In this series, we will discuss working with Selenium in C# along with Visual Studio IDE. Selenium with C# is yet another language binding of Selenium WebDriver, but most popularly used like Java. As many people started to work with Selenium and are very focused on one specific language like C#, this series is aimed for those who wants to learn automating application with Selenium in C#. Here is the complete series of articles discussed related to Selenium automation with C#

147 comments

  1. Mahima says:

    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

    • Karthik kk says:

      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

  2. Ravikrishna says:

    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#

    • Ravikrishna says:

      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

  3. Connie says:

    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

  4. Veena says:

    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.

  5. Raja says:

    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

  6. Sathya says:

    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&regards,
    Sathya.M

  7. Koti says:

    Hi Karthik,

    Please let me how to run multiple test cases by using a single file in selenium c# with Nunit.

    Regards,
    Koti

  8. Sony says:

    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.

  9. Rezaul Aziz says:

    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

  10. Prabhu says:

    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!

  11. Santhosh Kumar says:

    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

  12. Abhiram says:

    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.

  13. Vidya Sagar says:

    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 .

  14. Rohit Saini says:

    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 ?

    • Karthik kk says:

      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

  15. Mandar M says:

    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 .

  16. krishna says:

    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

  17. Rohit Saini says:

    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.

  18. srinivas says:

    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.

  19. krishna says:

    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.

  20. Pramod Kumar says:

    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

  21. omer says:

    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.

  22. Sharmila says:

    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.

  23. Namresh says:

    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

  24. farhana says:

    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

    • Karthik kk says:

      No Farhana, you can use even community edition, nothing to do with Enterprise edition (previously called as Ultimate)

      Thanks,
      Karthik KK

  25. Navaratnaa says:

    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.

  26. priya says:

    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.

    • Karthik kk says:

      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

  27. @Aaditya says:

    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

  28. Harish MS says:

    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

  29. Mie says:

    Hi Karthik,

    Can you please provide a coupon code for this course in Udemy: “Automation framework development with Selenium C# (Advanced)”

    Thanks!

  30. stephen says:

    Hi Karthik,

    Can you please provide a coupon code for this course in Udemy: “Automation framework development with Selenium C# (Advanced)”

    Thanks!

  31. rahul says:

    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.

  32. Amrutha says:

    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?

  33. vikram sharma says:

    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 .

Leave a Reply

Your email address will not be published. Required fields are marked *