S
S
sinneren2018-07-02 09:04:50
Java
sinneren, 2018-07-02 09:04:50

How to properly slow down the condition check when moving to another page?

@Then("^переход на \"([^\"]*)\"$")
    public void shouldBe(final String shouldBeUrl){
        WebDriverWait waitForOne = new WebDriverWait(driver, 10);
        waitForOne.until(ExpectedConditions.urlToBe(shouldBeUrl));
    }

I use this design, but it works in 1/10 case, I guess. No 10 seconds wait.
This design doesn't work either.
driver.manage().timeouts().implicitlyWait(4, TimeUnit.SECONDS);

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
azShoo, 2018-07-02
@azShoo

Move wait into a separate function that takes a driver and a target element as input.
The function in a loop with a minimum timeout checks the target element for presence\visibility\clickability, as soon as it finds it, it returns true.
From above, screw the maximum timeout so that it does not fall into an endless loop and voila.
You have a wait that waits just long enough for the target element to appear.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question