Reputation: 549
Could you explain the difference between By
element and IWebElement
s.
Also, why doesn't selenium use one or the other?
[FindsBy(How = How.XPath, Using = "//div[@class='example']/h3")]
private IWebElement _heading;
and
var byElement = By.XPath("//div[@class='example']/h3")
Upvotes: 2
Views: 4756
Reputation: 474031
IWebElement
is a selenium Web Element class which represents an HTML element (body
, table
, tr
etc) on a page in your selenium automation code. Through the IWebElement
instance, you can interact with an element, retrieve it's attributes and properties.
By.something()
is just a locator - the way you tell selenium how to locate the element within the document so that you can make an IWebElement
instance. The are different built-in locators, like By.Xpath
, By.CssSelector
, By.Id
etc.
Upvotes: 6