Skip to content

Instantly share code, notes, and snippets.

@jsteckel
Created June 6, 2012 17:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jsteckel/2883391 to your computer and use it in GitHub Desktop.
Save jsteckel/2883391 to your computer and use it in GitHub Desktop.
Script to reproduce UnreachableBrowserException with FirefoxDriver
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