forked from appium/java-client
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMobileBy.java
More file actions
110 lines (81 loc) · 2.92 KB
/
MobileBy.java
File metadata and controls
110 lines (81 loc) · 2.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
package io.appium.java_client;
import org.openqa.selenium.By;
import org.openqa.selenium.SearchContext;
import org.openqa.selenium.WebElement;
import java.io.Serializable;
import java.util.List;
/**
* Created by jonahss on 4/10/14.
*/
public abstract class MobileBy extends By {
public static By IosUIAutomation(final String uiautomationText) {
if (uiautomationText == null) {
throw new IllegalArgumentException("Must supply an iOS UIAutomation string");
}
return new ByIosUIAutomation(uiautomationText);
}
public static By AndroidUIAutomator(final String uiautomatorText) {
if (uiautomatorText == null) {
throw new IllegalArgumentException("Must supply an Android UIAutomator string");
}
return new ByAndroidUIAutomator(uiautomatorText);
}
public static By AccessibilityId(final String id) {
if (id == null) {
throw new IllegalArgumentException("Must supply a uiautomationText");
}
return new ByAccessibilityId(id);
}
public static class ByIosUIAutomation extends By implements Serializable {
private final String automationText;
public ByIosUIAutomation(String uiautomationText) {
automationText = uiautomationText;
}
@Override
public List<WebElement> findElements(SearchContext context) {
return ((FindsByIosUIAutomation) context).findElementsByIosUIAutomation(automationText);
}
@Override
public WebElement findElement(SearchContext context) {
return ((FindsByIosUIAutomation) context).findElementByIosUIAutomation(automationText);
}
@Override
public String toString() {
return "By.IosUIAutomation: " + automationText;
}
}
public static class ByAndroidUIAutomator extends By implements Serializable {
private final String automatorText;
public ByAndroidUIAutomator(String uiautomatorText) {
automatorText = uiautomatorText;
}
@Override
public List<WebElement> findElements(SearchContext context) {
return ((FindsByAndroidUIAutomator) context).findElementsByAndroidUIAutomator(automatorText);
}
@Override
public WebElement findElement(SearchContext context) {
return ((FindsByAndroidUIAutomator) context).findElementByAndroidUIAutomator(automatorText);
}
@Override
public String toString() { return "By.AndroidUIAutomator: " + automatorText; }
}
public static class ByAccessibilityId extends By implements Serializable {
private final String id;
public ByAccessibilityId(String id) {
this.id = id;
}
@Override
public List<WebElement> findElements(SearchContext context) {
return ((FindsByAccessibilityId) context).findElementsByAccessibilityId(id);
}
@Override
public WebElement findElement(SearchContext context) {
return ((FindsByAccessibilityId) context).findElementByAccessibilityId(id);
}
@Override
public String toString() {
return "By.AccessibilityId: " + id;
}
}
}