0

My page object contains different element with findsby attribute

[FindsBy(How = How.Id, Using = "hotelid")]
public IWebElement hotelreference;

[FindsBy(How = How.CssSelector, Using = "label[for='hotelname']")]
public IWebElement hotelname;

have another function which take IWebElement

public void waitForAjaxRequest(IWebElement element)
{
     //if there is no ajax request 
      element.Click()
}

but before clicking the element want to verify if element is exist. How can I verify if element exist because in page element we use different locator to find by element

delwasaf ewrew
  • 557
  • 1
  • 8
  • 21
  • When selenium cannot find a element two things happen. 1) The first reference to that element throws an ElementNotFound exception and 2) The value for the element will be Null. – JWP Jun 14 '16 at 17:14
  • If you're passing a IWebElement in parameter, it means the element is null or exists. If you will find it inside the method using the data anotation, you should to use `YourDriver.FindElements()`. If returns an empty list, the element does not exists – Striter Alfa Jun 14 '16 at 17:16
  • 1
    http://stackoverflow.com/a/32770597/5120498 – Striter Alfa Jun 14 '16 at 17:33

0 Answers0