-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGestures.java
More file actions
45 lines (31 loc) · 2.07 KB
/
Copy pathGestures.java
File metadata and controls
45 lines (31 loc) · 2.07 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
import java.net.MalformedURLException;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.WebElement;
import io.appium.java_client.TouchAction; //for line no 26 we have to import this package
import static io.appium.java_client.touch.TapOptions.tapOptions; //for using the tap options arguments, we have to import it
import static io.appium.java_client.touch.LongPressOptions.longPressOptions; //for using long press
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.android.AndroidElement;
import static java.time.Duration.ofSeconds; // for of seconds
import static io.appium.java_client.touch.offset.ElementOption.element; //for element
public class Gestures extends Base {
public static void main(String[] args) throws MalformedURLException {
// TODO Auto-generated method stub
AndroidDriver<AndroidElement> driver = capabilities();
driver.manage().timeouts().implicitlyWait(40, TimeUnit.SECONDS);
driver.findElementByXPath("//android.widget.TextView[@text='Views']").click();
System.out.println("Test 1");
//Tap Option
TouchAction t = new TouchAction(driver); //Tap Action method (Touch Action Class)
WebElement expandList = driver.findElementByXPath("//android.widget.TextView[@text='Expandable Lists']"); //here we are not clicking we are just grabbing xPath
//we have stored the xpath of webelement into the expand list variable.
t.tap(tapOptions().withElement(element(expandList))).perform() ; //Arguments
System.out.println("Test 2");
driver.findElementByXPath("//android.widget.TextView[@text='1. Custom Adapter']").click();
System.out.println("Test 3");
WebElement pn = driver.findElementByXPath("//android.widget.TextView[@text='People Names']"); //pn=public names
//Long press
t.longPress(longPressOptions().withElement(element(pn)).withDuration(ofSeconds(2))).release().perform(); //
System.out.println(driver.findElementById("android:id/title").isDisplayed()); //for displaying the action we have used the resource id of the sample Menu.
}
}