Skip to content

Commit 621333d

Browse files
#30 Page objects
Next steps are: - tp implement sample of tests - to add comments.
1 parent 722b9dd commit 621333d

4 files changed

Lines changed: 251 additions & 0 deletions

File tree

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package com.saucelabs.appium.page_object.android;
2+
3+
import io.appium.java_client.MobileElement;
4+
5+
import java.util.List;
6+
import io.appium.java_client.android.AndroidElement;
7+
import io.appium.java_client.pagefactory.AndroidFindAll;
8+
import io.appium.java_client.pagefactory.AndroidFindBy;
9+
10+
public class ApiDemosListViewScreenByAllPossible {
11+
12+
@AndroidFindAll({
13+
@AndroidFindBy(uiAutomator = "new UiSelector().resourceId(\"android:id/Fakecontent\")"),
14+
@AndroidFindBy(id = "android:id/Faketext1"),
15+
@AndroidFindBy(uiAutomator = "new UiSelector().resourceId(\"android:id/list\")"), //by this locator element is found
16+
@AndroidFindBy(id = "android:id/FakeId")
17+
})
18+
public List<MobileElement> findAllElementViews;
19+
20+
@AndroidFindAll({
21+
@AndroidFindBy(uiAutomator = "new UiSelector().resourceId(\"android:id/Fakecontent\")"),
22+
@AndroidFindBy(id = "android:id/Faketext1"),
23+
@AndroidFindBy(uiAutomator = "new UiSelector().resourceId(\"android:id/list\")"), //by this locator element is found
24+
@AndroidFindBy(id = "android:id/FakeId")
25+
})
26+
public AndroidElement findAllElementView;
27+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
package com.saucelabs.appium.page_object.android;
2+
3+
import io.appium.java_client.android.AndroidElement;
4+
import java.util.List;
5+
import org.openqa.selenium.WebElement;
6+
import io.appium.java_client.pagefactory.AndroidFindBy;
7+
import io.appium.java_client.pagefactory.AndroidFindBys;
8+
import io.appium.java_client.pagefactory.iOSFindBy;
9+
import io.appium.java_client.pagefactory.iOSFindBys;
10+
11+
public class ApiDemosListViewScreenChaided {
12+
13+
14+
@AndroidFindBys({
15+
@AndroidFindBy(uiAutomator = "new UiSelector().resourceId(\"android:id/list\")"),
16+
@AndroidFindBy(className = "android.widget.TextView")
17+
})
18+
public List<WebElement> chainElementViews;
19+
20+
@AndroidFindBys({
21+
@AndroidFindBy(uiAutomator = "new UiSelector().resourceId(\"android:id/content\")"),
22+
@AndroidFindBy(uiAutomator = "new UiSelector().resourceId(\"android:id/list\")"),
23+
@AndroidFindBy(id = "android:id/text1")
24+
})
25+
@iOSFindBys({@iOSFindBy(uiAutomator = ".elements()[0]"),
26+
@iOSFindBy(xpath = "//someElement")})
27+
public List<WebElement> chainAndroidOrIOSUIAutomatorViews;
28+
29+
30+
@AndroidFindBys({
31+
@AndroidFindBy(uiAutomator = "new UiSelector().resourceId(\"android:id/list\")"),
32+
@AndroidFindBy(className = "android.widget.TextView")
33+
})
34+
public WebElement chainElementView;
35+
36+
37+
@AndroidFindBys({
38+
@AndroidFindBy(uiAutomator = "new UiSelector().resourceId(\"android:id/content\")"),
39+
@AndroidFindBy(uiAutomator = "new UiSelector().resourceId(\"android:id/list\")"),
40+
@AndroidFindBy(id = "android:id/text1")
41+
})
42+
@iOSFindBys({@iOSFindBy(uiAutomator = ".elements()[0]"),
43+
@iOSFindBy(xpath = "//someElement")})
44+
public WebElement chainAndroidOrIOSUIAutomatorView;
45+
46+
@AndroidFindBys({
47+
@AndroidFindBy(uiAutomator = "new UiSelector().resourceId(\"android:id/content\")"),
48+
@AndroidFindBy(uiAutomator = "new UiSelector().resourceId(\"android:id/list\")"),
49+
@AndroidFindBy(id = "android:id/text1")
50+
})
51+
public AndroidElement androidElementView;
52+
53+
@AndroidFindBys({
54+
@AndroidFindBy(uiAutomator = "new UiSelector().resourceId(\"android:id/content\")"),
55+
@AndroidFindBy(uiAutomator = "new UiSelector().resourceId(\"android:id/list\")"),
56+
@AndroidFindBy(id = "android:id/text1")
57+
})
58+
public List<AndroidElement> androidElementViews;
59+
}
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
package com.saucelabs.appium.page_object.android;
2+
3+
import io.appium.java_client.MobileElement;
4+
import io.appium.java_client.pagefactory.AndroidFindBy;
5+
import io.appium.java_client.pagefactory.iOSFindBy;
6+
7+
import java.util.List;
8+
9+
import org.openqa.selenium.WebElement;
10+
import org.openqa.selenium.remote.RemoteWebElement;
11+
import org.openqa.selenium.support.FindBy;
12+
13+
public class ApiDemosListViewScreenSimple {
14+
15+
@FindBy(className = "android.widget.TextView")
16+
public List<WebElement> textVieWs;
17+
18+
@AndroidFindBy(className = "android.widget.TextView")
19+
public List<WebElement> androidTextViews;
20+
21+
@iOSFindBy(uiAutomator = ".elements()[0]")
22+
public List<WebElement> iosTextViews;
23+
24+
@iOSFindBy(uiAutomator = ".elements()[0]")
25+
@AndroidFindBy(className = "android.widget.TextView")
26+
public List<WebElement> androidOriOsTextViews;
27+
28+
@AndroidFindBy(uiAutomator = "new UiSelector().resourceId(\"android:id/text1\")")
29+
public List<WebElement> androidUIAutomatorViews;
30+
31+
@AndroidFindBy(uiAutomator = "new UiSelector().resourceId(\"android:id/text1\")")
32+
public List<MobileElement> mobileElementViews;
33+
34+
@FindBy(className = "android.widget.TextView")
35+
public List<MobileElement> mobiletextVieWs;
36+
37+
@AndroidFindBy(uiAutomator = "new UiSelector().resourceId(\"android:id/text1\")")
38+
public List<RemoteWebElement> remoteElementViews;
39+
40+
@FindBy(id = "android:id/text1")
41+
public WebElement textView;
42+
43+
@AndroidFindBy(className = "android.widget.TextView")
44+
public WebElement androidTextView;
45+
46+
@iOSFindBy(uiAutomator = ".elements()[0]")
47+
public WebElement iosTextView;
48+
49+
@AndroidFindBy(className = "android.widget.TextView")
50+
@iOSFindBy(uiAutomator = ".elements()[0]")
51+
public WebElement androidOriOsTextView;
52+
53+
@AndroidFindBy(uiAutomator = "new UiSelector().resourceId(\"android:id/text1\")")
54+
public WebElement androidUIAutomatorView;
55+
56+
@AndroidFindBy(uiAutomator = "new UiSelector().resourceId(\"android:id/text1\")")
57+
public MobileElement mobileElementView;
58+
59+
@FindBy(className = "android.widget.TextView")
60+
public MobileElement mobiletextVieW;
61+
62+
@AndroidFindBy(uiAutomator = "new UiSelector().resourceId(\"android:id/text1\")")
63+
public RemoteWebElement remotetextVieW;
64+
65+
}
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
package com.saucelabs.appium.page_object.ios;
2+
3+
import io.appium.java_client.MobileElement;
4+
import io.appium.java_client.ios.IOSElement;
5+
import io.appium.java_client.pagefactory.AndroidFindBy;
6+
import io.appium.java_client.pagefactory.iOSFindBy;
7+
8+
import java.util.List;
9+
10+
import org.openqa.selenium.WebElement;
11+
import org.openqa.selenium.remote.RemoteWebElement;
12+
import org.openqa.selenium.support.FindBy;
13+
14+
import io.appium.java_client.pagefactory.AndroidFindBys;
15+
import io.appium.java_client.pagefactory.iOSFindAll;;
16+
17+
public class UICatalogScreenSimple {
18+
19+
@FindBy(className = "UIAButton")
20+
public List<WebElement> uiButtons;
21+
22+
@FindBy(className = "UIAButton")
23+
public List<WebElement> iosUIButtons;
24+
25+
@iOSFindBy(uiAutomator = ".elements()[0]")
26+
public List<WebElement> iosUIAutomatorButtons;
27+
28+
@iOSFindBy(uiAutomator = ".elements()[0]")
29+
@AndroidFindBy(className = "android.widget.TextView")
30+
public List<WebElement> androidOriOsTextViews;
31+
32+
@AndroidFindBy(uiAutomator = "new UiSelector().resourceId(\"android:id/text1\")")
33+
public List<WebElement> androidUIAutomatorViews;
34+
35+
@iOSFindBy(uiAutomator = ".elements()[0]")
36+
public List<MobileElement> mobileButtons;
37+
38+
@FindBy(className = "UIAButton")
39+
public List<MobileElement> mobiletFindBy_Buttons;
40+
41+
@iOSFindBy(uiAutomator = ".elements()[0]")
42+
public List<RemoteWebElement> remoteElementViews;
43+
44+
@AndroidFindBys({
45+
@AndroidFindBy(uiAutomator = "new UiSelector().resourceId(\"android:id/list\")"),
46+
@AndroidFindBy(className = "android.widget.TextView")
47+
})
48+
public List<WebElement> chainElementViews;
49+
50+
51+
@FindBy(className = "UIAButton")
52+
public WebElement uiButton;
53+
54+
@FindBy(className = "UIAButton")
55+
public WebElement iosUIButton;
56+
57+
@iOSFindBy(uiAutomator = ".elements()[0]")
58+
public WebElement iosUIAutomatorButton;
59+
60+
@AndroidFindBy(className = "android.widget.TextView")
61+
@iOSFindBy(uiAutomator = ".elements()[0]")
62+
public WebElement androidOriOsTextView;
63+
64+
@AndroidFindBy(uiAutomator = "new UiSelector().resourceId(\"android:id/text1\")")
65+
public WebElement androidUIAutomatorView;
66+
67+
@iOSFindBy(uiAutomator = ".elements()[0]")
68+
public MobileElement mobileButton;
69+
70+
@FindBy(className = "UIAButton")
71+
public MobileElement mobiletFindBy_Button;
72+
73+
@iOSFindBy(uiAutomator = ".elements()[0]")
74+
public RemoteWebElement remotetextVieW;
75+
76+
@AndroidFindBys({
77+
@AndroidFindBy(uiAutomator = "new UiSelector().resourceId(\"android:id/list\")"),
78+
@AndroidFindBy(className = "android.widget.TextView")
79+
})
80+
public WebElement chainElementView;
81+
82+
@iOSFindBy(uiAutomator = ".elements()[0]")
83+
public IOSElement iosButton;
84+
85+
@iOSFindBy(uiAutomator = ".elements()[0]")
86+
public List<IOSElement> iosButtons;
87+
88+
@iOSFindAll({
89+
@iOSFindBy(xpath = "ComputeSumButton_Test"),
90+
@iOSFindBy(name = "ComputeSumButton") //it is real locator
91+
})
92+
public WebElement findAllElement;
93+
94+
@iOSFindAll({
95+
@iOSFindBy(xpath = "ComputeSumButton_Test"),
96+
@iOSFindBy(name = "ComputeSumButton") //it is real locator
97+
})
98+
public List<WebElement> findAllElements;
99+
100+
}

0 commit comments

Comments
 (0)