私はSelendroidを使ってAndroidアプリケーションでのテストを自動化するためにJAVAプログラムを作成しましたが、常にエラーが発生しています。selendroid-standalone-0.17.0 -with-dependencies.jar、java-client-5.0.4.jar。 java-client-5.0.4-sources.jar、java-client-5.0.4-javadoc.jarファイルをライブラリに入れても、エラーが発生しています。大いに必要な時に、助けてください。SelendroidプログラムがAppiumと接続していない、自動テストできない
エラー: Exception in thread "main" org.openqa.selenium.WebDriverException: Returned value cannot be converted to WebElement: {ELEMENT=1} Build info: version: 'unknown', revision: 'unknown', time: 'unknown' System info: host: 'Kapil-PC', ip: '192.168.43.212', os.name: 'Windows 8.1', os.arch: 'amd64', os.version: '6.3', java.version: '1.8.0_92' Driver info: driver.version: AndroidDriver at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:360) at io.appium.java_client.DefaultGenericMobileDriver.findElement(DefaultGenericMobileDriver.java:62) at io.appium.java_client.AppiumDriver.findElement(AppiumDriver.java:1) at io.appium.java_client.android.AndroidDriver.findElement(AndroidDriver.java:1) at org.openqa.selenium.remote.RemoteWebDriver.findElementById(RemoteWebDriver.java:403) at io.appium.java_client.DefaultGenericMobileDriver.findElementById(DefaultGenericMobileDriver.java:70) at io.appium.java_client.AppiumDriver.findElementById(AppiumDriver.java:1) at io.appium.java_client.android.AndroidDriver.findElementById(AndroidDriver.java:1) at org.openqa.selenium.By$ById.findElement(By.java:218) at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:345) at io.appium.java_client.DefaultGenericMobileDriver.findElement(DefaultGenericMobileDriver.java:58) at io.appium.java_client.AppiumDriver.findElement(AppiumDriver.java:1) at io.appium.java_client.android.AndroidDriver.findElement(AndroidDriver.java:1) at inventorytest.InventoryTest.main(InventoryTest.java:85) Caused by: java.lang.ClassCastException: java.util.HashMap cannot be cast to org.openqa.selenium.WebElement at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:358) ... 13 more C:\Users\Kapil\AppData\Local\NetBeans\Cache\8.1\executor-snippets\run.xml:53: Java returned: 1 BUILD FAILED (total time: 10 seconds)
とコード:
package inventorytest;
import io.appium.java_client.android.AndroidDriver;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
public class InventoryTest {
private static AndroidDriver driver;
public static void main(String[] args) throws MalformedURLException,
InterruptedException
{
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(CapabilityType.BROWSER_NAME, "hih");
capabilities.setCapability("deviceName", "My New Phone");
capabilities.setCapability("platformVersion", "6.0");
capabilities.setCapability("platformName", "Android");
capabilities.setCapability("appPackage", "com.example.kapil.inventory");
capabilities.setCapability("appActivity", ".add_new_item");
driver = new AndroidDriver(new URL("http://0.0.0.0:4723/wd/hub"), capabilities);
driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
driver.findElement(By.id("editText5")).sendKeys("Hello");
Thread.sleep(10000);
driver.quit();
}
}