So, I ask again... Why, oh why, oh why why, oh why why why?
WebDriverWait wait = new WebDriverWait(driver, 10); WebElement element = wait.until(ExpectedConditions.elementToBeClickable(By.id("someid")));
reference - http://seleniumhq.org/docs/04_webdriver_advanced.html
You see, Tarun, this is part of my rant. This would not work:driver.manage.timeouts.implicitlyWait(10, TimeUnit.SECONDS)...and at some point afterwards...driver.manage.timeouts.implicitlyWait(0, TimeUnit.SECONDS)Because once you set implicitlyWait for a WebDriver is does not change for the life of that driver.I am making the choice you mentioned: To not use implicit waits and to always rely on explicit waits for synchonization. This makes my suite less reliable, especially as many people write scripts and may or may not make the appropriate explicit wait calls.I am, however, using RemoteWebDriver.manage().timeouts().pageLoadTimeout(15, TimeUnit.SECONDS), this brings a little more reliability as in providing a minimum waiting time when we move to an entire new page.But I still wish I could set a "default" for the whole suite, and at the same time, when I need, explicitly wait for 5 seconds, 1 second, 0 seconds, etc. as I please. This I think is not possible and I am sorry that it is.
Yes Mike, but a default is (would be) useful for reliability across a whole suite of tests. You may be carefull to insert an explicit wait (or a call for a waiting routine) every time that one is needed or you may not. Also, implicitly waiting extracts from the scripts and to me that means more maintainability and less test code. Test code is a lousy place for an error to be. So I implicitly wait for page loads and re-loads. Tester need not worry (too much) about "hm, is this call to this component going to reload the page?". Also, how about when the GUI may change behaviour and your script may break unnecessarily.Of course there are many many moments when a call for a routine with an explicit value for timeout is in place, but I just can't do that in conjunction with having set a default... because it will always wait at least for the value set on implicitlyWait()... still don't see why it should be this way.In short, when I "tell" the driver how long it should wait, it should wait for that amount. When I do not "tell" it, because I forgot, because the application behave unexpectedly, or because I plain don't need to, it should DE-FAULT by itself and wait at least the default value before it goes ahead and "breaks all the dishes".Well... my point of view so far.
Hey Mike. Thank you, for the consideration. And just for the record, please do not interpret my comments as malicious, as they were all made in good spirit.
It can also cause explicit waits to not work as intended because the implicit wait overrides the settings of the explicit wait.
Generally if you know you need to wait for something do it explicitly, don’t ever set implicitlyWait()!
From: seleniu...@googlegroups.com [mailto:seleniu...@googlegroups.com] On Behalf Of Chon Chung
Sent: 29 September 2012 03:24
To: seleniu...@googlegroups.com
Subject: [selenium-users] Re: Why can't I Bypass WebDriver implicitlyWait once implicitlyWait is set?
Andre and Tarun:
I create WaitTool class to use implicitlyWait() and webDriver at the same test.
Here is Presentation http://chon.techliminal.com/ajax_wait/
source code is in github https://github.com/ChonC/wtbox/blob/master/src/wtbox/util/WaitTool.java
How do you think? Is it work?
Chon Chung
On Wednesday, August 8, 2012 3:05:05 PM UTC-7, andre wrote:
In short:
Why, oh why, oh why why, oh why why why, can't we alter the default timeout by calling WebDriver.manage().timeouts().implicitlyWait() a second time? Or have some other form of overriding the default?
Per documentation:
The default setting is 0. Once set, the implicit wait is set for the life of the WebDriver object instance.
So, I ask again... Why, oh why, oh why why, oh why why why?
After I set implicitlyWait to say, 10 seconds, when I want to check for elements not present on the screen, I can't use WebDriver.findElements, because it will wait 10 seconds to throw an Exception before it does. If I do this for 6 elements, there goes a minute.
On another situation, I can't use even a EXPLICIT wait in the form of:
(new WebDriverWait(myDriver, 2)).until(new ExpectedCondition<Boolean>() {
//@Override
public Boolean apply(WebDriver d) {
try{
return d.findElement(by).isEnabled();
}catch(NoSuchElementException e){
return false;
}catch(StaleElementReferenceException ex){
return false;
}
})
});
...
because the driver I am passing by reference has already set the implicitlyWait(10),in the past, so even if I am passing 2 as timeout for this WebDriverWait, it will wait 10 seconds for the element when it reaches the return statement ( return d.findElement(by).isEnabled(); )
Now,
It should be plain and simple, in my project, to be able to have a DEFAULT timeout value for findElement so that scripts are reliable across the entire suite against elements that just didn't show up yet.
DEFAULT means, a value that you go back to, when you don't inform it explicitly!
So when I do inform a value EXPLICITLY, I DON'T WANT TO USE the default. See, that is what "default" means.
If I could do this, I'd have scripts that are both "reliable", and "fast". What a good thing hu? :)
So, why? :)
And, is there a way to bypass it that I am unaware?
--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to selenium-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/KOgT2nQO52MJ.
For more options, visit https://groups.google.com/groups/opt_out.
Interesting, that implies implicitly wait is no longer set for the life of the object but can now be tweaked on the fly.
I'll have to investigate at some point :)
From: seleniu...@googlegroups.com [mailto:seleniu...@googlegroups.com] On Behalf Of Chon Chung
Sent: 02 October 2012 00:51
To: seleniu...@googlegroups.com
Subject: Re: [selenium-users] Re: Why can't I Bypass WebDriver implicitlyWait once implicitlyWait is set?
Hi Mark:
Thank you for your comment. I believe it is important to test WaitTool, to find out it really works or not.
So, I just add: testWaitTool_class() method in AJAX_wait class ( https://github.com/ChonC/wtbox/tree/master/src/test/wait_example)
testWaitTool_class() method checks the following:
This test verify 3 things:
1. Test if the WaitTool method only wait for the given wait time.
and implicitlyWait setting does not effect on WaitTool's wait time.
2. Test performance: how long does it takes calling driver-implicitlyWait 100 times.
3. Verify reset implicitlyWait() do actually work:
And here are the test result of testWaitTool_class() method
test WaitTool_class-----------------------------------------
Test WaitTool.waitForElement: 3 seconds wait time =========
time before WaitTool.waitForElement: Oct 01,2012 14:11:05
time after WaitTool.waitForElement: Oct 01,2012 14:11:09
Test performance: calling driver-implicitlyWait 100 times=========
time before calling: Oct 01,2012 14:11:09
time after calling: Oct 01,2012 14:11:10
Test resetImplicitWait (given wait time = 2 seconds) =========
time before: Oct 01,2012 14:11:10
time after: Oct 01,2012 14:11:12
test WaitTool_class-----------------------------------------
Seems Tarun's nullifyImplicitWait() works beautifully. Could you verify my testing result? You can download the latest code and check it.
Also, thank you for pointing out isTextPresent bug. I updated the code based on your suggestions.
It is hard to test my own code. :-) Thank you.
Sincerely,
Chon
To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/djYeGfqftpEJ.