Page Navigation in Selenium C#

In last post we discussed about Page Object Model in Selenium with C# and we also created a simple page object for the EA Page. In this post we will start working with Page Navigational concept of Page Object Model and try to work with two different pages like Login page and EA page and try to demonstrate the concept.

We have already discussed about page navigation concept in Selenium with Java, and in this post we will talk the same concept using Selenium with C#.

Here is the complete video of above discussion

Here is the complete code from the above video

Code for Login and EA Page

Code for Test Script

Thanks for watching the video and reading the post!!

Please leave your comments and let me know if there is anything need to be improved in the post!!!

Karthik KK


  1. swetha says:

    How to handle controls in modal popup, through page object model?
    By following your instructions, when i click on a link which opens up in pop, i get an error “Null refernce exception was handled”

  2. vivek says:

    Hi Karthik,
    Why can we create just one class that has objects and methods for all the pages in the website. Advantages:
    1) We will have less number of .cs files
    2)we would have some less lines of code
    3) As we will have all the page objects in one file, maintenance will be easier.
    Any thoughts?

    • Karthik kk says:

      Hi Vivek,

      What you have said is opposite to what I have demonstrated, but thats not going to help anyways for bigger projects.


  3. Sergey says:

    Hello Kartik !
    I really liked your lessons. POM – Great. But you nothing tell about hidden elements and hover actions. Could you give me a simple way to use hover actions (hidden elements) in selenium C#, using custom methods and POM. Thanks a lot !

    • Karthik kk says:

      You cannot hover on an hidden element, since it wont get rendered in DOM though, may I know whats your usecase to hover in hidden elements ?

      • Sergey says:

        Here is my code: (I copied from your lesson in Java)
        public void Property()
        IWebElement menu = driver.FindElement(By.Id("Automation Tools"));
        IWebElement selenium = driver.FindElement(By.Id("Selenium"));
        IWebElement seleniumRC = driver.FindElement(By.Id("Selenium RC"));
        hover(driver, menu);
        hoverAndClick(driver, selenium, seleniumRC);
        public static void hover(IWebDriver driver, IWebElement element)
        Actions action = new Actions(driver);
        public static void hoverAndClick(IWebDriver driver, IWebElement elementToHover, IWebElement elementToClick)
        Actions action = new Actions(driver);

        As you can see, this code found a Selenium RC element and click on it.
        I would like to know, can I write this code a shortly and simply.

Leave a Reply

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