无法运行为测试Play商店应用编写的脚本

时间:2018-07-24 02:47:28

标签: appium-android

我是Appium的新手,想继续努力。作为初学者,我正在尝试测试我在Eclipse中编写了脚本的Play商店应用。我正在尝试打开应用程序,然后单击文本框以编写一些文本。当我运行脚本时,它仅启动应用程序,然后什么也没有发生。请在下面找到代码。

包装测试;

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

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

import io.appium.java_client.AppiumDriver;
import io.appium.java_client.MobileElement;
import io.appium.java_client.android.AndroidDriver;

public class AppiumTest {

    public static void main(String[]args){

        AppiumDriver<MobileElement> driver = null;

        //Set the Desired Capabilities
        DesiredCapabilities caps = new DesiredCapabilities();
        caps.setCapability("deviceName", "Vinee");
        caps.setCapability("udid", "3204d6dea76f219d");
        caps.setCapability("platformName", "Android");
        caps.setCapability("platformVersion", "5.1.1");
        caps.setCapability("appPackage", "com.android.vending");
        caps.setCapability("appActivity", "com.google.android.finsky.activities.MainActivity");
        caps.setCapability("noReset", "true");

        //Instantiate Appium Driver
        try 
        {
             driver = new AndroidDriver<MobileElement>(new URL("http://0.0.0.0:4723/wd/hub"),caps);
        }
        catch (MalformedURLException e)
        {
            System.out.println(e.getMessage());
        }

        //Find Google Play element using ID property and click on it
        driver.findElement(By.id("com.android.vending:id/search_box_idle_text")).sendKeys("Calculator");
}   
}

我收到的错误消息是:

Jul 24, 2018 10:03:12 AM io.appium.java_client.remote.AppiumCommandExecutor$1 lambda$0
INFO: Detected dialect: W3C
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/lang3/StringUtils
    at io.appium.java_client.HasSessionDetails.lambda$0(HasSessionDetails.java:49)
    at java.util.stream.ReferencePipeline$2$1.accept(Unknown Source)
    at com.google.common.collect.CollectSpliterators$1.lambda$forEachRemaining$1(CollectSpliterators.java:117)
    at java.util.Iterator.forEachRemaining(Unknown Source)
    at java.util.Spliterators$IteratorSpliterator.forEachRemaining(Unknown Source)
    at com.google.common.collect.CollectSpliterators$1.forEachRemaining(CollectSpliterators.java:117)
    at java.util.stream.AbstractPipeline.copyInto(Unknown Source)
    at java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown Source)
    at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(Unknown Source)
    at java.util.stream.AbstractPipeline.evaluate(Unknown Source)
    at java.util.stream.ReferencePipeline.collect(Unknown Source)
    at io.appium.java_client.HasSessionDetails.getSessionDetails(HasSessionDetails.java:52)
    at io.appium.java_client.HasSessionDetails.getSessionDetail(HasSessionDetails.java:56)
    at io.appium.java_client.HasSessionDetails.getPlatformName(HasSessionDetails.java:65)
    at io.appium.java_client.internal.JsonToMobileElementConverter.<init>(JsonToMobileElementConverter.java:49)
    at io.appium.java_client.AppiumDriver.<init>(AppiumDriver.java:89)
    at io.appium.java_client.AppiumDriver.<init>(AppiumDriver.java:94)
    at io.appium.java_client.android.AndroidDriver.<init>(AndroidDriver.java:93)
    at tests.AppiumTest.main(AppiumTest.java:32)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.lang3.StringUtils
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    ... 19 more

请让我知道如何在此继续。

1 个答案:

答案 0 :(得分:1)

您可以在http://commons.apache.org/proper/commons-lang/download_lang.cgi上添加包含org / apache / commons / lang3 / StringUtils的jar文件。

在源代码下下载commons-lang3-3.7-src.zip并将其添加到项目中。