Created
June 6, 2012 17:19
-
-
Save jsteckel/2883391 to your computer and use it in GitHub Desktop.
Script to reproduce UnreachableBrowserException with FirefoxDriver
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.junit.Before; | |
import org.junit.After; | |
import org.junit.Test; | |
import org.openqa.selenium.WebDriver; | |
import org.openqa.selenium.WebElement; | |
import org.openqa.selenium.By; | |
import org.openqa.selenium.firefox.FirefoxDriver; | |
import org.openqa.selenium.support.ui.WebDriverWait; | |
import org.openqa.selenium.support.ui.ExpectedCondition; | |
public class IframeTest | |
{ | |
private WebDriver driver; | |
@Before | |
public void setUp() throws Exception | |
{ | |
driver = new FirefoxDriver(); | |
} | |
@Test | |
public void test() throws Exception | |
{ | |
driver.get( "http://www.baur.de" ); | |
isElementPresent( By.xpath( "//iframe[@title='Newsletter']" ), 20 ); | |
driver.switchTo().frame( driver.findElement( By.xpath( "//iframe[@title='Newsletter']" ))); | |
isElementPresent( By.cssSelector("input[type=\"submit\"]"), 10 ); | |
} | |
@After | |
public void tearDown() throws Exception | |
{ | |
driver.quit(); | |
} | |
private WebElement isElementPresent(final By by, int timeout) | |
{ | |
return ( new WebDriverWait( driver, timeout )) | |
.until( new ExpectedCondition<WebElement>() { | |
@Override | |
public WebElement apply( WebDriver d ) { | |
return d.findElement( by ); | |
}}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment