- Introduction to Selenium with C#
- Referencing Selenium C# in Visual Studio
- Simple code with Selenium C#
- Using NUnit with Selenium C#
- Custom methods for Controls in Selenium with C# (Part 1)
- Custom methods for control in Selenium C# (Part 2)
- Refactoring Custom methods of control libraries
- POM in Selenium C#
- Page Navigation in Selenium C#
- Customizing custom library methods
- Using C# Extension methods for Selenium custom libraries
- Data Driven Testing using Selenium with C#
hi karthik,
In my selenium script after every 2-3 lines or randomly NoSuchElement found or StaleElementeference Exception is coming. How to resolve this so that in one time whole application run without any error please help me in it and one more doubt is while launching firefox in visual studio sometimes webdriverException came how to resolve this one also.
Thanks in advance
I think the best way is to wait for control to be exist before performing operations
new WebDriverWait(driver, TimeSpan.FromSeconds(timeOut)).Until(ExpectedConditions.ElementExists((By.Id(login))));
Thanks,
Karthik KK
Hello Mr. Karthik
Great Tutorial…
I want to study in udemy, is there a coupon code?
Thank You
Karthik sir,
How to handle pop-up box in selenium using C# lang. I searched and found a video for Java,can you please explain/provide video for C#
im sorry. i too don’t know.
how to handle pop ups in C#.
sorry sir i was searching at the top of the comments section that is the reason i did not notice my comments were already posted. sorry for writitng twice
How to genereate reports using C#
Hello, Mr. Karthik.
I greatly appreciate the tutorials you have provided. They helped me immensely. I was wondering if you could help me understand how to use selenium to read a downloaded file (one that is launched from the interface I’m testing in my selenium test – I click a button on the UI to launch a report which either downloads to a folder or else causes Excel to launch and display it, depending on my settings. I’d love to be able to do asserts on the values found in those files (.xlsx and .csv) and how to do diffs, but I’m running into issues with not being able to access the downloaded file and figuring out how to switch over to the Excel window to try asserts that way . Also, I was wondering if you could help explain garbage collection for selenium c# tests. I read in data from a spreadsheet that I pass into my methods in my tests, and each test runs great in isolation. But as soon as I run all of them together, the first runs and all the rest fail. I suspect that some sort of Excel resource is still tied up after the first test is run.
Cheers, Connie
Hi Connie,
The reason is because, Excel is an Windows application and Selenium wont support it.
You can either read the excel sheet and then perform the operation like verifying the data in excel sheet, here is the video explaining that https://www.youtube.com/watch?v=dMai7HW-J4U&index=12&list=PL6tu16kXT9PqKSouJUV6sRVgmcKs-VCqo
Thanks,
Karthik KK
Hi Connie,
For excel data parsing you can use POI libraries you can GET and SET data from any type of excel sheet there is no concern in Microsoft or APACHE product like our bro say that Excel is Microsoft and selenium is Apache . here is the big advantage of cross performing open source tools.
Hi Connie,
Pls find the below code and you can read data from .xls or .xlsx file. Provide file path and change code according to you.
public static String readFromExcelSheet(String filePath, String fileName,
String columnName) throws KDTKeywordExecException {
String configPath = "", expRowValues = "";
String allRowValues = "";
String fileVar = "", fileSend = "";
// To get canonical path..
try {
configPath = StringUtils.stripEnd(filePath, "/\\");
configPath = (new File(filePath)).getCanonicalPath();
} catch (IOException e1) {
e1.printStackTrace();
throw new KDTKeywordExecException(
"Error in config path assigning. ", e1);
}
fileVar = configPath + "\\";
fileSend = fileVar + fileName;
FileInputStream file = null;
try {
file = new FileInputStream(new File(fileSend));
} catch (FileNotFoundException e1) {
e1.printStackTrace();
throw new KDTKeywordExecException(
"File not found with the given path: " + fileSend);
}
// Create Workbook instance holding reference to .xlsx file
org.apache.poi.ss.usermodel.Workbook workbook = null;
try {
workbook = WorkbookFactory.create(file);
} catch (InvalidFormatException e1) {
e1.printStackTrace();
throw new KDTKeywordExecException(": " + fileSend);
} catch (IOException e1) {
e1.printStackTrace();
throw new KDTKeywordExecException(
"Not able to Create the file in the given path. : "
+ fileSend);
}
// Iterate through each rows one by one
Sheet sheet = workbook.getSheetAt(0);
Iterator rowIterator = sheet.iterator();
List rowValues = new ArrayList(200);
String rowValue = "";
// while (rowIterator.hasNext()) {
Row row = rowIterator.next();
// For each row, iterate through all the columns
Iterator cellIterator = row.cellIterator();
while (cellIterator.hasNext()) {
Cell cell = cellIterator.next();
// Check the cell type and format accordingly
switch (cell.getCellType()) {
case Cell.CELL_TYPE_NUMERIC:
rowValue = String.valueOf(cell.getNumericCellValue());
if (rowValue.length() >= 1) {
rowValues.add(rowValue);
}
System.out.println("Temp1: " + rowValue);
//
// System.out.print(cell.getNumericCellValue() + "t");
break;
case Cell.CELL_TYPE_STRING:
rowValue = cell.getStringCellValue();
if (rowValue.length() >= 1) {
rowValues.add(rowValue);
}
System.out.println("Temp2: " + rowValue);
// rowValues.add(temp);
// System.out.print(cell.getStringCellValue() + "t");
break;
}
}
System.out.println(""); // gets one complete row
// }
try {
file.close();
} catch (IOException e) {
e.printStackTrace();
}
int value = 1;
value = rowValues.indexOf(columnName);
sheet = workbook.getSheetAt(0);
Iterator rowIterator1 = sheet.iterator();
String rowValue1 = "";
if (rowIterator1.hasNext())
rowIterator1.next();
boolean saveValue = false;
try {
while (rowIterator1.hasNext()) {
Row row1 = rowIterator1.next();
// For each row, iterate through all the columns
Cell cell = row1.getCell(value);
// Check the cell type and format accordingly
switch (cell.getCellType()) {
case Cell.CELL_TYPE_NUMERIC:
rowValue1 = String.valueOf(cell.getNumericCellValue());
if (rowValue1.length() >= 1) {
expRowValues = rowValue1;
}
System.out.println("Temp1: " + rowValue1);
saveValue = true;
// System.out.print(cell.getNumericCellValue() + "t");
break;
case Cell.CELL_TYPE_STRING:
rowValue1 = cell.getStringCellValue();
if (rowValue1.length() >= 1) {
expRowValues = rowValue1;
}
if (rowValue1.length() = 1) {
expRowValues = rowValue1;
}
System.out.println("Temp2: " + rowValue1);
saveValue = false;
// rowValues.add(temp);
// System.out.print(cell.getStringCellValue() + "t");
break;
}
if (saveValue) {
allRowValues = allRowValues + expRowValues.trim() + ";";
}
}
} catch (Exception e) {
// no exception
}
String moreValuesString[] = allRowValues.split(";");
System.out.println("Length of the String: " + moreValuesString.length);
if (moreValuesString.length <= 1) {
allRowValues = moreValuesString[0];
}
return allRowValues;
}
Hello Karthik
Firstly, thank you for the Selenium tutorial videos!
I was hoping to get your advise to resolve an issue with “Opening of links in a new tab/window using IE 11” using selenium webdriver C# . In my AUT on clicking a link a new tab is opened , However in IE when the link is clicked the browser opens 2 new windows and is unable to switch to the newly opened window . I use the below code to switch tabs
var parentwindow = driver.CurrentWindowHandle;
link.Click();
var newwindow = driver.WindowHandles.Last();
driver.SwitchTo().Window(newwindow);
Please let me know if anything different needs to be done for IE , becasue this work fine in Firefox and chrome browsers.
Hi Karthik,
Many thanks. I am your Udemy student, (Selenium with C#). Can you help me for Scala with Selenium please? I am looking for join immediately.
I look forward to hear from you asap and thanks again.
Kind regards,
Raja
Hi Karthik,
Please make the new tutorial on hybrid framework in selenium by using c# from scratch.
I have searched , but not yet find in Google.
Thanks®ards,
Sathya.M
You can find the paid content of framework development from here https://www.udemy.com/framework-development-with-selenium-csharp-advanced
Thanks,
Karthik KK
Coupon plz
Please check your email !
Hi,
I want to register for this course.Can i get a coupon for this?
Regards,
Rishi Raj
Hi Karthik,
Please let me how to run multiple test cases by using a single file in selenium c# with Nunit.
Regards,
Koti
Hi Kartik,
I am working on a website, where I have looped three dropdowns and when I click on Search, it will take to another page, is there a way where we can go to the previous page and go to the next option in the dropdown and click on Search.
You can use this method Driver.Navigate().Back() to navigate to previous page to perform operations !!!
Hi Karthik,
I sent you couple of emails with a question of using selenium with C# on mac-pro. I am posting the query again here with this email. Can you please help me on this?
1) In order to develop selenium tests using C# on mac system, what I need to install?
a) I need to install visual studio community version 2015 from visualstudio.com
or,
b) I need to install virtual machine (parallel) to run visual studio in it
or,
c) I need to install MonoDevelop
I will highly appreciate your response.
Thanks,
Rezaul
Hi Rezaul,
Here are the answers for your question
1. You need to install VS in Parallel, since other than that nothing will support debugging options.
Thanks,
Karthik KK
Thank you sir!!!
Hi Karthik,
Greatly impressed and gained much knowledge by all your videos! I’m an Automation QA, doing along BDD Specflow. I would like to run my tests using Selenium Grid in parallel. I did watched all your JAVA videos, still wondering is there any links or blogs executing Selenium Grid in C#.
Thanks in advance!
Hi Karthik,
I have seen your C# Selenium videos. Its pretty useful.
1) I started working on it. But on the whole i was unable to get all the concepts when i started working on real time scenarios.
Please provide me a guidance how to Summarize all the concepts with a sample work flow so that i can make it over(Like all the concepts need to know to work on a real time project)
2) Whenever i search a guidance to solve an issue or problem, I am getting all the Java related solutions except a few like your blog. So please suggest some good blogs and Sites to follow with C# Selenium.
3) I want to know the theoretical or the concepts involved for all the concepts for learning and Interview point of view so can u suggest some good books to get all these concepts(C# with Selenium).
Finally, Please let me know the scope of the Selenium C# Automation in Current Industries now.
I apologize for asking too many questions.
All these answers i can get it in google but a clear answer like experienced like you will be always better.
Awaiting a good reply from you.
Contact : santhoshkumar.ac11@gmail.com
Thanks
Hi Karthik
Please can you tell how to priorities the test cases.
Is there any other method for reporting for the execution other than html and excel sheet??? I am trying to create a report which is very interactive for the end user.
I think you may be interested in this http://executeautomation.com/blog/advanced-automation-reporting-system-with-ears/
Thanks,
Karthik KK
Hi Karthikh I’m Vidya , can you send me the code to handle the file uploads Window in selenium C# for automating one of the feature in my application , thanks .
hello karthikh
i have some doubt before purchasing the course . please help me to find out which option is better.
i know both native language c# and java , but i want to know that which platform is better for selenium for better scope in future . will i choose c# or java
please specify why we choose c# or java ?
I guess it depends on you !!!
But to me C# is much better than Java, since there are many different tools and technologies currently visual studio has which even Java wont support.
Thanks,
Karthik KK
Hi Kartik ,
Excellent Video’s …Appreciate your efforts taken for this . This videos has helped me a lot … Can you share some API testing tutorials (SOAP/REST) as it is in great boom . I have explored it all over the net but couldn’t find suitable videos all seems to be like for laterals levels who has some prior knowledge of API testing , and rest i am not able to grasp anything . that would really help all of us …reply awaited .
Awesome !!!
You can checkout this playlist for API testing, but its WCF not SOAP/REST. BTW SOAP and WCF are pretty much the same, so you can still learn how we can do API testing with C# https://www.youtube.com/playlist?list=PL6tu16kXT9PrHl9RTqJ6lAUA2ViJPZXna
Thanks,
Karthik KK
Hi karthik,
i am working as manual tester, i am average programmer in c# net asp.net, i would like to know what type of bug report is integrated with selenium to generate bug report using visual studios. and how to generate bug report after execution of test cases using selenium and c#.
please can you suggest and guide me how to set up selenium environment like integration of bug report and how run test cases and generate bug report using selenium and c# in visual studios.
thanks
krishna
For reporting you can checkout the following course https://www.udemy.com/creating-automation-reports-with-ears which has all your answers for the questions
Thanks,
Karthik KK
Hellp kathik
I already purchased your content i.e c# advanced course that was very helpful to me .
but i want to know that how to generate a test report in c# like TestNG report
hope you will give me a positive response as soon as possible.
Hello Karthik,
Can you please send me a coupon for ‘Selenium with c#’ in Udemy
Hi Karthik,
I am new to this field, I am working on Selenium automation.
I have same questions……
I have seen your C# Selenium videos. Its pretty useful.
1) I started working on it. But on the whole i was unable to get all the concepts when i started working on real time scenarios.
Please provide me a guidance how to Summarize all the concepts with a sample work flow so that i can make it over(Like all the concepts need to know to work on a real time project)
2) Whenever i search a guidance to solve an issue or problem, I am getting all the Java related solutions except a few like your blog. So please suggest some good blogs and Sites to follow with C# Selenium.
3) I want to know the theoretical or the concepts involved for all the concepts for learning and Interview point of view so can u suggest some good books to get all these concepts(C# with Selenium).
Finally, Please let me know the scope of the Selenium C# Automation in Current Industries now.
I apologize for asking too many questions.
Awaiting a good reply from you.
For all your questions, the one answer is this video course which I have released in Udemy https://www.udemy.com/framework-development-with-selenium-csharp-advanced/?instructorPreviewMode=guest
If you are interested let me know, I will share the discount coupon code.
Thanks,
Karthik KK
Yes i am interested kindly share the coupon code.
Done !
Hi Karthik,
How to write code in C# for pop-ups…..like conformation(Yes or NO)
Hello Karthik,
In real time console application is used with visual studio with selenium driver..? . can you please explain me the real time environment and structure of the selenium process in organizations.
Can you have take a look @this course https://www.udemy.com/framework-development-with-selenium-csharp-advanced, you can get an clear understanding of how things works in organization.
If you are interested in the course, mail me to get discounted coupon code.
Thanks,
Karthik KK
Hi Karthik,
Can you please send me a coupon code for the udemy video: Automation framework development with Selenium C# (Advanced)
Thanks!
Please check your inbox for latest coupon code.
Thanks,
Karthik KK
Hi karthik ,
I am beginner in selenium c# automation . I have query .I created one ms unit test project , how can i run multiple test cases in same browser without closing browser , how we can run all test cases in one browser . e.g if we have 15 test methods and i created one [TestInitialize] attribute method, there i am creating instance of chrome driver .now for 15 test method , it create 15 instance of browser .
Is there any solution ,Please help me
Can you please tell me how I can manage test suites using NUnit. I know in TestNg we use to call in the .xml file but how can I manage up in Nunit. For example not to call particular test case from the test suite. Or to run selected test cases from different test suites in Nunit.
Hi….I’m finding it difficult to identify shadow dom elements. Is there a way that we can identify these elements just like how we identify the other elements. Appreciate your support.
Hi Karthik,
I have gone through the videos of appium and trying to launch the app in Android Emulator.
Android Emulator opens up correctly but the app does not open up.
Appium Server Gives: Telnet command got response: a[K[Dav[K[D[Davd[K[D[D[Davd [K[D[D[D[Davd n[K[D[D[D[D[Davd na[K[D[D[D[D[D[Davd nam[K[D[D[D[D[D[D[Davd name[K
Code:
[TestMethod]
public void TestMethod1()
{
//string abc = “C:\app-bettingClubTheme-debug.apk”;
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.SetCapability(“platformName”, “Android “);
capabilities.SetCapability(“platformVersion”, “6.0”);
//capabilities.SetCapability(“platform”, “Windows”);
capabilities.SetCapability(“deviceName”, “Android Emulator”);
capabilities.SetCapability(“app”, “/app-bettingClubTheme-debug.apk”);
Console.WriteLine(capabilities);
//Connecting to Appium Server
driver = new AndroidDriver(new Uri(“http://127.0.0.1:4723/wd/hub”), capabilities);
}
Any Info to resolve this would be helpful.
Regards,
Namresh
hi kartik,
i wanted to know can i use my visual studio professional for starting my testing in selenium? or i have to get ultimate version?
Thank you in Advance
farhana
No Farhana, you can use even community edition, nothing to do with Enterprise edition (previously called as Ultimate)
Thanks,
Karthik KK
How to generate reports using C#
Here is the way https://github.com/executeautomation/ExecuteAutomationReportingSystem
Hi Karthik,
I’m learning Selenium through ur videos. In mean time Im trying the same in Visual Studio.. While practicing Page Navigation part, Im facing an exception of “OpenQA.Selenium. NoSuchElementException: couldnot find element by:By.Name:Initial”.
[FindsBy(How = How.Name, Using = “Initial”)]
public IWebElement txtinitial{ get; set; }
[FindsBy(How = How.Name, Using = “Save”)]
public IWebElement save { get; set; }
public void FillUserForm(string initial)
{
poinitial.SendKeys(initial);
btnsave.Click();
}
Regards,
Navaratnaa.
Hi Karthik,
I am new to the selenium, i started leaning selenium through your valuable videos.
Thanks for all the vidoes which can be accessible without any pay.
I am trying the below program but could not able to succeed it.
Program: accessing the month drop down in Google sign in page.
elem3 = elem3.FindElement(By.XPath(” *div[@id=’:8′]/div”));
The above statement is throwing an exception. (No Such element found exception)
Could you please help me to resolve this.
Hi Priya,
The way you are identifying element is not going to work out, since the value from google is always dynamic
div[@id=’:8′]/
you need to identify unique identifier.Thanks,
Karthik KK
Hi Karthik,
Can you provide me the some idea how to execute this ?
I tired many ways i could not succeed. Could you please help me.
Hi Priya,
Can you let me know what problem you are getting while executing the code ?
Hello Karthik sir,
Can you please tell me how to do selenium automation testing on .net platform , can you please tell where i will get to learn selenium automation testing in .net at no cost.
Thank you sir
I guess the question you are asking is the exact page where your answer lies.
Thanks,
Hi karthik,
Thank you for sharing your valuable information.
can you add one more video that is related to taking screen shots.
Thank you,
Harish MS
Its here https://www.youtube.com/watch?v=yyFpRuhWtVU
Thank u Karthik.
i need this information in C#
Hi Karthik,
I really liked this blog
can you give me coupon code for your Udemy Course
Thanks
Your email id is not valid and it bounces back
Hi Karthik,
Can you please provide a coupon code for this course in Udemy: “Automation framework development with Selenium C# (Advanced)”
Thanks!
Hi Karthik,
Can you please provide a coupon code for this course in Udemy: “Automation framework development with Selenium C# (Advanced)”
Thanks!
Hi Stephen,
Please check your inbox for coupon code.
Thanks,
Karthik KK
Hi Karthikk,
Could you please revert as to how can we save exported excel directly to a folder ?
Like, how to automate notification bar at bottom in ie9 when click on “Export to excel” , which says Open, Save, Cancel.
Also, if we can write selenium code in WCF Service and consume this in windows service client.
Hi Karthik,
I have done automation testing in Selenium Webdriver with Java and TestNG. Now I have to implement it in c#. When I saw the tutorials, they are using NUnit with it. But one of my collegue said that it is not good to use NUnit, because NUnit is used for unit testing. If this is right, then what can be used instead of NUnit?
NUnit is best and its used for framework developments now, you can checkout this course which is used in many companies and its proven Udemy course
Thanks,
Karthik KK
Hi kartik,
This is my code
IWebElement query1 = g.FindElement(By.Name(“FirstName”));
query1.SendKeys(“vikram”);
query1.Submit();
/* if (!g.FindElement(By.XPath(“.//*[@name=’FirstName’]”)).Text.Equals(“vikram”))
{
g.Close();
throw new Exception(“assertText ‘Firstname’ failed”);
}*/
I want to give validation on send key,whatever i am sending the text it will be validate first with the text that i had decided and give me the output of error if the text is not same .
Hi Karthik,
I am facing an issue with drag and drop on Angular JS page with Firefox and Chrome. The page has 3 div containers and all elements are within these containers. I have used the DragandDrop functionality from Actions interface and it worked with Internet explorer.
I have not found a solution for Chrome and Firefox. I observe that there is some action happening on the draggable element but it is not moved to the droppable element.I have used all methods like DragandDrop as well as calling Javascript codes mentioned on github.
Is there a known issue on Firefox and Chrome draganddrop when used with Angular js and is there way to overcome the same. Do you know of any working solution for DragandDrop.
Regards
Vivek
Hi,
I want to join Automation framework development with Selenium C# (Advanced) course.Can i get a coupon for this course?
Regards,
Rishi Raj
Please check your inbox for discount coupon code.
Thanks,
Karthik KK
Hi Karthik,
Require a coupon code for the course “Automation framework development with Selenium C# (Advanced)”
Iam new to C#, i need to do a Automation project and implement in my local machine only. my project has 3 entities and each entity has around 200 test cases. it is ok to implement this project using Nunit or should i use MS TEST .
If it is ok to implement with the NUnit , please guide me through our courses where to start and can you give me the sequence to follow the video series. Not only the above iam ready for other paid courses if needed. please share me the coupon codes if available.
i found 4 video series of yours which are mentioned below. can you please guide me to follow the sequence so that i can complete my automation projrct
C# for Automation Testing
selenium automation with C#
Automate application with Specflow and Selenium C#(this course was said as free in the “Automation framework development with Selenium C# (Advanced)” course but it is a padi course in udemy)
Automation framework development with Selenium C# (Advanced)
Please check your inbox for details and coupon code.
Thanks,
Karthik KK
Hello Karthik,
Could you please share coupon code for the below course in Udemy.I would like to buy the course.
Angular automation with Protractor + Typescript + Cucumber
Thanks
Regards,
Pramod
Please check you inbox for discount coupon Pramod.
Thanks,
Karthik KK
Hi Karthik,
Great job with the training videos. Wanted to check the udemy course for ‘Automation framework development with Selenium C# (Advanced)’ Can you help with a coupon code?
Thanks,
Sachin
Please check your inbox for the latest coupon code.
Thanks,
Karthik KK
Hi Karthik,
First of all….thanks for your videos.
Can you explain me how can I use FluentWait in Selenium with C#.
I am unable to find in google also… its very much important to solve this fluentwait. pls help me.
waiting for your reply…..
Thanks and Regards,
Hi Karthik
Thank you for your efforts.
I just want to know about page object model thing. In a e commerce website if we have 100’s of products and each product has its own page.. then do we need to have a separate page for each product to perform some action. Lets say i have mobile page which have 15 products and when ever i click on specific product it will land on its details page. so do we need to create 15 class files for each class or do we have any alternate for this.
Sooner response will be helpful.
Thank you once again for taking time to spread the knowledge.
Hi Karthik,
I would like to Learn Selenium with C# (“‘Automation framework development with Selenium C# (Advanced)) , Can you help with a coupon code?
Regards
Please check your inbox for discount coupon code.
Thanks,
Karthik KK
Hi Karthik,
I have completed selenium with C# from your Youtube channel and executeautomation.com website. Can you please help me with a coupon code of —Automation framework development with Selenium C# (Advanced).
Thanks in Advance.
Hi Arijit,
Please check your inbox for latest coupon code.
Thanks,
Karthik KK