How to wait for the page to load in HtmlUnit not HtmlUnitDriver

397 Views Asked by At

I have a selenium code below which wait for the page to load before the action(click button) is performed. How do I do the same thing with HtmlUnit not HtmlUnitDriver.


driver = new ChromeDriver();

WebDriverWait wait = new WebDriverWait(driver,30);

wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//button[text()='couple']"))).click();

I know there is this line of code below in HtmlUnit:

webClient.waitForBackgroundJavaScript();

But does it do the same thing?

1

There are 1 best solutions below

3
RBRi On

No this is not the same.

ExpectedConditions.elementToBeClickable waits until the element is there/visible and enabled.

webClient.waitForBackgroundJavaScript(timeoutMillis) looks only for (async) JavaScript jobs and waits if there are still any that are currently running or waiting in the queue.