-
-
Notifications
You must be signed in to change notification settings - Fork 6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
179 additions
and
1,516 deletions.
There are no files selected for viewing
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
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
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
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
43 changes: 19 additions & 24 deletions
43
sample-code/examples/java/junit/src/test/java/com/saucelabs/appium/AndroidWebViewTest.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,54 @@ | ||
package com.saucelabs.appium; | ||
|
||
import io.appium.java_client.AppiumDriver; | ||
import org.junit.After; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.openqa.selenium.*; | ||
import org.openqa.selenium.interactions.HasTouchScreen; | ||
import org.openqa.selenium.interactions.TouchScreen; | ||
import org.openqa.selenium.By; | ||
import org.openqa.selenium.WebElement; | ||
import org.openqa.selenium.remote.CapabilityType; | ||
import org.openqa.selenium.remote.DesiredCapabilities; | ||
import org.openqa.selenium.remote.RemoteTouchScreen; | ||
import org.openqa.selenium.remote.RemoteWebDriver; | ||
|
||
import java.io.File; | ||
import java.net.URL; | ||
import java.util.Set; | ||
|
||
public class AndroidWebViewTest { | ||
private WebDriver driver; | ||
private AppiumDriver driver; | ||
|
||
@Before | ||
public void setUp() throws Exception { | ||
// set up appium | ||
File classpathRoot = new File(System.getProperty("user.dir")); | ||
File app = new File(classpathRoot, "../../../apps/selendroid-test-app.apk"); | ||
DesiredCapabilities capabilities = new DesiredCapabilities(); | ||
capabilities.setCapability("device","selendroid"); | ||
capabilities.setCapability("automationName","selendroid"); | ||
capabilities.setCapability(CapabilityType.PLATFORM, "android"); | ||
capabilities.setCapability("app", app.getAbsolutePath()); | ||
capabilities.setCapability("app-package", "io.selendroid.testapp"); | ||
capabilities.setCapability("app-activity", ".HomeScreenActivity"); | ||
driver = new SwipeableWebDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities); | ||
driver = new AppiumDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities); | ||
} | ||
@After | ||
public void tearDown() throws Exception { | ||
driver.quit(); | ||
} | ||
|
||
@Test | ||
public void webView(){ | ||
public void webView() throws InterruptedException { | ||
WebElement button = driver.findElement(By.id("buttonStartWebview")); | ||
button.click(); | ||
driver.switchTo().window("WEBVIEW"); | ||
Thread.sleep(6000); | ||
Set<String> contextNames = driver.getContextHandles(); | ||
for (String contextName : contextNames) { | ||
System.out.println(contextName); | ||
if (contextName.contains("WEBVIEW")){ | ||
driver.context(contextName); | ||
} | ||
} | ||
WebElement inputField = driver.findElement(By.id("name_input")); | ||
inputField.sendKeys("Some name"); | ||
inputField.submit(); | ||
} | ||
|
||
|
||
public class SwipeableWebDriver extends RemoteWebDriver implements HasTouchScreen { | ||
private RemoteTouchScreen touch; | ||
|
||
public SwipeableWebDriver(URL remoteAddress, Capabilities desiredCapabilities) { | ||
super(remoteAddress, desiredCapabilities); | ||
touch = new RemoteTouchScreen(getExecuteMethod()); | ||
} | ||
|
||
public TouchScreen getTouch() { | ||
return touch; | ||
} | ||
} | ||
|
||
} |
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
Oops, something went wrong.