forked from JasmineChiu/sample-code
-
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.
- Loading branch information
1 parent
69c2e5c
commit 15009d4
Showing
8 changed files
with
287 additions
and
13 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
151 changes: 151 additions & 0 deletions
151
...rc/test/java/com/saucelabs/appium/AndroidPageObjectTest_PageObjectLikeComplexElement.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 |
---|---|---|
@@ -0,0 +1,151 @@ | ||
package com.saucelabs.appium; | ||
|
||
import io.appium.java_client.android.AndroidDriver; | ||
import io.appium.java_client.pagefactory.AppiumFieldDecorator; | ||
import io.appium.java_client.remote.MobileCapabilityType; | ||
|
||
import java.io.File; | ||
import java.net.URL; | ||
import java.util.NoSuchElementException; | ||
import java.util.concurrent.TimeUnit; | ||
|
||
import org.junit.After; | ||
import org.junit.Assert; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.openqa.selenium.By; | ||
import org.openqa.selenium.WebDriver; | ||
import org.openqa.selenium.remote.DesiredCapabilities; | ||
import org.openqa.selenium.support.PageFactory; | ||
|
||
import com.saucelabs.appium.page_object.android.ApiDemosListViewScreenByAllPossible; | ||
import com.saucelabs.appium.page_object.android.ApiDemosListViewScreenChaided; | ||
import com.saucelabs.appium.page_object.android.ApiDemosListViewScreenSimple; | ||
import com.saucelabs.appium.page_object.ios.UICatalogScreenSimple; | ||
|
||
/** | ||
* Please read about Page Object design pattern here: | ||
* https://code.google.com/p/selenium/wiki/PageObjects | ||
* | ||
* Please look at: | ||
* {@link ApiDemosListViewScreenSimple} | ||
* {@link ApiDemosListViewScreenChaided} | ||
* {@link ApiDemosListViewScreenByAllPossible} | ||
* {@link UICatalogScreenSimple} | ||
* | ||
*/ | ||
public class AndroidPageObjectTest_PageObjectLikeComplexElement { | ||
|
||
private WebDriver driver; | ||
private ApiDemosListViewScreenSimple apiDemosPageObject; | ||
|
||
@Before | ||
public void setUp() throws Exception { | ||
File classpathRoot = new File(System.getProperty("user.dir")); | ||
File appDir = new File(classpathRoot, "../../../apps/ApiDemos/bin"); | ||
File app = new File(appDir, "ApiDemos-debug.apk"); | ||
DesiredCapabilities capabilities = new DesiredCapabilities(); | ||
capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "Android Emulator"); | ||
capabilities.setCapability(MobileCapabilityType.APP, app.getAbsolutePath()); | ||
driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities); | ||
|
||
apiDemosPageObject = new ApiDemosListViewScreenSimple(); | ||
PageFactory.initElements(new AppiumFieldDecorator(driver. | ||
findElement(By.id("android:id/list")) /*(!!!)*/ | ||
, 5, TimeUnit.SECONDS), | ||
apiDemosPageObject); | ||
} | ||
|
||
@After | ||
public void tearDown() throws Exception { | ||
driver.quit(); | ||
} | ||
|
||
@Test | ||
public void findByElementsTest() { | ||
Assert.assertNotEquals(0, apiDemosPageObject.textVieWs.size()); | ||
} | ||
|
||
@Test | ||
public void findByElementTest() { | ||
Assert.assertNotEquals(null, apiDemosPageObject.textView.getAttribute("text")); | ||
} | ||
|
||
|
||
@Test | ||
public void androidFindByElementsTest(){ | ||
Assert.assertNotEquals(0, apiDemosPageObject.androidTextViews.size()); | ||
} | ||
|
||
@Test | ||
public void androidFindByElementTest(){ | ||
Assert.assertNotEquals(null, apiDemosPageObject.androidTextView.getAttribute("text")); | ||
} | ||
|
||
@Test | ||
public void checkThatElementsWereNotFoundByIOSUIAutomator(){ | ||
Assert.assertEquals(0, apiDemosPageObject.iosTextViews.size()); | ||
} | ||
|
||
@Test | ||
public void checkThatElementWasNotFoundByIOSUIAutomator(){ | ||
NoSuchElementException nsee = null; | ||
try{ | ||
apiDemosPageObject.iosTextView.getAttribute("text"); | ||
} | ||
catch (Exception e){ | ||
nsee = (NoSuchElementException) e; | ||
} | ||
Assert.assertNotNull(nsee); | ||
} | ||
|
||
@Test | ||
public void androidOrIOSFindByElementsTest(){ | ||
Assert.assertNotEquals(0, apiDemosPageObject.androidOriOsTextViews.size()); | ||
} | ||
|
||
@Test | ||
public void androidOrIOSFindByElementTest(){ | ||
Assert.assertNotEquals(null, apiDemosPageObject.androidOriOsTextView.getAttribute("text")); | ||
} | ||
|
||
@Test | ||
public void androidFindByUIAutomatorElementsTest(){ | ||
Assert.assertNotEquals(0, apiDemosPageObject.androidUIAutomatorViews.size()); | ||
} | ||
|
||
@Test | ||
public void androidFindByUIAutomatorElementTest(){ | ||
Assert.assertNotEquals(null, apiDemosPageObject.androidUIAutomatorView.getAttribute("text")); | ||
} | ||
|
||
@Test | ||
public void areMobileElementsTest(){ | ||
Assert.assertNotEquals(0, apiDemosPageObject.mobileElementViews.size()); | ||
} | ||
|
||
@Test | ||
public void isMobileElementTest(){ | ||
Assert.assertNotEquals(null, apiDemosPageObject.mobileElementView.getAttribute("text")); | ||
} | ||
|
||
@Test | ||
public void areMobileElements_FindByTest(){ | ||
Assert.assertNotEquals(0, apiDemosPageObject.mobiletextVieWs.size()); | ||
} | ||
|
||
@Test | ||
public void isMobileElement_FindByTest(){ | ||
Assert.assertNotEquals(null, apiDemosPageObject.mobiletextVieW.getAttribute("text")); | ||
} | ||
|
||
@Test | ||
public void areRemoteElementsTest(){ | ||
Assert.assertNotEquals(0, apiDemosPageObject.remoteElementViews.size()); | ||
} | ||
|
||
@Test | ||
public void isRemoteElementTest(){ | ||
Assert.assertNotEquals(null, apiDemosPageObject.remotetextVieW.getAttribute("text")); | ||
} | ||
} |
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
23 changes: 21 additions & 2 deletions
23
...src/test/java/com/saucelabs/appium/page_object/android/ApiDemosListViewScreenChaided.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
Oops, something went wrong.