gpt4 book ai didi

java - 线程中的异常 "main"java.lang.NoSuchMethodError : io. appium.java_client.TouchAction.longPress(Lorg/openqa/selenium/WebElement;)

转载 作者:行者123 更新时间:2023-11-30 02:01:44 25 4
gpt4 key购买 nike

我的 Appium Java 代码:

package Generic;

import java.net.MalformedURLException;
import java.net.URL;

import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.DesiredCapabilities;

import io.appium.java_client.remote.MobileCapabilityType;

import io.appium.java_client.MobileDriver;
import io.appium.java_client.TouchAction;
import io.appium.java_client.android.AndroidDriver;

public class AppiumSelenium {

//AndroidDriver Ad=new AndroidDriver();
public static void main(String arg[]) throws MalformedURLException, InterruptedException {

DesiredCapabilities dc= new DesiredCapabilities();

dc.setCapability(MobileCapabilityType.AUTOMATION_NAME, "Appium");

dc.setCapability(MobileCapabilityType.PLATFORM_NAME, "Android");

dc.setCapability(MobileCapabilityType.PLATFORM_VERSION, "7.1.1");

dc.setCapability(MobileCapabilityType.DEVICE_NAME, "Android Emulator");

dc.setCapability(MobileCapabilityType.APP, "/home/connexis/appium/AppiumMobile/src/main/java/Apps/ApiDemos.apk");

URL url =new URL("http://127.0.0.1:4723/wd/hub");

AndroidDriver<WebElement> driver= new AndroidDriver<WebElement>(url,dc);

driver.findElementsById("android:id/text1").get(1).click();

WebElement info=driver.findElementsById("android:id/text1").get(1);


int x1=info.getLocation().getX();
int y1=info.getLocation().getY();

//we need end coornidates a.longPress(x).moveTo(startX, endY).release().perform();too hence , lets use some formulat to geterate


int x2=x1 /2;
int y2=y1 /2;






TouchAction a = new TouchAction((MobileDriver) driver);
-------------------------------------------------------

a.longPress(info).moveTo(x1, y2).perform().release();






/*
List<WebElement> val=driver.findElementsById("android:id/text1");
//it should retrive all the objects means 30 or 40 whatever present in that app

for(int i=0;i<val.size();i++){

System.out.println(val.get(i).getText());

}
*/

Thread.sleep(9000);

driver.quit();

}

}

环境设置:

 Selenium server standalone 2.53
> java-client 5.0.4
> java-client 6.1.0

错误日志

Oct 04, 2018 3:07:53 PM io.appium.java_client.remote.AppiumCommandExecutor$1 lambda$0 INFO: Detected dialect: W3C Exception in thread "main" java.lang.NoSuchMethodError: io.appium.java_client.TouchAction.longPress(Lorg/openqa/selenium/WebElement;)Lio/appium/java_client/TouchAction; at Generic.AppiumSelenium.main(AppiumSelenium.java:52)

最佳答案

如果你查看发布版本https://github.com/appium/java-client/releases/tag/v6.0.0-BETA1 TouchActions 的用法已更改,它们接受 io.appium.java_client.touch.ActionOptions 并添加了子类

TouchActions类请引用Appium的单元测试here

关于java - 线程中的异常 "main"java.lang.NoSuchMethodError : io. appium.java_client.TouchAction.longPress(Lorg/openqa/selenium/WebElement;),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52643766/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com