Hi,
I have created few wrapper methods using Webdrive wait class,
following code for element and waitfortitle of page.
public boolean isDisplayed() {
return wait.until(new ExpectedCondition()
{
public Boolean apply(WebDriver driver) {
if
(browser.findElements(locatorHandler.autoLocator(locator)).size() > 0)
{
return
driver.findElement(locatorHandler.autoLocator(locator)).isDisplayed();
}
else
return false;
}
});
public boolean waitForTitle(final String str)
{
return wait.until(new ExpectedCondition() {
public Boolean apply(WebDriver driver) {
driver.getTitle();
if(driver.getTitle().equals(str))
{
return true;
}
return false;
}
});
}
This methods works fine in my test code. if waitfortitle method fails
when the page has incorrect title or page is slow than expected, the
test code throws an Timed Out exception
org.openqa.selenium.TimeoutException: Timed out after 30 seconds
Build info: version: '2.16.1', revision: '15405', time: '2012-01-05
12:23:11'
System info: os.name: 'Windows XP', os.arch: 'x86', os.version: '5.1',
java.version: '1.6.0_21'
Driver info: driver.version: unknown
at
org.openqa.selenium.support.ui.FluentWait.timeoutException(FluentWait.java:
252)
at org.openqa.selenium.support.ui.FluentWait.until(FluentWait.java:
221)
at common.WebControl.waitForTitle(WebControl.java:137)
at pages.YahooPage.waitForTitle(YahooPage.java:35)
at copa11.TestYahoo.testSignUp(TestYahoo.java:34)
... Removed 22 stack frames
This exception doesn't give me the exact root cause of the failure
whether the page is loaded and had incorrect title or page is not
loaded in expected time. Could some one help me to customize the
method or override the Timeout Exception with proper error
Some thing would help
i) If the page is loaded with incorrect title... then the expected
title is ******** and actual is ********* \
With the timed out exception, isDisplayed gets failed.
Regards,
Sai