forked from appium/appium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bring Sample Code into master (appium#10880)
* Sample code stub (appium#9887) * WD tests * WD sample code (appium#9918) * WebdriverIO sample code (appium#10166) * Ruby sample code (appium#10331) * PHP Sample Code (appium#10209) * Basic Android java test * Java sample code (appium#10427) * Sample code (appium#10834) * Sample code stub (appium#9887) * WD tests * WD sample code (appium#9918) * WebdriverIO sample code (appium#10166) * Ruby sample code (appium#10331) * PHP Sample Code (appium#10209) * Basic Android java test * Java sample code (appium#10427) * fixed WDIO test * Update .npmignore
- Loading branch information
Showing
68 changed files
with
2,098 additions
and
27 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,3 +18,6 @@ _vimrc_local.vim | |
*.trace | ||
*.sublime- | ||
*.prefs | ||
./.npmignore | ||
coverage | ||
sample-code/ |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Sample Code | ||
|
||
Sample Appium code written in multiple client languages | ||
|
||
## Running sample code | ||
|
||
* Follow the [Appium setup guide](https://github.com/appium/appium/blob/master/docs/en/about-appium/getting-started.md) to install Appium locally. | ||
* Choose the client library that you wish to run and then follow the guide in `sample-code/<client-language>/README.md` (e.g.: `sample-code/java/README.md`) | ||
|
||
## Environment variables | ||
|
||
* `DEV`: If set to true, runs apps that are downloaded from GitHub, otherwise runs apps that are in local directory | ||
* `IOS_DEVICE_NAME`: Sets the `deviceName` capability for iOS. Otherwise uses some default | ||
* `IOS_PLATFORM_VERSION`: Sets the `platformVersion` capability for iOS. Otherwise uses some default | ||
* `ANDROID_DEVICE_NAME`: Sets the `deviceName` capability for Android. Otherwise uses some default | ||
* `ANDROID_PLATFORM_VERSION`: Sets the `platformVersion` capability for Android. Otherwise uses some default | ||
* `SAUCE_LABS`: If set to true, runs tests on Sauce Labs. Requires being setup on SauceLabs to run these tests. |
Binary file not shown.
Binary file not shown.
Empty file.
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Java Sample Code | ||
|
||
## Setup | ||
|
||
* Uses TestNG and was built and tested on IntelliJ | ||
|
||
## Running Tests | ||
|
||
* Can be run from IntelliJ the way tests normally are run |
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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<module type="JAVA_MODULE" version="4"> | ||
<component name="NewModuleRootManager" inherit-compiler-output="true"> | ||
<exclude-output /> | ||
<content url="file://$MODULE_DIR$"> | ||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" /> | ||
</content> | ||
<orderEntry type="inheritedJdk" /> | ||
<orderEntry type="sourceFolder" forTests="false" /> | ||
<orderEntry type="module-library" scope="TEST"> | ||
<library name="testng"> | ||
<CLASSES> | ||
<root url="jar://$APPLICATION_HOME_DIR$/plugins/testng/lib/testng.jar!/" /> | ||
<root url="jar://$APPLICATION_HOME_DIR$/plugins/testng/lib/jcommander.jar!/" /> | ||
</CLASSES> | ||
<JAVADOC /> | ||
<SOURCES /> | ||
</library> | ||
</orderEntry> | ||
<orderEntry type="module-library"> | ||
<library> | ||
<CLASSES> | ||
<root url="jar://$APPLICATION_HOME_DIR$/plugins/testng/lib/testng.jar!/" /> | ||
<root url="jar://$APPLICATION_HOME_DIR$/plugins/testng/lib/jcommander.jar!/" /> | ||
</CLASSES> | ||
<JAVADOC /> | ||
<SOURCES /> | ||
</library> | ||
</orderEntry> | ||
<orderEntry type="library" name="io.appium:java-client:5.0.4" level="project" /> | ||
</component> | ||
</module> |
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 |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import io.appium.java_client.android.Activity; | ||
import io.appium.java_client.android.AndroidDriver; | ||
import io.appium.java_client.android.AndroidElement; | ||
import org.openqa.selenium.By; | ||
import org.openqa.selenium.WebElement; | ||
import org.openqa.selenium.remote.DesiredCapabilities; | ||
import org.openqa.selenium.support.ui.ExpectedConditions; | ||
import org.openqa.selenium.support.ui.WebDriverWait; | ||
import org.testng.Assert; | ||
import org.testng.annotations.AfterClass; | ||
import org.testng.annotations.BeforeClass; | ||
import org.testng.annotations.Test; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
|
||
public class AndroidBasicInteractionsTest extends BaseTest { | ||
private AndroidDriver<WebElement> driver; | ||
private final String SEARCH_ACTIVITY = ".app.SearchInvoke"; | ||
private final String ALERT_DIALOG_ACTIVITY = ".app.AlertDialogSamples"; | ||
private final String PACKAGE = "io.appium.android.apis"; | ||
|
||
@BeforeClass | ||
public void setUp() throws IOException { | ||
File classpathRoot = new File(System.getProperty("user.dir")); | ||
File appDir = new File(classpathRoot, "../apps"); | ||
File app = new File(appDir.getCanonicalPath(), "ApiDemos-debug.apk"); | ||
DesiredCapabilities capabilities = new DesiredCapabilities(); | ||
capabilities.setCapability("deviceName", "Android Emulator"); | ||
capabilities.setCapability("app", app.getAbsolutePath()); | ||
driver = new AndroidDriver<WebElement>(getServiceUrl(), capabilities); | ||
} | ||
|
||
@AfterClass | ||
public void tearDown() { | ||
driver.quit(); | ||
} | ||
|
||
|
||
@Test() | ||
public void testSendKeys() { | ||
driver.startActivity(new Activity(PACKAGE, SEARCH_ACTIVITY)); | ||
AndroidElement searchBoxEl = (AndroidElement) driver.findElementById("txt_query_prefill"); | ||
searchBoxEl.sendKeys("Hello world!"); | ||
AndroidElement onSearchRequestedBtn = (AndroidElement) driver.findElementById("btn_start_search"); | ||
onSearchRequestedBtn.click(); | ||
AndroidElement searchText = (AndroidElement) new WebDriverWait(driver, 30) | ||
.until(ExpectedConditions.visibilityOfElementLocated(By.id("android:id/search_src_text"))); | ||
String searchTextValue = searchText.getText(); | ||
Assert.assertEquals(searchTextValue, "Hello world!"); | ||
} | ||
|
||
@Test | ||
public void testOpensAlert() { | ||
// Open the "Alert Dialog" activity of the android app | ||
driver.startActivity(new Activity(PACKAGE, ALERT_DIALOG_ACTIVITY)); | ||
|
||
// Click button that opens a dialog | ||
AndroidElement openDialogButton = (AndroidElement) driver.findElementById("io.appium.android.apis:id/two_buttons"); | ||
openDialogButton.click(); | ||
|
||
// Check that the dialog is there | ||
AndroidElement alertElement = (AndroidElement) driver.findElementById("android:id/alertTitle"); | ||
String alertText = alertElement.getText(); | ||
Assert.assertEquals(alertText, "Lorem ipsum dolor sit aie consectetur adipiscing\nPlloaso mako nuto siwuf cakso dodtos anr koop."); | ||
AndroidElement closeDialogButton = (AndroidElement) driver.findElementById("android:id/button1"); | ||
|
||
// Close the dialog | ||
closeDialogButton.click(); | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import io.appium.java_client.android.AndroidDriver; | ||
import org.openqa.selenium.WebElement; | ||
import org.openqa.selenium.remote.DesiredCapabilities; | ||
import org.testng.Assert; | ||
import org.testng.annotations.*; | ||
|
||
import java.io.File; | ||
|
||
public class AndroidCreateSessionTest extends BaseTest { | ||
private AndroidDriver<WebElement> driver; | ||
|
||
@BeforeClass | ||
public void setUp() throws Exception { | ||
File classpathRoot = new File(System.getProperty("user.dir")); | ||
File appDir = new File(classpathRoot, "../apps"); | ||
File app = new File(appDir.getCanonicalPath(), "ApiDemos-debug.apk"); | ||
DesiredCapabilities capabilities = new DesiredCapabilities(); | ||
capabilities.setCapability("deviceName", "Android Emulator"); | ||
capabilities.setCapability("app", app.getAbsolutePath()); | ||
capabilities.setCapability("appPackage", "io.appium.android.apis"); | ||
capabilities.setCapability("appActivity", ".ApiDemos"); | ||
driver = new AndroidDriver<WebElement>(getServiceUrl(), capabilities); | ||
} | ||
|
||
@AfterClass | ||
public void tearDown() { | ||
driver.quit(); | ||
} | ||
|
||
@Test() | ||
public void testCreateSession() { | ||
String activity = driver.currentActivity(); | ||
String pkg = driver.getCurrentPackage(); | ||
Assert.assertEquals(activity, ".ApiDemos"); | ||
Assert.assertEquals(pkg, "io.appium.android.apis"); | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import io.appium.java_client.android.AndroidDriver; | ||
import org.openqa.selenium.WebElement; | ||
import org.openqa.selenium.remote.DesiredCapabilities; | ||
import org.testng.Assert; | ||
import org.testng.annotations.*; | ||
|
||
import java.net.URI; | ||
import java.net.URISyntaxException; | ||
|
||
public class AndroidCreateWebSessionTest extends BaseTest { | ||
private AndroidDriver<WebElement> driver; | ||
|
||
@BeforeClass | ||
public void setUp() { | ||
DesiredCapabilities capabilities = new DesiredCapabilities(); | ||
capabilities.setCapability("deviceName", "Android Emulator"); | ||
capabilities.setCapability("browserName", "Chrome"); | ||
driver = new AndroidDriver<WebElement>(getServiceUrl(), capabilities); | ||
} | ||
|
||
@AfterClass | ||
public void tearDown() { | ||
driver.quit(); | ||
} | ||
|
||
@Test() | ||
public void testCreateWebSession() throws URISyntaxException { | ||
driver.get(new URI("http://www.google.com").toString()); | ||
String title = driver.getTitle(); | ||
Assert.assertEquals(title, "Google"); | ||
} | ||
} |
Oops, something went wrong.