Selenium IE WebDriver only works while debugging
There are a couple of facts which you may have to consider as follows :
-
First of all:
public void waitForPageLoaded(WebDriver driver)
looks to me as a pure overhead. There is basically no need to write a separate wrapper function on top of WebDriverWait.
-
As per the current implementation of WebDriverWait in Selenium v3.8.1 the Constructors are as follows :
WebDriverWait(WebDriver driver, Clock clock, Sleeper sleeper, long timeOutInSeconds, long sleepTimeOut) WebDriverWait(WebDriver driver, long timeOutInSeconds) WebDriverWait(WebDriver driver, long timeOutInSeconds, long sleepInMillis)
It is pretty much unclear how you have implemented:
WebDriverWait(driver, SeleniumConfigurator.TIME_OUT)
The arguments looks error prone.
-
Again, the until condition
d -> ((JavascriptExecutor)d).executeScript("return document.readyState").equals("complete")
is a overhead because the Client (i.e. the Web Browser) will never return the control back to the
WebDriver
instance until and unless'document.readyState'
is equal to"complete"
. Once this condition is fulfilled Selenium performs the next line of code. Hence the functionBoolean org.openqa.selenium.support.ui.FluentWait.until(Function<? super WebDriver, Boolean> arg0)
will have no impact.
It's worth to mention that though the Client (i.e. the Web Browser) can return back the control to the WebDriver instance once
'document.readyState' equal to "complete"
is achieved, it doesn't guarantees that all theWebElements
on the new HTML DOM are VISIBLE, INTERACTABLE and CLICKABLE.Finally, to address your main issue, I needed a clarification about the node
xPath = "//*[@id='link-highlighted']/a"
to ensure whether invokingclick()
opens a new tab or url gets redirected. I don't see you handling either of the cases.
Solution
- While dealing with InternetExplorer, keep in mind InternetExplorerDriver runs in a real browser and supports Javascript.
-
Set the Browser Focus through :
capabilities.setCapability("requireWindowFocus", true);
If
click()
opens a new window, switch() through thewindow_handles
References
You can find a couple of relevant detailed discussions in:
- Do we have any generic function to check if page has completely loaded in Selenium
- Selenium how to manage wait for page load?