Skip to main content

Posts

Showing posts with the label selenium waitfor

Can't wait to wait -- Webdriver Waits!!

Wait!!! These four letters can drive you crazy if you are having a bad day using Webdriver... Thus if you are reading this article you are already in the middle of one bad bad day...thus I'll cut the crap and go directly into the ways you can add waits using webdriver: Type 1 - Using driver.manager.timeouts() Implicit Waits - When you set this wait, webdriver would wait for this amount of time before failing any command. Syntax -  driver . manage (). timeouts (). implicitlyWait ( 10 , TimeUnit . SECONDS ); Example - Webdriver is looking to find an element using an xpath and its not able to find it, webdriver waits for 10 seconds before trying to find the element and thus failing if it still can't find the element after 10 seconds Page Load Timeouts - When you set this wait, webdriver would wait for this amount of time to declare page load timeouts Syntax -  driver . manage (). timeouts (). pageLoadTimeout ( 100 , SECONDS ); Example - Let's say we ar...

AJAX Testing–Some Useful Links

Testing dynamic elements is always a challenge. I found some interesting/useful links which might prove useful to you too: http://agilesoftwaretesting.com/selenium-wait-for-ajax-the-right-way/ http://stackoverflow.com/questions/6850994/wait-for-javascript-file-to-load-in-selenium-2 http://saucelabs.com/blog/index.php/2011/04/how-to-lose-races-and-win-at-selenium/   Happy Testing!!!!

Selenium: How to verify a hidden div tag exists

Most of the times we do have hidden div tags which need to be verified.  In most of the test designs, the first step towards testing a particular application is to verify that all the elements exist on the application under test.  Example:  Lets say we have a login page which has two text-fields. One for username the other for password. On the page, we also have a hidden div tag which is used by the developer to pass on the login failure message.  Usually its hidden but is set to visible when there is a login failure.  In usual test designs we would want to do something like this at the first step.  1. test all the components exist:  verifyTrue(selenium.isElementExists(LoginPage.username));  verifyTrue(selenium.isElementExists(LoginPage.password)); 2. Then give an incorrect username and password  selenium.type("LoginPage.username","SomeUserName"); selenium.type("LoginPage.password","SomePassword"); 3. Now verify that the...