首页 文章

如何使用Eclipse在Appium上运行脚本测试?

提问于
浏览
0

嗨,我写了这段代码,我正在尝试做一个测试,通过使用Appium在APP中进行登录 . 当我运行测试它返回我这个错误:

org.openqa.selenium.WebDriverException:处理命令时发生未知的服务器端错误 . 原始错误:启动App时出错 . 原始错误:执行adbExec时出错 . 原始错误:'命令'C:\ Users \ lucas \ AppData \ Local \ Android \ sdk \ platform-tools \ adb.exe -P 5037 -s 5210ce98fa7eb4b3 shell am start -W -n com.consul.android.smartbeer.qa /com.whirlpool.ted.View.DashBoardActivity-S'退出代码1'; Stderr:'java.lang.SecurityException:Permission Denial:start Intent {flg = 0x10000000 cmp = com.consul.android.smartbeer.qa / com.whirlpool.ted.View.DashBoardActivity launchParam = MultiScreenLaunchParams {mDisplayId = 0 mBaseDisplayId = 0 mFlags从null(pid = 867,uid = 2000)未从uid 10226在android.os.Parcel.readException(Parcel.java:1653)的android.os.Parcel.readException(Parcel.java:1703)中导出= 0}}在android.app.ActivityManagerProxy.startActivityAndWait(ActivityManagerNative.java:3680)的com.android.commands.am.Am.runStart(Am.java:658)com.android.commands.am.Am.onRun(Am.java) :392)位于com.android.internal.os的com.android.commands.am.Am.main(Am.java:125)的com.android.internal.os.BaseCommand.run(BaseCommand.java:51) . com.android.internal.os.RuntimeInit.main(RuntimeInit.java:316)'中的RuntimeInit.nativeFinishInit(Native Method);代码:'1'(警告:服务器未提供任何堆栈跟踪信息)命令持续时间或超时:28.33秒构建信息:版本:'3.9.1',修订版:'63f7b50',时间:'2018-02-07T22: 42:22.379Z'系统信息:主机:'LAPTOP-PFJQUV00',ip:'192.168.116.1',os.name:'Windows 10',os.arch:'amd64',os.version:'10 .0',java .version:'1.8.0_152'驱动程序信息:driver.version:sun.reflect.NativeConstructorAccessorImpl.newInstance0(本地方法)的sun.reflect.NativeConstructorAccessorImpl.newInstance(未知来源)sun.reflect.DelegatingConstructorAccessorImpl.newInstance(未知)的AndroidDriver来自org.openqa.selenium.remote上的org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:214)中的java.lang.reflect.Constructor.newInstance(未知来源)(ErrorHandler . 错误处理程序 . java:166)org.openqa.selenium.remote.JsonWireProtocolResponse.lambda $ new $ 0(JsonWireProtocolResponse.java:53)org.openqa.selenium.remote.JsonWireProtocolRespons e.lambda $ getResponseFunction $ 2(JsonWireProtocolResponse.java:91)atg.openqa.selenium.remote.ProtocolHandshake.lambda $ createSession $ 0(ProtocolHandshake.java:123)at java.util.stream.ReferencePipeline $ 3 $ 1.accept(Unknown Source java.util.stream上的java.util.stream.AbstractPipeline.copyIntoWithCancel(未知来源)java.util.stream.ReferencePipeline.forEachWithCancel(未知来源)的java.util.Spliterators $ ArraySpliterator.tryAdvance(未知来源) . java.util.stream.FindOps上的java.util.stream.AbstractPipeline.wrapAndCopyInto(未知来源)中的AbstractPipeline.copyInto(未知来源)java.util.stream.AbstractPipeline.evaluate(未知来源)中的$ FindOp.evaluateSequential(未知来源) )org.openqa.selenium.remote.Arotium.remotium.remote.Arotote.ProtocolHandshake.createSession(ProtocolHandshake.java)中org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:126)的java.util.stream.ReferencePipeline.findFirst(未知来源) :73)在org.openqa.selenium.remote.HttpCommandExecutor.e xecute(HttpCommandExecutor.java:138)位于io.appium的org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:601)的io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:89) . iava.appium.java_client.AppiumDriver.exe执行(AppiumDriver.java:1)中的.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:42)at io.appium.java_client.android.AndroidDriver.execute(AndroidDriver.java:1)at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:219)atg.openqa.selenium.remote.RemoteWebDriver . (RemoteWebDriver.java:142)at io.appium.java_client.DefaultGenericMobileDriver . (DefaultGenericMobileDriver.java: 38)io.appium.java_client.AppiumDriver . (AppiumDriver.java:83)at io.appium.java_client.AppiumDriver . (AppiumDriver.java:93)at io.appium.java_client.android.AndroidDriver . (AndroidDriver.java: 72)在test.FacebookLoginTest.testLoginFB(FacebookLoginTest.java:30)atsun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)at java.lang.reflect.Method.invoke(Unknown Source)at at at at在org.junit.runners.model.FrameworkMethod的org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)上的org.junit.runners.model.FrameworkMethod $ 1.runReflectiveCall(FrameworkMethod.java:50) .invokeExplosively(FrameworkMethod.java:47)org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)org . junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)at org.junit.runners.ParentRunner $ 3.run(ParentRunner.java:290)at org.junit.runners.ParentRunner $ 1.schedule(ParentRunner.java:71)org.junit.runners.ParentRunner.runChildren(Pa rentRunner.java:288)org.junit.runners.ParentRunner.access $ 000(ParentRunner.java:58)org.junit.runners.ParentRunner $ 2.evaluate(ParentRunner.java:268)org.junit.runners.ParentRunner .run(ParentRunner.java:363)atg.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution) .java:38)org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:538)org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:760) )org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:460)org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:206)

