我有一个java maven项目,它使用appium在真实设备中运行本机应用程序的测试。我试图使用selendroid与appium。我将功能自动化名称设置为selendroid,并将selendroid端口设置为appium中的8080。我的应用程序正在启动,但点击或点击无法正常工作。我还需要设置更多。 以下是来自appium和代码的错误
> Starting Node Server
> info: Welcome to Appium v1.2.0 (REV e53f49c706a25242e66d36685c268b599cc18da5)
> debug: Non-default server args:
{"address":"127.0.0.1","logNoColors":true,"platformName":"Android","platformVersion":"18","automation Name":"Selendroid"}
> info: Appium REST http interface listener started on 127.0.0.1:4723
> info: LogLevel: debug
> info: --> POST /wd/hub/session {"desiredCapabilities": {"app":"C:\\Users\\Antony\\workspace\\appiumJustWink\\app\\justwink-usa- 2.3.2.218221.69.apk","appPackage":"com.justwink","autoWebviewTimeout":6000,"appWaitPackage":"com.just wink","appWaitActivity":"com.justwink.splashscreen.SplashActivity","deviceName":"SCH- I535","autolaunch":"true","appActivity":"com.justwink.splashscreen.SplashActivity","newCommandTimeout ":24000,"platformVersion":"4.4","automationName":"Selendroid","browserName":"","autoWebview":true,"
platformName":"Android"}}
> debug: Appium request initiated at /wd/hub/session
> debug: Request received with params: {"desiredCapabilities": {"app":"C:\\Users\\Antony\\workspace\\appiumJustWink\\app\\justwink-usa- 2.3.2.218221.69.apk","appPackage":"com.justwink","autoWebviewTimeout":6000,"appWaitPackage":"com.just wink","appWaitActivity":"com.justwink.splashscreen.SplashActivity","deviceName":"SCH- I535","autolaunch":"true","appActivity":"com.justwink.splashscreen.SplashActivity","newCommandTimeout ":24000,"platformVersion":"4.4","automationName":"Selendroid","browserName":"","autoWebview":true,"pl atformName":"Android"}}
> debug: The following desired capabilities were provided, but not recognized by appium. They will be passed on to any other services running on this server. : autolaunch
> debug: Using local app from desired caps: C:\Users\Antony\workspace\appiumJustWink\app\justwink- usa-2.3.2.218221.69.apk
> info: Retrieving device
> debug: Creating new appium session ff684895-7955-499a-b298-f56ee81ee5f4
> debug: Starting selendroid server
> debug: Checking whether selendroid is built yet
> debug: Selendroid server exists!
> debug: Preparing device for session
> debug: Checking whether app is actually present
> debug: Checking whether adb is present
> debug: Using adb from C:\AndroidSDK\sdk\platform-tools\adb.exe
> debug: Trying to find a connected android device
> debug: Getting connected devices...
> debug: executing: "C:\AndroidSDK\sdk\platform-tools\adb.exe" devices
> debug: 1 device(s) connected
> info: Found device 43013dce
> debug: Setting device id to 43013dce
> debug: Waiting for device to be ready and to respond to shell commands (timeout = 5)
> debug: executing: "C:\AndroidSDK\sdk\platform-tools\adb.exe" -s 43013dce wait-for-device
> debug: executing: "C:\AndroidSDK\sdk\platform-tools\adb.exe" -s 43013dce shell "echo 'ready'"
> debug: Starting logcat capture
> debug: Rebuilt selendroid apk exists, doing nothing
> debug: Rebuilt selendroid server already exists, no need to rebuild it with a new manifest
> debug: Checking signed status of C:\Windows\Temp\selendroid.com.justwink.apk
> debug: Checking app cert for C:\Windows\Temp\selendroid.com.justwink.apk: java -jar "C:\Program Files (x86)\Appium\node_modules\appium\node_modules\appium-adb\jars\verify.jar" "C:\Windows\Temp\selendroid.com.justwink.apk"
> debug: Checking signed status of C:\Users\Antony\workspace\appiumJustWink\app\justwink-usa-2.3.2.218221.69.apk
> debug: Checking app cert for C:\Users\Antony\workspace\appiumJustWink\app\justwink-usa- 2.3.2.218221.69.apk: java -jar "C:\Program Files (x86)\Appium\node_modules\appium\node_modules\appium-adb\jars\verify.jar" "C:\Users\Antony\workspace\appiumJustWink\app\justwink-usa-2.3.2.218221.69.apk"
> debug: App already signed.
> debug: Zip-aligning C:\Windows\Temp\selendroid.com.justwink.apk
> debug: Checking whether zipalign is present
> debug: Using zipalign from C:\AndroidSDK\sdk\build-tools\19.1.0\zipalign.exe
> debug: zipAlignApk: "C:\AndroidSDK\sdk\build-tools\19.1.0\zipalign.exe" -f 4 "C:\Windows\Temp\selendroid.com.justwink.apk" "C:\Users\Antony\AppData\Local\Temp\appium114824-5500-v7yco6.tmp"
> debug: App already signed.
> debug: Zip-aligning C:\Users\Antony\workspace\appiumJustWink\app\justwink-usa-2.3.2.218221.69.apk
> debug: Checking whether zipalign is present
> debug: Using zipalign from C:\AndroidSDK\sdk\build-tools\19.1.0\zipalign.exe
> debug: zipAlignApk: "C:\AndroidSDK\sdk\build-tools\19.1.0\zipalign.exe" -f 4 "C:\Users\Antony\workspace\appiumJustWink\app\justwink-usa-2.3.2.218221.69.apk" "C:\Users\Antony\AppData\Local\Temp\appium114824-5500-18wquh1.tmp"
> debug: Getting install status for com.justwink.selendroid
> debug: executing: "C:\AndroidSDK\sdk\platform-tools\adb.exe" -s 43013dce shell "pm list packages -3 com.justwink.selendroid"
> debug: App is installed
> debug: Rebuilt selendroid is already installed
> debug: executing: "C:\AndroidSDK\sdk\platform-tools\adb.exe" -s 43013dce shell "getprop persist.sys.language"
> debug: Current device language: en
> debug: java -jar "C:\Program Files (x86)\Appium\node_modules\appium\node_modules\appium-adb\jars\strings_from_apk.jar" "C:\Users\Antony\workspace\appiumJustWink\app\justwink-usa-2.3.2.218221.69.apk" "C:\Windows\Temp\com.justwink" en
> debug: No strings.xml for language 'en', getting default strings.xml
> debug: java -jar "C:\Program Files (x86)\Appium\node_modules\appium\node_modules\appium-adb\jars\strings_from_apk.jar" "C:\Users\Antony\workspace\appiumJustWink\app\justwink-usa-2.3.2.218221.69.apk" "C:\Windows\Temp\com.justwink"
> debug: Not uninstalling app since server not started with --full-reset
> debug: Checking app cert for C:\Users\Antony\workspace\appiumJustWink\app\justwink-usa-2.3.2.218221.69.apk: java -jar "C:\Program Files (x86)\Appium\node_modules\appium\node_modules\appium-adb\jars\verify.jar" "C:\Users\Antony\workspace\appiumJustWink\app\justwink-usa-2.3.2.218221.69.apk"
> debug: App already signed.
> debug: Zip-aligning C:\Users\Antony\workspace\appiumJustWink\app\justwink-usa-2.3.2.218221.69.apk
> debug: Checking whether zipalign is present
> debug: Using zipalign from C:\AndroidSDK\sdk\build-tools\19.1.0\zipalign.exe
> debug: zipAlignApk: "C:\AndroidSDK\sdk\build-tools\19.1.0\zipalign.exe" -f 4 "C:\Users\Antony\workspace\appiumJustWink\app\justwink-usa-2.3.2.218221.69.apk" "C:\Users\Antony\AppData\Local\Temp\appium114824-5500-1en8ers.tmp"
> debug: MD5 for app is 3aca4df645e75a21edbbd9a27ea557db
> debug: executing: "C:\AndroidSDK\sdk\platform-tools\adb.exe" -s 43013dce shell "ls /data/local/tmp/3aca4df645e75a21edbbd9a27ea557db.apk"
> debug: Getting install status for com.justwink
> debug: executing: "C:\AndroidSDK\sdk\platform-tools\adb.exe" -s 43013dce shell "pm list packages -3 com.justwink"
> debug: App is installed
> info: App is already installed, resetting app
> debug: Running fast reset (stop and clear)
> debug: executing: "C:\AndroidSDK\sdk\platform-tools\adb.exe" -s 43013dce shell "am force-stop com.justwink"
> debug: executing: "C:\AndroidSDK\sdk\platform-tools\adb.exe" -s 43013dce shell "pm clear com.justwink"
> debug: Forwarding system:8080 to device:8080
> debug: executing: "C:\AndroidSDK\sdk\platform-tools\adb.exe" -s 43013dce forward tcp:8080 tcp:8080
> debug: Pushing settings apk to device...
> debug: executing: "C:\AndroidSDK\sdk\platform-tools\adb.exe" -s 43013dce install "C:\Program Files (x86)\Appium\node_modules\appium\build\settings_apk\settings_apk-debug.apk"
> debug: Pushing unlock helper app to device...
> debug: executing: "C:\AndroidSDK\sdk\platform-tools\adb.exe" -s 43013dce install "C:\Program Files (x86)\Appium\node_modules\appium\build\unlock_apk\unlock_apk-debug.apk"
> debug: executing: "C:\AndroidSDK\sdk\platform-tools\adb.exe" -s 43013dce shell "dumpsys window"
> debug: Writing dumpsys output to C:\Program Files (x86)\Appium\node_modules\appium\.dumpsys.log
> debug: Screen already unlocked, continuing.
> debug: executing: "C:\AndroidSDK\sdk\platform-tools\adb.exe" -s 43013dce shell "am instrument -e main_activity 'com.justwink.splashscreen.SplashActivity' com.justwink.selendroid/io.selendroid.ServerInstrumentation"
> debug: Making http request with opts: {"url":"http://localhost:8080/wd/hub/status","method":"GET"}
> debug: Making http request with opts: {"url":"http://localhost:8080/wd/hub/status","method":"GET"}
> debug: Making http request with opts: {"url":"http://localhost:8080/wd/hub/status","method":"GET"}
> debug: Making http request with opts: {"url":"http://localhost:8080/wd/hub/status","method":"GET"}
> debug: Making http request with opts: {"url":"http://localhost:8080/wd/hub/status","method":"GET"}
> debug: Making http request with opts: {"url":"http://localhost:8080/wd/hub/status","method":"GET"}
> debug: Selendroid server is alive!
> debug: Listening for Selendroid logs
> debug: Creating Selendroid session
> debug: Making http request with opts: {"url":"http://localhost:8080/wd/hub/session","method":"POST","json":{"desiredCapabilities":{"warnings":{},"desired":{"app":"C:\\Users\\Antony\\workspace\\appiumJustWink\\app\\justwink-usa-2.3.2.218221.69.apk","appPackage":"com.justwink","autoWebviewTimeout":6000,"appWaitPackage":"com.justwink","appWaitActivity":"com.justwink.splashscreen.SplashActivity","deviceName":"SCH-I535","autolaunch":"true","appActivity":"com.justwink.splashscreen.SplashActivity","newCommandTimeout":24000,"platformVersion":"4.4","automationName":"Selendroid","browserName":"","autoWebview":true,"platformName":"Android"},"app":"C:\\Users\\Antony\\workspace\\appiumJustWink\\app\\justwink-usa-2.3.2.218221.69.apk","appPackage":"com.justwink","autoWebviewTimeout":6000,"appWaitPackage":"com.justwink","appWaitActivity":"com.justwink.splashscreen.SplashActivity","deviceName":"SCH-I535","autolaunch":"true","appActivity":"com.justwink.splashscreen.SplashActivity","newCommandTimeout":24000,"platformVersion":"4.4","automationName":"Selendroid","browserName":"","autoWebview":true,"platformName":"Android"}}}
> debug: Successfully started selendroid session
> debug: Waiting for pkg "com.justwink" and activity "com.justwink.splashscreen.SplashActivity" to be focused
> debug: Getting focused package and activity
> debug: executing: "C:\AndroidSDK\sdk\platform-tools\adb.exe" -s 43013dce shell "dumpsys window windows"
> debug: [SELENDROID] http://localhost:8080/wd/hub/session/a7755f7f-4b4b-ceb1-758d-8e938724c2ba
> debug: Setting auto webview
> debug: Getting a list of available webviews
> debug: executing: "C:\AndroidSDK\sdk\platform-tools\adb.exe" -s 43013dce shell "cat /proc/net/unix"
> debug: Available contexts: undefined
> debug: []
> debug: Making http request with opts: {"url":"http://localhost:8080/wd/hub/session/a7755f7f-4b4b-ceb1-758d-8e938724c2ba/window_handles","method":"GET"}
> debug: Retrying context switch with timeout '6000'
> debug: Getting a list of available webviews
> debug: executing: "C:\AndroidSDK\sdk\platform-tools\adb.exe" -s 43013dce shell "cat /proc/net/unix"
> debug: Available contexts: NATIVE_APP
> debug: []
> debug: Making http request with opts: {"url":"http://localhost:8080/wd/hub/session/a7755f7f-4b4b- ceb1-758d-8e938724c2ba/window_handles","method":"GET"}
> debug: Overriding session id with "a7755f7f-4b4b-ceb1-758d-8e938724c2ba"
> info: <-- POST /wd/hub/session 303 37750.184 ms - 9
> debug: Device launched! Ready for commands
> debug: Setting command timeout to 24000 secs
> debug: Appium session started with sessionId a7755f7f-4b4b-ceb1-758d-8e938724c2ba
> info: --> GET /wd/hub/session/a7755f7f-4b4b-ceb1-758d-8e938724c2ba {}
> debug: Appium request initiated at /wd/hub/session/a7755f7f-4b4b-ceb1-758d-8e938724c2ba
> debug: Request received with params: {}
> debug: Proxying command to localhost:8080
> debug: Making http request with opts: {"url":"http://localhost:8080/wd/hub/session/a7755f7f-4b4b-ceb1-758d-8e938724c2ba","method":"GET"}
> debug: Proxied response received with status 200: "{\"value\":{\"automationName\":\"selendroid\",\"platform\":\"android\",\"platformVersion\":\"18\",\"acceptSslCerts\":true,\"javascriptEnabled\":true,\"platformName\":\"android\",\"handlesAlerts\":true,\"browserName\":\"selendroid\",\"networkConnectionEnabled\":true,\"rotatable\":true,\"takesScreenshot\":true,\"version\":\"0.10.0\"},\"status\":0,\"sessionId\":\"a7755f7f-4b4b-ceb1-758d-8e938724c2ba\"}"
> info: <-- GET /wd/hub/session/a7755f7f-4b4b-ceb1-758d-8e938724c2ba 200 64.131 ms - 358
> info: --> POST /wd/hub/session/a7755f7f-4b4b-ceb1-758d-8e938724c2ba/timeouts/implicit_wait {"ms":160000}
> debug: Appium request initiated at /wd/hub/session/a7755f7f-4b4b-ceb1-758d-8e938724c2ba/timeouts/implicit_wait
> debug: Request received with params: {"ms":160000}
> debug: Proxying command to localhost:8080
> debug: Making http request with opts: {"url":"http://localhost:8080/wd/hub/session/a7755f7f-4b4b-ceb1-758d-8e938724c2ba/timeouts/implicit_wait","method":"POST","json":{"ms":160000}}
> debug: Proxied response received with status 200: {"value":"","status":0,"sessionId":"a7755f7f-4b4b-ceb1-758d-8e938724c2ba"}
> info: <-- POST /wd/hub/session/a7755f7f-4b4b-ceb1-758d-8e938724c2ba/timeouts/implicit_wait 200 66.321 ms - 74
> info: --> POST /wd/hub/session/a7755f7f-4b4b-ceb1-758d-8e938724c2ba/element {"using":"xpath","value":"//android.widget.Button[2]"}
> debug: Appium request initiated at /wd/hub/session/a7755f7f-4b4b-ceb1-758d-8e938724c2ba/element
> debug: Request received with params: {"using":"xpath","value":"//android.widget.Button[2]"}
> debug: Proxying command to localhost:8080
> debug: Making http request with opts: {"url":"http://localhost:8080/wd/hub/session/a7755f7f-4b4b-ceb1-758d-8e938724c2ba/element","method":"POST","json":{"using":"xpath","value":"//android.widget.Button[2]"}}
> debug: Responding to client with error: {"status":7,"value":{"message":"An element could not be located on the page using the given search parameters.","origValue":"Element was not found.\nio.selendroid.exceptions.NoSuchElementException: Element was not found.\n\tat io.selendroid.server.handler.FindElement.handle(FindElement.java:57)\n\tat io.selendroid.server.AndroidServlet.handleRequest(AndroidServlet.java:290)\n\tat io.selendroid.server.BaseServlet.handleHttpRequest(BaseServlet.java:70)\n\tat org.webbitserver.netty.NettyHttpControl.nextHandler(NettyHttpControl.java:78)\n\tat org.webbitserver.netty.NettyHttpControl.nextHandler(NettyHttpControl.java:62)\n\tat io.selendroid.server.inspector.InspectorServlet.handleHttpRequest(InspectorServlet.java:78)\n\tat org.webbitserver.netty.NettyHttpControl.nextHandler(NettyHttpControl.java:78)\n\tat org.webbitserver.netty.NettyHttpControl.nextHandler(NettyHttpControl.java:62)\n\tat org.webbitserver.handler.PathMatchHandler.handleHttpRequest(PathMatchHandler.java:33)\n\tat org.webbitserver.netty.NettyHttpControl.nextHandler(NettyHttpControl.java:78)\n\tat org.webbitserver.netty.NettyHttpControl.nextHandler(NettyHttpControl.java:62)\n\tat org.webbitserver.handler.DateHeaderHandler.handleHttpRequest(DateHeaderHandler.java:21)\n\tat org.webbitserver.netty.NettyHttpControl.nextHandler(NettyHttpControl.java:78)\n\tat org.webbitserver.netty.NettyHttpControl.nextHandler(NettyHttpControl.java:62)\n\tat org.webbitserver.handler.ServerHeaderHandler.handleHttpRequest(ServerHeaderHandler.java:25)\n\tat org.webbitserver.netty.NettyHttpControl.nextHandler(NettyHttpControl.java:78)\n\tat org.webbitserver.netty.NettyHttpControl.nextHandler(NettyHttpControl.java:67)\n\tat org.webbitserver.netty.NettyHttpChannelHandler$2.run(NettyHttpChannelHandler.java:72)\n\tat java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)\n\tat java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)\n\tat java.lang.Thread.run(Thread.java:841)\n"},"sessionId":"a7755f7f-4b4b-ceb1-758d-8e938724c2ba"}
> info: <-- POST /wd/hub/session/a7755f7f-4b4b-ceb1-758d-8e938724c2ba/element 500 160247.347 ms - 2040
代码:
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("browserName", "");
capabilities.setCapability("platformVersion", "4.4");
capabilities.setCapability("platformName", "Android");
capabilities.setCapability("app", app.getAbsolutePath());
capabilities.setCapability("deviceName", "SCH-I535");
//capabilities.setCapability("deviceName", "emulator-5554");
capabilities.setCapability("autolaunch", "true");
capabilities.setCapability("appPackage", "com.justwin");
capabilities.setCapability("appWaitPackage", "com.justwin");
capabilities.setCapability("automationName", "Selendroid");
//capabilities.setCapability("device", "Selendroid");
capabilities.setCapability("autoWebview", true);
capabilities.setCapability("newCommandTimeout",24000);
capabilities.setCapability("autoWebviewTimeout",6000);
capabilities.setCapability("appActivity", "com.justwink.splashscreen.SplashActivity");
capabilities.setCapability("appWaitActivity", "com.justwink.splashscreen.SplashActivity");
try {
driver = new AppiumDriver(new URL("http://127.0.0.1:4723/wd/hub"),capabilities);
} catch (Exception e) {
e.printStackTrace();
}
driver.manage().timeouts().implicitlyWait(160, TimeUnit.SECONDS);
}
@Test
public void testUIz()
{
driver.findElement(By.xpath("//android.widget.Button[2]")).click();
}
答案 0 :(得分:0)
当您要求selenium找到该元素时,您似乎正在给它定位策略&#34; id&#34;。
"using":"id",
"value":"android:id/button1"
您应该使用xpath
定位器策略。
尝试类似:
driver.findElement(By.XPATH("//className[1]").click()
试试这个。如果您粘贴源代码,则可以更轻松地调试问题。