What is the equivalent version of C # Java Webdriver @Findby?

I am transitioning from Java to .NET and I need to write Webdriver tests using the page object model.

In Java, I would use the following annotation:

@FindBy(linkText = "More details") WebElement moreDetailsButton; 

Please can someone tell me how to define WebElement using C #? Also used PageFactory.initElements in the same way?

Thanks Steve

+6
source share
1 answer

Yes, there is a direct translation.

Are you looking for FindsBy :

 [FindsBy(How = How.LinkText, Using = "More details")] private IWebElement moreDetailsButton; 

As for PageFactory.initElements , yes, it is very similar to .NET, usually called in the Object Object constructor:

 public class LoginPage { private IWebDriver _driver; public LoginPage(IWebDriver driver) { _driver = driver; PageFactory.InitElements(_driver); } } 

Please note that the Selenium project is fully open. You can easily see the source code "Helper classes of page objects here .

+7
source

Source: https://habr.com/ru/post/957337/


All Articles