简体   繁体   中英

How to run a script test on Appium with Eclipse?

Hi I wrote this code and I'm trying to do a test that will do log-in process in a APP by using Appium. When I run the test It returns me this error:

org.openqa.selenium.WebDriverException: An unknown server-side error occurred while processing the command. Original error: Error occured while starting App. Original error: Error executing adbExec. Original error: 'Command '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' exited with code 1'; Stderr: 'java.lang.SecurityException: Permission Denial: starting Intent { flg=0x10000000 cmp=com.consul.android.smartbeer.qa/com.whirlpool.ted.View.DashBoardActivity launchParam=MultiScreenLaunchParams { mDisplayId=0 mBaseDisplayId=0 mFlags=0 } } from null (pid=867, uid=2000) not exported from uid 10226 at android.os.Parcel.readException(Parcel.java:1703) at android.os.Parcel.readException(Parcel.java:1653) at android.app.ActivityManagerProxy.startActivityAndWait(ActivityManagerNative.java:3680) at com.android.commands.am.Am.runStart(Am.java:658) at com.android.commands.am.Am.onRun(Am.java:392) at com.android.internal.os.BaseCommand.run(BaseCommand.java:51) at com.android.commands.am.Am.main(Am.java:125) at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method) at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:316)'; Code: '1' (WARNING: The server did not provide any stacktrace information) Command duration or timeout: 28.33 seconds Build info: version: '3.9.1', revision: '63f7b50', time: '2018-02-07T22:42:22.379Z' System info: host: '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 info: driver.version: AndroidDriver at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) at java.lang.reflect.Constructor.newInstance(Unknown Source) at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:214) at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:166) at org.openqa.selenium.remote.JsonWireProtocolResponse.lambda$new$0(JsonWireProtocolResponse.java:53) at org.openqa.selenium.remote.JsonWireProtocolRespons e.lambda$getResponseFunction$2(JsonWireProtocolResponse.java:91) at org.openqa.selenium.remote.ProtocolHandshake.lambda$createSession$0(ProtocolHandshake.java:123) at java.util.stream.ReferencePipeline$3$1.accept(Unknown Source) at java.util.Spliterators$ArraySpliterator.tryAdvance(Unknown Source) at java.util.stream.ReferencePipeline.forEachWithCancel(Unknown Source) at java.util.stream.AbstractPipeline.copyIntoWithCancel(Unknown Source) at java.util.stream.AbstractPipeline.copyInto(Unknown Source) at java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown Source) at java.util.stream.FindOps$FindOp.evaluateSequential(Unknown Source) at java.util.stream.AbstractPipeline.evaluate(Unknown Source) at java.util.stream.ReferencePipeline.findFirst(Unknown Source) at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:126) at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:73) at org.openqa.selenium.remote.HttpCommandExecutor.e xecute(HttpCommandExecutor.java:138) at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:89) at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:601) at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:42) at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:1) at io.appium.java_client.android.AndroidDriver.execute(AndroidDriver.java:1) at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:219) at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:142) at io.appium.java_client.DefaultGenericMobileDriver.(DefaultGenericMobileDriver.java:38) at 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) at test.FacebookLoginTest.testLoginFB(FacebookLoginTest.java:30) at sun.reflect.NativeMethodAccessorImpl.invok e0(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 org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78) at 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) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners. ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:538) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:760) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:460) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:206)

I'm trying to run a simple test for login, but I'm stuck in this. The Appium doesn't open the app :(

Here is the class clode in Java:

    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);

     }
    }

Does anyone know what am I doing wrong? Am I missing any import or is it a syntax error?

In searching SO, I found a number of questions similar to this and they all had more or less the same answer.


You need to set android:exported="true" in your AndroidManifest.xml file where you declare this Activity.

<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>

Reference: https://stackoverflow.com/a/19829733/2533443

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM