Webdriver can login in Chrome, not in firefox: 'Unable to find owning document' error

后端 未结 2 1998
傲寒
傲寒 2020-12-12 01:29

I have 2 classes belonging to the same package in a java testNG project and I have declared \'webdriver driver\' public static in class A. In that class, chrome launched, ur

相关标签:
2条回答
  • 2020-12-12 01:33

    This is an issue caused by the Firefox version in use, 49.0.2. It's a weird case and unclear why login functionality is being imparted by the browser version in use;however, resolving the issue requires a downgrade to version 46.0. This fixed the problem.

    0 讨论(0)
  • 2020-12-12 01:36

    edit: See this very relevant question and answer

    If you edit the post to include relevant html, this would be easier to help with.

    Try with cssSelector:

    Inspect the login button. Within the inspector, right click the element and copy the CSS Selector.

    driver.findElement(By.cssSelector("copypasta")).click();
    

    Try to locate by xpath using several different methods listed in this useful cheat sheet.

    For example, if the inner html text for your button is 'Login':

    driver.findElement(By.xpath("//button[contains(text(), 'Login']")).click();
    

    There are many different ways to do this, so looking at your html will help people help you, I think.

    0 讨论(0)
提交回复
热议问题