0

been struggling with this for few hours. My XPath is right but I get this error message. I don't seem to get a way forward on this

o such element: Unable to locate element: {"method":"xpath","selector":"//a[@class='btn primary block']"} (Session info: chrome=68.0.3440.106) (Driver info: chromedriver=2.41.578706 (5f725d1b4f0a4acbf5259df887244095596231db),platform=Mac OS X 10.11.6 x86_64) (WARNING: The server did not provide any stacktrace information) Command duration or timeout: 0 milliseconds For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html

NydPage nydPage;
GetAQuotePage getAQuotePage;

@FindBy(xpath="//a[@class='btn primary block']")
WebElement GetAQuoteLink;

public NydPage() {
    PageFactory.initElements(driver, this);
}

public GetAQuotePage clickOnGetAQuoteLink() throws Exception{
    Thread.sleep(5000);
    GetAQuoteLink.click();
    return new GetAQuotePage();

}

@BeforeMethod
public void setUp() {
    //driver = new ChromeDriver();
    initialization();
    testUtil = new TestUtil();
    nydPage = new NydPage();
}

@Test(priority=1)
public  void verifyQuotePageLinkTest() throws Exception{
    //testUtil.switchToFrame();
    Thread.sleep(5000);
    getAQuotePage = nydPage.clickOnGetAQuoteLink();

}


@AfterMethod
public void tearDown() {
    driver.quit();
}
Sam.fan
  • 1
  • 2
  • Yuck! Thread.sleep(...). Surely you can wait for a javascript condition to be true (eg some DOM element exists) – lance-java Aug 31 '18 at 15:14
  • 1
    *"but I get this error message"* What error message would that be? – Andreas Aug 31 '18 at 15:21
  • Looks like you have invalid chars in the class name, are you sure spaces are ok? https://stackoverflow.com/q/448981/217324 – Nathan Hughes Aug 31 '18 at 16:07
  • Can you [edit] your post and add the relevant parts of the page? Is the page fully loaded when you try to find the `a`? – Robert Aug 31 '18 at 17:16

0 Answers0