|
1 | | -package com.saucelabs.appium; |
2 | | - |
3 | | -import io.appium.java_client.android.AndroidDriver; |
4 | | -import io.appium.java_client.pagefactory.AppiumFieldDecorator; |
5 | | -import io.appium.java_client.remote.MobileCapabilityType; |
6 | | - |
7 | | -import java.io.File; |
8 | | -import java.net.URL; |
9 | | -import java.util.concurrent.TimeUnit; |
10 | | - |
11 | | -import org.junit.After; |
12 | | -import org.junit.Assert; |
13 | | -import org.junit.Before; |
14 | | -import org.junit.Test; |
15 | | -import org.openqa.selenium.WebDriver; |
16 | | -import org.openqa.selenium.remote.DesiredCapabilities; |
17 | | -import org.openqa.selenium.support.PageFactory; |
18 | | - |
19 | | -import com.saucelabs.appium.page_object.android.ApiDemosListViewScreenByAllPossible; |
20 | | -import com.saucelabs.appium.page_object.android.ApiDemosListViewScreenChaided; |
21 | | -import com.saucelabs.appium.page_object.android.ApiDemosListViewScreenSimple; |
22 | | -import com.saucelabs.appium.page_object.ios.UICatalogScreenSimple; |
23 | | - |
24 | | -/** |
25 | | - * Please read about Page Object design pattern here: |
26 | | - * https://code.google.com/p/selenium/wiki/PageObjects |
27 | | - * |
28 | | - * Please look at: |
29 | | - * {@link ApiDemosListViewScreenSimple} |
30 | | - * {@link ApiDemosListViewScreenChaided} |
31 | | - * {@link ApiDemosListViewScreenByAllPossible} |
32 | | - * {@link UICatalogScreenSimple} |
33 | | - * |
34 | | - */ |
35 | | -public class AndroidPageObjectTest_Chained { |
36 | | - |
37 | | - private WebDriver driver; |
38 | | - private ApiDemosListViewScreenChaided apiDemosPageObject; |
39 | | - |
40 | | - @Before |
41 | | - public void setUp() throws Exception { |
42 | | - File classpathRoot = new File(System.getProperty("user.dir")); |
43 | | - File appDir = new File(classpathRoot, "../../../apps/ApiDemos/bin"); |
44 | | - File app = new File(appDir, "ApiDemos-debug.apk"); |
45 | | - DesiredCapabilities capabilities = new DesiredCapabilities(); |
46 | | - capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "Android Emulator"); |
47 | | - capabilities.setCapability(MobileCapabilityType.APP, app.getAbsolutePath()); |
48 | | - driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities); |
49 | | - |
50 | | - apiDemosPageObject = new ApiDemosListViewScreenChaided(); |
51 | | - PageFactory.initElements(new AppiumFieldDecorator(driver, 5, TimeUnit.SECONDS), |
52 | | - apiDemosPageObject); |
53 | | - } |
54 | | - |
55 | | - @After |
56 | | - public void tearDown() throws Exception { |
57 | | - driver.quit(); |
58 | | - } |
59 | | - |
60 | | - @Test |
61 | | - public void androidChainSearchElementsTest(){ |
62 | | - Assert.assertNotEquals(0, apiDemosPageObject.chainElementViews.size()); |
63 | | - } |
64 | | - |
65 | | - @Test |
66 | | - public void androidChainSearchElementTest(){ |
67 | | - Assert.assertNotEquals(null, apiDemosPageObject.chainElementView.getAttribute("text")); |
68 | | - } |
69 | | - |
70 | | - @Test |
71 | | - public void androidOrIOSFindByElementsTest_ChainSearches(){ |
72 | | - Assert.assertNotEquals(0, apiDemosPageObject.chainAndroidOrIOSUIAutomatorViews.size()); |
73 | | - } |
74 | | - |
75 | | - @Test |
76 | | - public void androidOrIOSFindByElementTest_ChainSearches(){ |
77 | | - Assert.assertNotEquals(null, apiDemosPageObject.chainAndroidOrIOSUIAutomatorView.getAttribute("text")); |
78 | | - } |
79 | | - |
80 | | - @Test |
81 | | - public void isAndroidElementTest(){ |
82 | | - Assert.assertNotEquals(null, apiDemosPageObject.androidElementView.getAttribute("text")); |
83 | | - } |
84 | | - |
85 | | - @Test |
86 | | - public void areAndroidElementsTest(){ |
87 | | - Assert.assertNotEquals(0, apiDemosPageObject.androidElementViews.size()); |
88 | | - } |
89 | | -} |
| 1 | +package com.saucelabs.appium; |
| 2 | + |
| 3 | +import io.appium.java_client.android.AndroidDriver; |
| 4 | +import io.appium.java_client.pagefactory.AppiumFieldDecorator; |
| 5 | +import io.appium.java_client.remote.MobileCapabilityType; |
| 6 | + |
| 7 | +import java.io.File; |
| 8 | +import java.net.URL; |
| 9 | +import java.util.concurrent.TimeUnit; |
| 10 | + |
| 11 | +import org.junit.After; |
| 12 | +import org.junit.Assert; |
| 13 | +import org.junit.Before; |
| 14 | +import org.junit.Test; |
| 15 | +import org.openqa.selenium.WebDriver; |
| 16 | +import org.openqa.selenium.remote.DesiredCapabilities; |
| 17 | +import org.openqa.selenium.support.PageFactory; |
| 18 | + |
| 19 | +import com.saucelabs.appium.page_object.android.ApiDemosListViewScreenByAllPossible; |
| 20 | +import com.saucelabs.appium.page_object.android.ApiDemosListViewScreenChaided; |
| 21 | +import com.saucelabs.appium.page_object.android.ApiDemosListViewScreenSimple; |
| 22 | +import com.saucelabs.appium.page_object.ios.TestAppScreenSimple; |
| 23 | + |
| 24 | +/** |
| 25 | + * Please read about Page Object design pattern here: |
| 26 | + * https://code.google.com/p/selenium/wiki/PageObjects |
| 27 | + * |
| 28 | + * Please look at: |
| 29 | + * {@link ApiDemosListViewScreenSimple} |
| 30 | + * {@link ApiDemosListViewScreenChaided} |
| 31 | + * {@link ApiDemosListViewScreenByAllPossible} |
| 32 | + * {@link TestAppScreenSimple} |
| 33 | + * |
| 34 | + */ |
| 35 | +public class AndroidPageObjectTest_Chained { |
| 36 | + |
| 37 | + private WebDriver driver; |
| 38 | + private ApiDemosListViewScreenChaided apiDemosPageObject; |
| 39 | + |
| 40 | + @Before |
| 41 | + public void setUp() throws Exception { |
| 42 | + File classpathRoot = new File(System.getProperty("user.dir")); |
| 43 | + File appDir = new File(classpathRoot, "../../../apps/ApiDemos/bin"); |
| 44 | + File app = new File(appDir, "ApiDemos-debug.apk"); |
| 45 | + DesiredCapabilities capabilities = new DesiredCapabilities(); |
| 46 | + capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "Android Emulator"); |
| 47 | + capabilities.setCapability(MobileCapabilityType.APP, app.getAbsolutePath()); |
| 48 | + driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities); |
| 49 | + |
| 50 | + apiDemosPageObject = new ApiDemosListViewScreenChaided(); |
| 51 | + PageFactory.initElements(new AppiumFieldDecorator(driver, 5, TimeUnit.SECONDS), |
| 52 | + apiDemosPageObject); |
| 53 | + } |
| 54 | + |
| 55 | + @After |
| 56 | + public void tearDown() throws Exception { |
| 57 | + driver.quit(); |
| 58 | + } |
| 59 | + |
| 60 | + /** |
| 61 | + * Page Object best practice is to describe interactions with target |
| 62 | + * elements by methods. This methods describe business logic of the page/screen. |
| 63 | + * Here test interacts with lazy instantiated elements directly. |
| 64 | + * It was done so just for obviousness |
| 65 | + */ |
| 66 | + |
| 67 | + @Test |
| 68 | + public void androidChainSearchElementsTest(){ |
| 69 | + Assert.assertNotEquals(0, apiDemosPageObject.chainElementViews.size()); |
| 70 | + } |
| 71 | + |
| 72 | + @Test |
| 73 | + public void androidChainSearchElementTest(){ |
| 74 | + Assert.assertNotEquals(null, apiDemosPageObject.chainElementView.getAttribute("text")); |
| 75 | + } |
| 76 | + |
| 77 | + @Test |
| 78 | + public void androidOrIOSFindByElementsTest_ChainSearches(){ |
| 79 | + Assert.assertNotEquals(0, apiDemosPageObject.chainAndroidOrIOSUIAutomatorViews.size()); |
| 80 | + } |
| 81 | + |
| 82 | + @Test |
| 83 | + public void androidOrIOSFindByElementTest_ChainSearches(){ |
| 84 | + Assert.assertNotEquals(null, apiDemosPageObject.chainAndroidOrIOSUIAutomatorView.getAttribute("text")); |
| 85 | + } |
| 86 | + |
| 87 | + @Test |
| 88 | + public void isAndroidElementTest(){ |
| 89 | + Assert.assertNotEquals(null, apiDemosPageObject.androidElementView.getAttribute("text")); |
| 90 | + } |
| 91 | + |
| 92 | + @Test |
| 93 | + public void areAndroidElementsTest(){ |
| 94 | + Assert.assertNotEquals(0, apiDemosPageObject.androidElementViews.size()); |
| 95 | + } |
| 96 | +} |
0 commit comments