Я использую этот код и генерирую эту ошибку
import java.net.MalformedURLException;
import java.net.URL;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.DesiredCapabilities;
import io.appium.java_client.MobileDriver;
import io.appium.java_client.TouchAction;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.remote.MobileCapabilityType;
public class HandlingScrollVertical {
public static void main(String[] args) throws MalformedURLException, InterruptedException {
// TODO Auto-generated method stub
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.findElementsByAccessibilityId("Animation").get(1).click();
/*WebElement info=driver.findElementsById("android:id/text1").get(1);
int x1=info.getLocation().getX();
int y1=info.getLocation().getY();
int x2=x1 /2;
int y2=y1 /2;
TouchAction a = new TouchAction((MobileDriver) driver);
a.press(info).moveTo(x1,y1).perform().release();*/
Thread.sleep(8000);
driver.quit();
}
}
Набор переменных Envorinment:
Автономный сервер Selenium 2.53
Java-Client 5.0.4
Emulator
Журнал ошибок:
Exception in thread "main" java.lang.ClassCastException: java.util.HashMap cannot be cast to org.openqa.selenium.WebElement
at org.openqa.selenium.remote.RemoteWebDriver.findElements(RemoteWebDriver.java:397)
at io.appium.java_client.DefaultGenericMobileDriver.findElements(DefaultGenericMobileDriver.java:54)
at io.appium.java_client.AppiumDriver.findElements(AppiumDriver.java:167)
at io.appium.java_client.FindsByAccessibilityId.findElementsByAccessibilityId(FindsByAccessibilityId.java:38)
at io.appium.java_client.AppiumDriver.findElementsByAccessibilityId(AppiumDriver.java:203)
at HandlingScrollVertical.main(HandlingScrollVertical.java:33)