0

I have a helper class where I've initialised the chromedriver as well as set the driver implicit timeout to 10 seconds in its constructor:

public HelperClass {
        System.setProperty("webdriver.chrome.driver", "src/resources/chromedriver");
        chromeDriver = new ChromeDriver();
        chromeDriver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
}

In my test classes, I am also defining a HelperClass object:

public class Test {
    public static HelperClass helper = new HelperClass();

Now if I have a test where a button with a link to another page is clicked and then another element within the new page is polled, the test will immediately fail since the new page has not been loaded yet. Shouldn't the browser wait for 10 seconds before it throws the error: org.openqa.selenium.WebDriverException: unknown error: unhandled inspector error: {"code":-32000,"message":"Cannot find context with specified id"}

test:

helper.click(createNew); helper.click(dropdownMenu);<---fails on this. Works if I add an explicit wait right before this line

Any helper would be appreciated.

Andreas
  • 154,647
  • 11
  • 152
  • 247
Ken
  • 1
  • 1
  • Possible duplicate of [Using implicit wait in selenium](https://stackoverflow.com/questions/45672693/using-implicit-wait-in-selenium) – undetected Selenium Feb 24 '18 at 11:54
  • Not a duplicate. I want to know why the implicit wait is failing in this instance – Ken Feb 25 '18 at 17:27
  • @Ken Show us how did you pass `chromeDriver` to line which throws the exception. – Fenio Feb 26 '18 at 08:04
  • @RafałLaskowski So the chromedriver is being used in the click function of the Helper class: ```public void click(Object elem) { Actions actions = new Actions(chromeDriver); actions.moveToElement(getElement(elem)).click().perform(); }``` The getElement function simply returns a locator to the element. – Ken Mar 02 '18 at 17:20
  • @Ken Please, edit your question and add `Test` class with test methods and `getElement()` method – Fenio Mar 02 '18 at 17:30

0 Answers0