POM in Selenium C#

Page Object Model (POM) is best known for modeling the UI objects of page within test codes was discussed a lot more detail as article as well as in video in our blog as shown below

In this article we will discuss how to work with Page Object Model in Selenium with C# also we will discuss about some of the minor changes in Selenium with C# and Java

Minor Changes in Selenium C#

JAVA C#
POM of Java works even without specifying the @FindBy attribute, since by default Java POM picks the WebElements by their ID or Name specified as the name of the property in POM class In C# POM the option is not available and it throws NOSUCHELEMENTEXCEPTION
POM in Java first identifies the element with ID and if it fails, then it try to identify the control using its Name C# it identifies element only with ID but not with Name

 

Here is the complete video of the above discussion

Here is the snippet of code from the above video

EAPageObject

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!!!

Thanks,
Karthik KK

7 comments

  1. Drew Resner says:

    Hello,
    I attempted to follow your teaching in video 8 POM. I’m getting an error when I write the FindsBy attribute on the How key word – the error is “LaunchQuest.FindsByAttribute does not contain a definition for How”

    This is the code.
    using OpenQA.Selenium;
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using OpenQA.Selenium.Support.PageObjects;

    namespace LaunchQuest
    {
    class PersonPageObjects
    {
    [FindsBy(How = How.Id,using=”a.mainNav-person”)]
    public IWebElement ClickPerson { get; set; }
    }
    }

    • Karthik kk says:

      Hi Ankita,

      You are correct, the videos
      Page Object Model in Selenium — Part 1
      Page Object Model in Selenium — Part 2

      Are in Java, but the core video is still in C#, since the Part 1 and Part 2 gives a detail theoretical explanation as well !!!

      Thanks,
      Karthik KK

  2. swathi says:

    Hi Karthik,

    I am new to selenium your videos are very helpful, Can you please explain about implicit and explicit waits and when they can be used safely?

    Thanks,
    swat

  3. Sachin Patil says:

    Hi Karthik,
    These all videos are of great use to people who want to learn Selenium.
    Thanks for these videos. Can you also suggest some dummy sites, where we can practice selenium with some more web elements available.

    • Karthik kk says:

      There is one right here executeautomation.com/demosite/Login.html, not sure if the controls are enough for your practice !!!

Leave a Reply

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