Given a page with a <select> element and some <option>s, that when clicked cause the browser to open a new URL, like (JavaScript code omitted):
<select>
<option value="here">go here</option>
<option value="there">go there</option>
</select>
When I automate this behavior with WebDriver I call
hereOrThereSelectElement.SelectByValue("here");
and then it waits until the new page has loaded.
In my case, the page load for the new location takes more than 60s (intentionally), so I had to increase the command timeout of the WebDriver instance. Unfortunately this timeout will affect all other tests created with the same WebDriver instance.
Also I would like to perform an explicit Wait for the new page to load (to mark it as long running in the test scenario), but in this condition the next command will be called after the SelectByValue command succeeded – so no Wait needed anymore.
I looked into the source and realized that SelectByValue command uses the Click logics which waits for a page to load if needed.
So my question is: How do I explicitly perform a SelectByValue (or Click) without waiting for a new page to load?
Update:
What I actually want to have in my code is:
// the following command should not wait for the new page to load
hereOrThereSelectElement.SelectByValueButDoNotWait("here");
webDriverWait.Until(/* some "page has loaded" check */)
Finally, I found a solution for this.
Meanwhile the problem has slightly shifted to a call to a WebElement’s
Click()method that ran into the timeout. Nethertheless the following solution applies also to the original problem with callingSelectByValue().So, one can use Selenium’s
Actionslow-level interactions builder to perform a click on an element.Maybe this will help anyone having similar problems.