Web application automation is depends on so many factors. Browser, network speed ...etc. We should write unquie code for running in all environments. For achieveing that we need to wait for WebElements before performing any operation on that.
Here we will see some built-in waits in WebDriver.
implicitlyWait
1 | WebDriver driver = new FirefoxDriver(); |
2 | driver.manage().timeouts().implicitlyWait(30 , TimeUnit.SECONDS); |
3 | driver.get( "http://www.google.co.in" ); |
4 | WebElement myElement = driver.findElement(By.id( "someId" )); |
pageLoadTimeout
1 | driver.manage().timeouts().pageLoadTimeout( 30 , SECONDS); |
setScriptTimeout
1 | driver.manage().timeouts().setScriptTimeout(30 ,SECONDS); |
Sets the amount of time to wait for an asynchronous script to finish execution before throwing an error.
Regards,
SantoshSarma
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.