我正在尝试运行一个简单的登录测试,但我陷入了困境 . Appium没有打开应用程序:(

这是Java中的类clode:

package test;

    import io.appium.java_client.android.AndroidDriver;

    import java.net.MalformedURLException; import java.net.URL; 
    import java.util.concurrent.TimeUnit; 
    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;

    import org.junit.Test;

    public class TedLoginTest {

    @Test

    public void testLoginFB() throws MalformedURLException, InterruptedException    {   

    DesiredCapabilities capabilities = new DesiredCapabilities() ;  

    capabilities.setCapability("automationName","Appium");  
    capabilities.setCapability("platformnName","Android");  
    capabilities.setCapability("platformVersion","7.0");    
    capabilities.setCapability("deviceName","Lucas" );  
    capabilities.setCapability("udid", "5210ce98fa7eb4b3");     
    capabilities.setCapability("app","C:\\Users\\lucas\\Downloads\\TED.apk");
    capabilities.setCapability("appActivity", "com.whirlpool.ted.View.DashboardActivity");
    AndroidDriver driver = new AndroidDriver (new URL ("http://0.0.0.0:4723/wd/hub"), capabilities) ;
    driver.manage().timeouts().implicitlyWait(100,TimeUnit.SECONDS);

    driver.findElementByAndroidUIAutomator("new UiSelector().resourceId(\"com.consul.android.smartbeer.qa:id/edEmail\")").sendKeys("tedusp01@yahoo.com");
    driver.findElementByAndroidUIAutomator("new UiSelector().resourceId(\"com.consul.android.smartbeer.qa:id/edPassword\")").sendKeys("Smart2000");
    driver.findElementByAndroidUIAutomator("new UiSelector().resourceId(\"com.consul.android.smartbeer.qa:id/login\").text(\"Entrar\")").click();
    Thread.sleep(8000);

     }
    }

有谁知道我做错了什么?我错过了任何导入,还是语法错误?

1 回答

  • 0

    在搜索SO时,我发现了许多与此类似的问题,并且它们都有或多或少相同的答案 .


    您需要在声明此活动的AndroidManifest.xml文件中设置 android:exported="true" .

    <activity
        android:name="com.example.lib.MainActivity"
        android:label="LibMain" 
        android:exported="true">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" >
            </action>
        </intent-filter>
    </activity>
    

    参考:https://stackoverflow.com/a/19829733/2533443

相关问题