0
votes

I'm getting this error while trying to find the web element for testing the facebook "create a page">"sign up" button under Page Object Model. I tried various options like by class name(CSS selector) and also by copying the system xpath but getting the same error message

org.openqa.selenium.NoSuchElementException: no such element : Unable to locate element

/driver.findElement(By.xpath("//*[@id='blueBarDOMInspector']/div/div[1]/div/div/span/a")).click();
driver.findElement(By.className("_42ft _4jy0 signup_btn _4jy4 _4jy2 selected _51sy"));
1

1 Answers

0
votes

Looks like you class name generates randomly - you can check it by re-visiting same page from different browsers (or you can try incognito). If it's true you need another way to work with element. Some examples:

  1. If this Sign Up button - use xPath and look for the text in that element
  2. Think if your task can be resolved without using interaction with UI (or part of the task). Read about facebook API and if possible use this instead of UI. It will save you a lot of time and hassle down the road.