mercredi 26 septembre 2018

Java Eclipse Android testing - Tap doesn't work, imports are not recognized

I am trying to use TouchAction for testing Android Java Eclipse.

However, for some reason, Eclipse doesn't recognize tap and tapOptions.

In the following code:

package tests;

import java.net.MalformedURLException;
import java.util.concurrent.TimeUnit;

import org.openqa.selenium.WebElement;

import io.appium.java_client.TouchAction;
import static io.appium.java_client.touch.TapOptions.tapOptions;
import static io.appium.java_client.touch.LongPressOptions.longPressOptions;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.android.AndroidElement;
import static java.time.Duration.ofSeconds;
import static io.appium.java_client.touch.offset.ElementOption.element;




public class gestures extends AppiumTest {

    public static void main(String[] args) throws MalformedURLException {
        // TODO Auto-generated method stub
        AndroidDriver<AndroidElement> driver=Capabilities();
        driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
        driver.findElementByXPath("//android.widget.TextView[@text='Views']").click();
        //Tap
        TouchAction t =new TouchAction(driver);
        WebElement expandList=  driver.findElementByXPath("//android.widget.TextView[@text='Expandable Lists']");
        t.tap(tapOptions().withElement(element(expandList))).perform();
        driver.findElementByXPath("//android.widget.TextView[@text='1. Custom Adapter']").click();
    WebElement pn=  driver.findElementByXPath("//android.widget.TextView[@text='People Names']");

        t.longPress(longPressOptions().withElement(element(pn)).withDuration(ofSeconds(2))).release().perform();
        //Thread.sleep(2000);
        System.out.println(driver.findElementById("android:id/title").isDisplayed());

    }
}

, the following imports are not recognized:

import static io.appium.java_client.touch.TapOptions.tapOptions;
import static io.appium.java_client.touch.LongPressOptions.longPressOptions;
import static io.appium.java_client.touch.offset.ElementOption.element;

Why they are not recognized?

I am using:

  1. Java JDK 1.8.0

  2. java client 5.0.0 beta 6 jar

  3. appium server v1.9.1

Aucun commentaire:

Enregistrer un commentaire