Reputation: 219
I'm very new to Selenium Webdriver. I'm trying to automate an webpage and i'm facing two issues. I couldn't able to click the Search button in the frame. Below is my code.
WebDriverWait wait = new WebDriverWait(driver,120,1000);
wait.until(ExpectedConditions.frameToBeAvailableAndSwitchToIt("frameview"));
wait.until(ExpectedConditions.frameToBeAvailableAndSwitchToIt("epilowerframe"));
wait.until(ExpectedConditions.frameToBeAvailableAndSwitchToIt("productSearchIframe"));
driver.switchTo().frame("frameview")
.switchTo().frame("epilowerframe")
.switchTo().frame("productSearchIframe");
driver.findElement(By.id("styleSearchForm:goBtn")).click();
the StylesearchForm:goBtn is inside the productsearchIframe .
I'm always getting the error:
Timed out after 120 seconds waiting for frame to be available: epilowerframe Build info: version: '2.31.0', revision: '1bd294d', time: '2013-02-27 20:53:56' System info: os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.6.0_33' Driver info: driver.version: unknown at org.openqa.selenium.support.ui.FluentWait.timeoutException(FluentWait.java:259) at org.openqa.selenium.support.ui.FluentWait.until(FluentWait.java:228) at Nike_Demo.main(Nike_Demo.java:59)
Your help is highly appreciated.
Upvotes: 2
Views: 2875
Reputation: 15413
The frameToBeAvailableAndSwitchToIt is already switching the driver to the frame. You don't need to do:
driver.switchTo().frame("frameview")
driver.switchTo().frame("epilowerframe")
driver.switchTo().frame("productSearchIframe");
Just use the code:
WebDriverWait wait = new WebDriverWait(driver,120,1000);
wait.until(ExpectedConditions.frameToBeAvailableAndSwitchToIt("frameview"));
wait.until(ExpectedConditions.frameToBeAvailableAndSwitchToIt("epilowerframe"));
wait.until(ExpectedConditions.frameToBeAvailableAndSwitchToIt("productSearchIframe"));
driver.findElement(By.id("styleSearchForm:goBtn")).click();
Upvotes: 2
Reputation: 29669
It is not oftend the problem, but sometimes, depending on the app, you could be switching frames too quickly. You should put a 1-2 second pause after each time you call .switchTo() to get to a new frame. That will give the browser driver time to load the new DOM before you do another switchTo(). Also, it sorta appears that you are switching to each frame twice; not sure if you noticed that.
Upvotes: 1