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

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?



Solution 1:[1]

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.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Sergey Vyacheslavovich Brunov