Created
July 2, 2014 08:06
-
-
Save hatena-iti/a0115f11fdaa966a6a74 to your computer and use it in GitHub Desktop.
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
package jp.co.iti.test; | |
import java.util.concurrent.TimeUnit; | |
import org.junit.Test; | |
import io.selendroid.SelendroidCapabilities; | |
import io.selendroid.SelendroidConfiguration; | |
import io.selendroid.SelendroidDriver; | |
import io.selendroid.SelendroidLauncher; | |
import org.junit.After; | |
import org.junit.Before; | |
import org.openqa.selenium.By; | |
import org.openqa.selenium.WebDriver; | |
import org.openqa.selenium.WebElement; | |
import org.openqa.selenium.remote.DesiredCapabilities; | |
public class AndroidDriverTest2 { | |
private SelendroidLauncher selendroidServer = null; | |
private WebDriver driver = null; | |
@Test | |
public void shouldSearchWithEbay() { | |
// And now use this to visit ebay | |
driver.get("http://m.ebay.de"); | |
// Find the text input element by its id | |
WebElement element = driver.findElement(By.id("kw")); | |
// Enter something to search for | |
element.sendKeys("Nexus 5"); | |
// Now submit the form. WebDriver will find the form for us from the element | |
element.submit(); | |
driver.findElement(By.id("refinetxtId")); | |
// Check the title of the page | |
System.out.println("Page title is: " + driver.getTitle()); | |
driver.quit(); | |
} | |
@Before | |
public void startSelendroidServer() throws Exception { | |
if (selendroidServer != null) { | |
selendroidServer.stopSelendroid(); | |
} | |
SelendroidConfiguration config = new SelendroidConfiguration(); | |
selendroidServer = new SelendroidLauncher(config); | |
selendroidServer.launchSelendroid(); | |
DesiredCapabilities caps = SelendroidCapabilities.android(); | |
driver = new SelendroidDriver(caps); | |
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS); | |
} | |
@After | |
public void stopSelendroidServer() { | |
if (driver != null) { | |
driver.quit(); | |
} | |
if (selendroidServer != null) { | |
selendroidServer.stopSelendroid(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment