Due to presence of a sticky chat button, I can not click a button on screen on my Appium test. Can anyone help?
Code
public static void TapViewBookingButton() throws InterruptedException
{
Setup.startTimer();
MobileElement btnViewBooking = (MobileElement) Setup.wait.until(ExpectedConditions.presenceOfElementLocated(By.id(btnViewBooking_ID)));
btnViewBooking.click();
Setup.updateLogMessage("VIEW BOOKING button clicked in " + Setup.stopTimer(Setup.stopWatch), SM_CONSTANTS.isScreenshot);
}
buttonViewBooking.Click() - (VIEW BOOKING) doesn't work as shown in the picture due to a sticky online chat sticky button shown on the bottom right of the screen
Logs:
info: --> POST /wd/hub/session/7ee1afc3-9a7c-4105-b8e9-acdbf9570f46/elements {"using":"id","value":"com.servicemarket.app.debug:id/btnViewBooking"}
info: [debug] Waiting up to 0ms for condition
info: [debug] Pushing command to appium work queue: ["find",{"strategy":"id","selector":"com.servicemarket.app.debug:id/btnViewBooking","context":"","multiple":true}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"id","selector":"com.servicemarket.app.debug:id/btnViewBooking","context":"","multiple":true}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: find
info: [debug] [BOOTSTRAP] [debug] Finding com.servicemarket.app.debug:id/btnViewBooking using ID with the contextId: multiple: true
info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[RESOURCE_ID=com.servicemarket.app.debug:id/btnViewBooking]
info: [debug] [BOOTSTRAP] [debug] getElements selector:UiSelector[RESOURCE_ID=com.servicemarket.app.debug:id/btnViewBooking]
info: [debug] [BOOTSTRAP] [debug] Element[] is null: (0)
info: [debug] [BOOTSTRAP] [debug] getElements tmp selector:UiSelector[INSTANCE=0, RESOURCE_ID=com.servicemarket.app.debug:id/btnViewBooking]
info: [debug] [BOOTSTRAP] [debug] Element[] is null: (1)
info: [debug] [BOOTSTRAP] [debug] getElements tmp selector:UiSelector[INSTANCE=1, RESOURCE_ID=com.servicemarket.app.debug:id/btnViewBooking]
info: [debug] [BOOTSTRAP] [debug] Returning result: {"value":[{"ELEMENT":"126"}],"status":0}
info: [debug] Responding to client with success: {"status":0,"value":[{"ELEMENT":"126"}],"sessionId":"7ee1afc3-9a7c-4105-b8e9-acdbf9570f46"}
info: <-- POST /wd/hub/session/7ee1afc3-9a7c-4105-b8e9-acdbf9570f46/elements 200 36.010 ms - 91 {"status":0,"value":[{"ELEMENT":"126"}],"sessionId":"7ee1afc3-9a7c-4105-b8e9-acdbf9570f46"}
info: --> POST /wd/hub/session/7ee1afc3-9a7c-4105-b8e9-acdbf9570f46/element/126/click {"id":"126"}
info: [debug] Pushing command to appium work queue: ["element:click",{"elementId":"126"}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"element:click","params":{"elementId":"126"}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: click
info: [debug] [BOOTSTRAP] [debug] Returning result: {"value":true,"status":0}
info: [debug] Responding to client with success: {"status":0,"value":true,"sessionId":"7ee1afc3-9a7c-4105-b8e9-acdbf9570f46"}
info: <-- POST /wd/hub/session/7ee1afc3-9a7c-4105-b8e9-acdbf9570f46/element/126/click 200 306.260 ms - 76 {"status":0,"value":true,"sessionId":"7ee1afc3-9a7c-4105-b8e9-acdbf9570f46"}
So you can get element. Thats already good. Try to click with TouchAction, e.g. press or longPress:
Point point = btnViewBooking.getLocation();
new TouchAction(driver)
.longPress(point.getX(), point.getY())
.release()
.perform();
Related
I'm trying to pass the login credentials to the input fields, everytime when I run the code the input field is getting identified, but the keys are not passing at the input field. Please help...
Code:
WebElement image=driver.findElement(By.xpath("//android.widget.Image[#content-desc='LandingPAge']"));
System.out.println("Landed Login page");
driver.findElementByXPath("//android.view.View[#content-desc='Username']").sendKeys("u3#gmail.com");
driver.findElementById("password").sendKeys("1231212");
driver.findElementByXPath("//android.widget.Button[#content-desc='Login']").click();
Appium Log Details:
[debug] [W3C (235592b3)] Calling AppiumDriver.setValue() with args: [["u","3","#","g","m","a","i","l",".","c","o","m"],"2","235592b3-a8eb-4ccb-8d22-fef43fa92679"]
[debug] [AndroidBootstrap] Sending command to android: {"cmd":"action","action":"element:setText","params":{"elementId":"2","text":"u3#gmail.com","replace":false}}
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {"cmd":"action","action":"element:setText","params":{"elementId":"2","text":"u3#gmail.com","replace":false}}
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: setText
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Using element passed in: 2
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Attempting to clear using UiObject.clearText().
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {"status":7,"value":"UiSelector[CLASS=android.view.View, INSTANCE=5]"}
[debug] [AndroidBootstrap] Received command result from bootstrap
[debug] [MJSONWP] Matched JSONWP error code 7 to NoSuchElementError
[debug] [W3C (235592b3)] Encountered internal error running command: NoSuchElementError: UiSelector[CLASS=android.view.View, INSTANCE=5]
Ecllipse Console Error:
[RemoteTestNG] detected TestNG version 6.14.2
Jun 05, 2019 1:03:25 PM io.appium.java_client.remote.AppiumCommandExecutor$1 lambda$0
INFO: Detected dialect: W3C
Landed Login page
FAILED CONFIGURATION: #BeforeClass setUp
org.openqa.selenium.NoSuchElementException:
UiSelector[CLASS=android.view.View, INSTANCE=5]
For documentation on this error, please visit:
http://seleniumhq.org/exceptions/no_such_element.html
Although you're following like selenium sendKeys to enter text in input fields, sometimes appium does not work as it.
So first click on input field and then enter value using sendKeys as mentioned in below snippet.
driver.findElement(By.id("#loc")).click();
driver.findElement(By.id("#loc")).sendKeys("text);
Let me know if you still face any issue.
Can anyone help me out I am new to Android testing with Appium , I am trying to open app in AVD the app getting installed but then m getting Error "A new Session could not be created.(Original error: Command failed: )","killed":false,"code":1,"signal":null,"origValue":"Command failed: "},"sessionId":null}
Thanks for the help in advance
tried with just giving capabilities.setCapability("appActivity", ".MainActivity");
'''
File classpathRoot = new File(System.getProperty("user.dir"));
File appDir = new File(classpathRoot, "/Apps/src/");
File app = new File(appDir, "ChatApp-release.apk");
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(CapabilityType.BROWSER_NAME, "");
capabilities.setCapability("deviceName", "emulator-5554");
capabilities.setCapability("platformVersion", "7.1.1");
capabilities.setCapability("platformName", "Android");
capabilities.setCapability("app", app.getAbsolutePath());
capabilities.setCapability("appPackage", "com.aaa.charla");
capabilities.setCapability("appActivity", "com.aaa.xxx.MainActivity");
driver = new AndroidDriver(new URL("https://127.0.0.1:4723/wd/hub"), capabilities);
driver.manage().timeouts().implicitlyWait(80, TimeUnit.SECONDS);
Thread.sleep(10000);
driver.quit();
Following are the Debug log:
info: Console LogLevel: debug
info: --> POST /wd/hub/session {"desiredCapabilities":{"app":"D:\AndroidNew\Yrreport\YrReport\RemoteSystemsTempFiles\Appium\apk\ChatApp-master-0.9.35.1195-release.apk","appPackage":"com.odysseyinc.charla","appActivity":"com.odyssey.chatapp.MainActivity","newCommandTimeout":"10000","platformName":"Android","version":"7.1.1","deviceName":"emulator-5554"}}
info: Client User-Agent string: Apache-HttpClient/4.5.2 (Java/1.8.0_162)
info: [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. : version
info: [debug] Using local app from desired caps: D:\AndroidNew\Yrreport\YrReport\RemoteSystemsTempFiles\Appium\apk\ChatApp-master-0.9.35.1195-release.apk
info: [debug] Creating new appium session 0d25aeac-d055-449f-af84-b6d314d9b4a5
info: Starting android appium
info: [debug] Getting Java version
info: Java version is: 1.8.0_162
info: [debug] Checking whether adb is present
info: [debug] Using adb from C:\Users\unmesh.ghatbandhe\AppData\Local\Android\Sdk\platform-tools\adb.exe
info: [debug] Set chromedriver binary as: C:\Program Files (x86)\Appium\node_modules\appium\build\chromedriver\windows\chromedriver.exe
info: [debug] Using fast reset? true
info: [debug] Preparing device for session
info: [debug] Checking whether app is actually present
info: Retrieving device
info: [debug] Trying to find a connected android device
info: [debug] Getting connected devices...
info: [debug] executing cmd: C:\Users\unmesh.ghatbandhe\AppData\Local\Android\Sdk\platform-tools\adb.exe devices
info: [debug] 1 device(s) connected
info: Found device emulator-5554
info: [debug] Setting device id to emulator-5554
info: [debug] Waiting for device to be ready and to respond to shell commands (timeout = 5)
info: [debug] executing cmd: C:\Users\unmesh.ghatbandhe\AppData\Local\Android\Sdk\platform-tools\adb.exe -s emulator-5554 wait-for-device
info: [debug] executing cmd: C:\Users\unmesh.ghatbandhe\AppData\Local\Android\Sdk\platform-tools\adb.exe -s emulator-5554 shell "echo 'ready'"
info: [debug] Starting logcat capture
info: [debug] Getting device API level
info: [debug] executing cmd: C:\Users\unmesh.ghatbandhe\AppData\Local\Android\Sdk\platform-tools\adb.exe -s emulator-5554 shell "getprop ro.build.version.sdk"
info: [debug] Device is at API Level 25
info: Device API level is: 25
info: [debug] Extracting strings for language: default
info: [debug] executing cmd: C:\Users\unmesh.ghatbandhe\AppData\Local\Android\Sdk\platform-tools\adb.exe -s emulator-5554 shell "getprop persist.sys.language"
info: [debug] Current device persist.sys.language:
info: [debug] java -jar "C:\Program Files (x86)\Appium\node_modules\appium\node_modules\appium-adb\jars\appium_apk_tools.jar" "stringsFromApk" "D:\AndroidNew\Yrreport\YrReport\RemoteSystemsTempFiles\Appium\apk\ChatApp-master-0.9.35.1195-release.apk" "C:\Users\UNMESH~1.GHA\AppData\Local\Temp\com.odysseyinc.charla"
info: [debug] Reading strings from converted strings.json
info: [debug] Setting language to default
info: [debug] executing cmd: C:\Users\unmesh.ghatbandhe\AppData\Local\Android\Sdk\platform-tools\adb.exe -s emulator-5554 push "C:\Users\UNMESH~1.GHA\AppData\Local\Temp\com.odysseyinc.charla\strings.json" /data/local/tmp
info: [debug] Checking whether aapt is present
info: [debug] Using aapt from C:\Users\unmesh.ghatbandhe\AppData\Local\Android\Sdk\build-tools\28.0.3\aapt.exe
info: [debug] Retrieving process from manifest.
info: [debug] executing cmd: C:\Users\unmesh.ghatbandhe\AppData\Local\Android\Sdk\build-tools\28.0.3\aapt.exe dump xmltree D:\AndroidNew\Yrreport\YrReport\RemoteSystemsTempFiles\Appium\apk\ChatApp-master-0.9.35.1195-release.apk AndroidManifest.xml
info: [debug] Set app process to: com.odysseyinc.charla
info: [debug] Not uninstalling app since server not started with --full-reset
info: [debug] Checking app cert for D:\AndroidNew\Yrreport\YrReport\RemoteSystemsTempFiles\Appium\apk\ChatApp-master-0.9.35.1195-release.apk.
info: [debug] executing cmd: java -jar "C:\Program Files (x86)\Appium\node_modules\appium\node_modules\appium-adb\jars\verify.jar" D:\AndroidNew\Yrreport\YrReport\RemoteSystemsTempFiles\Appium\apk\ChatApp-master-0.9.35.1195-release.apk
info: [debug] App already signed.
info: [debug] Zip-aligning D:\AndroidNew\Yrreport\YrReport\RemoteSystemsTempFiles\Appium\apk\ChatApp-master-0.9.35.1195-release.apk
info: [debug] Checking whether zipalign is present
info: [debug] Using zipalign from C:\Users\unmesh.ghatbandhe\AppData\Local\Android\Sdk\build-tools\28.0.3\zipalign.exe
info: [debug] Zip-aligning apk.
info: [debug] executing cmd: C:\Users\unmesh.ghatbandhe\AppData\Local\Android\Sdk\build-tools\28.0.3\zipalign.exe -f 4 D:\AndroidNew\Yrreport\YrReport\RemoteSystemsTempFiles\Appium\apk\ChatApp-master-0.9.35.1195-release.apk C:\Users\UNMESH~1.GHA\AppData\Local\Temp\119427-15556-1rmbgw9\appium.tmp
info: [debug] MD5 for app is f3d7efc8b197792c3d0529a48dc92ff2
info: [debug] executing cmd: C:\Users\unmesh.ghatbandhe\AppData\Local\Android\Sdk\platform-tools\adb.exe -s emulator-5554 shell "ls /data/local/tmp/f3d7efc8b197792c3d0529a48dc92ff2.apk"
info: [debug] Getting install status for com.odysseyinc.charla
info: [debug] Getting device API level
info: [debug] executing cmd: C:\Users\unmesh.ghatbandhe\AppData\Local\Android\Sdk\platform-tools\adb.exe -s emulator-5554 shell "getprop ro.build.version.sdk"
info: [debug] Device is at API Level 25
info: [debug] executing cmd: C:\Users\unmesh.ghatbandhe\AppData\Local\Android\Sdk\platform-tools\adb.exe -s emulator-5554 shell "pm list packages -3 com.odysseyinc.charla"
info: [debug] App is installed
info: App is already installed, resetting app
info: [debug] Running fast reset (stop and clear)
info: [debug] executing cmd: C:\Users\unmesh.ghatbandhe\AppData\Local\Android\Sdk\platform-tools\adb.exe -s emulator-5554 shell "am force-stop com.odysseyinc.charla"
info: [debug] executing cmd: C:\Users\unmesh.ghatbandhe\AppData\Local\Android\Sdk\platform-tools\adb.exe -s emulator-5554 shell "pm clear com.odysseyinc.charla"
info: [debug] Forwarding system:4724 to device:4724
info: [debug] executing cmd: C:\Users\unmesh.ghatbandhe\AppData\Local\Android\Sdk\platform-tools\adb.exe -s emulator-5554 forward tcp:4724 tcp:4724
info: [debug] Pushing appium bootstrap to device...
info: [debug] executing cmd: C:\Users\unmesh.ghatbandhe\AppData\Local\Android\Sdk\platform-tools\adb.exe -s emulator-5554 push "C:\Program Files (x86)\Appium\node_modules\appium\build\android_bootstrap\AppiumBootstrap.jar" /data/local/tmp/
info: [debug] Pushing settings apk to device...
info: [debug] executing cmd: C:\Users\unmesh.ghatbandhe\AppData\Local\Android\Sdk\platform-tools\adb.exe -s emulator-5554 install "C:\Program Files (x86)\Appium\node_modules\appium\build\settings_apk\settings_apk-debug.apk"
info: [debug] Stopping logcat capture
info: [debug] Logcat terminated with code null, signal SIGTERM
info: [debug] Sent shutdown command, waiting for UiAutomator to stop...
warn: UiAutomator did not shut down fast enough, calling it gone
error: Failed to start an Appium session, err was: Error: Command failed: adb: failed to install C:\Program Files (x86)\Appium\node_modules\appium\build\settings_apk\settings_apk-debug.apk: Failure [INSTALL_FAILED_ALREADY_EXISTS: Attempt to re-install io.appium.settings without first uninstalling.]
info: [debug] Cleaning up android objects
info: [debug] Cleaning up appium session
info: [debug] Error: Command failed: adb: failed to install C:\Program Files (x86)\Appium\node_modules\appium\build\settings_apk\settings_apk-debug.apk: Failure [INSTALL_FAILED_ALREADY_EXISTS: Attempt to re-install io.appium.settings without first uninstalling.]
at ChildProcess.exithandler (child_process.js:637:15)
at ChildProcess.EventEmitter.emit (events.js:98:17)
at maybeClose (child_process.js:743:16)
at Process.ChildProcess._handle.onexit (child_process.js:810:5)
info: [debug] Responding to client with error: {"status":33,"value":{"message":"A new session could not be created. (Original error: Command failed: adb: failed to install C:\Program Files (x86)\Appium\node_modules\appium\build\settings_apk\settings_apk-debug.apk: Failure [INSTALL_FAILED_ALREADY_EXISTS: Attempt to re-install io.appium.settings without first uninstalling.]\r\n)","killed":false,"code":1,"signal":null,"origValue":"Command failed: adb: failed to install C:\Program Files (x86)\Appium\node_modules\appium\build\settings_apk\settings_apk-debug.apk: Failure [INSTALL_FAILED_ALREADY_EXISTS: Attempt to re-install io.appium.settings without first uninstalling.]\r\n"},"sessionId":null}
info: <-- POST /wd/hub/session 500 32039.992 ms - 664
`
You need to share the full appium logs in order to know the reason for that.
[After checking the logs]
That's a known issue for that specific Android image as it installs 2 versions of appium settings app and unlock app. What you can do is either change the android image you are testing against or uninstall those 2 apps before starting your script.
You can uninstall them manually by starting the emulator GUI and do that with the mouse or through the below commands:
adb -s device_serial uninstall io.appium.settings
adb -s device_serial uninstall io.appium.unlock
Also, you can add those commands in your code if you really have to execute the tests on android 7 devices as below:
String androidVersion=executeCommand("adb shell getprop ro.build.version.release");
if(androidVersion.contains("7"))
{
//uninstall appium settings app
cmd="adb uninstall io.appium.settings";
executeCommand(cmd);
//uninstall appium unlock app
cmd="adb uninstall io.appium.unlock";
executeCommand(cmd);
}
I have upgraded the Appuim 1.4 to 1.9 and started working as Expected .
When android driver finding some element, appium frozen ([AndroidBootstrap] Sending command to android) and will die after some time. This happens only on one computer (Mac) and only on android.
At last appium sending this:
[Appium] New AndroidDriver session created successfully, session 7de5c8a9-3d5e-49dc-b228-3b76f0cf5f1d added to master session list
[debug] [MJSONWP] Responding to client with driver.createSession() result: {"platform":"LINUX","webStorageEnabled":false,"takesScreenshot":true,"javascriptEnabled":true,"databaseEnabled":false,"networkConnectionEnabled":true,"locationContextEnabled":false,"warnings":{},"desired":{"app":"/Users/jenkins/.jenkins/jobs/Android5-test-ReleaseIntegtationTests-Demo/workspace/test-Integration-Tests/src/test/resources/testDemo-debug.apk","noReset":true,"newCommandTimeout":88,"udid":"018433348882859","platformName":"Android","deviceName":"Android","fullReset":false},"app":"/Users/jenkins/.jenkins/jobs/Android5-test-ReleaseIntegtationTests-Demo/workspace/test-Integration-Tests/src/test/resources/testDemo-debug.apk","noReset":true,"newCommandTimeout":88,"udid":"018433348882859","platformName":"Android","deviceName":"018433348882859","fullReset":false,"deviceUDID":"018433348882859","platformVersion":"5.1.1","appPackage":"com.my.testApp","appWaitPackage":"com.my.testApp","appActivity":"com.my.testApp.MainActivity","appWaitActivity":"com.my.targetDem...
[HTTP] <-- POST /wd/hub/session 200 6192 ms - 1112
[HTTP] --> GET /wd/hub/session/7de5c8a9-3d5e-49dc-b228-3b76f0cf5f1d {}
[debug] [MJSONWP] Calling AppiumDriver.getSession() with args: ["7de5c8a9-3d5e-49dc-b228-3b76f0cf5f1d"]
[debug] [MJSONWP] Responding to client with driver.getSession() result: {"platform":"LINUX","webStorageEnabled":false,"takesScreenshot":true,"javascriptEnabled":true,"databaseEnabled":false,"networkConnectionEnabled":true,"locationContextEnabled":false,"warnings":{},"desired":{"app":"/Users/jenkins/.jenkins/jobs/Android5-test-ReleaseIntegtationTests-Demo/workspace/test-Integration-Tests/src/test/resources/testDemo-debug.apk","noReset":true,"newCommandTimeout":88,"udid":"018433348882859","platformName":"Android","deviceName":"Android","fullReset":false},"app":"/Users/jenkins/.jenkins/jobs/Android5-test-ReleaseIntegtationTests-Demo/workspace/test-Integration-Tests/src/test/resources/testDemo-debug.apk","noReset":true,"newCommandTimeout":88,"udid":"018433348882859","platformName":"Android","deviceName":"018433348882859","fullReset":false,"deviceUDID":"018433348882859","platformVersion":"5.1.1","appPackage":"com.my.testApp","appWaitPackage":"com.my.testApp","appActivity":"com.my.testApp.MainActivity","appWaitActivity":"com.my.targetDem...
[HTTP] <-- GET /wd/hub/session/7de5c8a9-3d5e-49dc-b228-3b76f0cf5f1d 200 5 ms - 1112
[HTTP] --> GET /wd/hub/session/7de5c8a9-3d5e-49dc-b228-3b76f0cf5f1d {}
[debug] [MJSONWP] Calling AppiumDriver.getSession() with args: ["7de5c8a9-3d5e-49dc-b228-3b76f0cf5f1d"]
[debug] [MJSONWP] Responding to client with driver.getSession() result: {"platform":"LINUX","webStorageEnabled":false,"takesScreenshot":true,"javascriptEnabled":true,"databaseEnabled":false,"networkConnectionEnabled":true,"locationContextEnabled":false,"warnings":{},"desired":{"app":"/Users/jenkins/.jenkins/jobs/Android5-test-ReleaseIntegtationTests-Demo/workspace/test-Integration-Tests/src/test/resources/testDemo-debug.apk","noReset":true,"newCommandTimeout":88,"udid":"018433348882859","platformName":"Android","deviceName":"Android","fullReset":false},"app":"/Users/jenkins/.jenkins/jobs/Android5-test-ReleaseIntegtationTests-Demo/workspace/test-Integration-Tests/src/test/resources/testDemo-debug.apk","noReset":true,"newCommandTimeout":88,"udid":"018433348882859","platformName":"Android","deviceName":"018433348882859","fullReset":false,"deviceUDID":"018433348882859","platformVersion":"5.1.1","appPackage":"com.my.testApp","appWaitPackage":"com.my.testApp","appActivity":"com.my.testApp.MainActivity","appWaitActivity":"com.my.targetDem...
[HTTP] <-- GET /wd/hub/session/7de5c8a9-3d5e-49dc-b228-3b76f0cf5f1d 200 3 ms - 1112
[HTTP] --> POST /wd/hub/session/7de5c8a9-3d5e-49dc-b228-3b76f0cf5f1d/timeouts {"type":"implicit","ms":10000}
[debug] [MJSONWP] Calling AppiumDriver.timeouts() with args: ["implicit",10000,"7de5c8a9-3d5e-49dc-b228-3b76f0cf5f1d"]
[debug] [BaseDriver] Set implicit wait to 10000ms
[debug] [MJSONWP] Responding to client with driver.timeouts() result: null
[HTTP] <-- POST /wd/hub/session/7de5c8a9-3d5e-49dc-b228-3b76f0cf5f1d/timeouts 200 3 ms - 76
[HTTP] --> POST /wd/hub/session/7de5c8a9-3d5e-49dc-b228-3b76f0cf5f1d/timeouts {"type":"implicit","ms":1000}
[debug] [MJSONWP] Calling AppiumDriver.timeouts() with args: ["implicit",1000,"7de5c8a9-3d5e-49dc-b228-3b76f0cf5f1d"]
[debug] [BaseDriver] Set implicit wait to 1000ms
[debug] [MJSONWP] Responding to client with driver.timeouts() result: null
[HTTP] <-- POST /wd/hub/session/7de5c8a9-3d5e-49dc-b228-3b76f0cf5f1d/timeouts 200 3 ms - 76
[HTTP] --> POST /wd/hub/session/7de5c8a9-3d5e-49dc-b228-3b76f0cf5f1d/elements {"using":"id","value":"com.my.testApp:id/card_view"}
[debug] [MJSONWP] Calling AppiumDriver.findElements() with args: ["id","com.my.testApp:id/card_view","7de5c8a9-3d5e-49dc-b228-3b76f0cf5f1d"]
[debug] [BaseDriver] Valid locator strategies for this request: xpath, id, class name, accessibility id, -android uiautomator
[debug] [BaseDriver] Valid locator strategies for this request: xpath, id, class name, accessibility id, -android uiautomator
[debug] [BaseDriver] Waiting up to 1000 ms for condition
[debug] [AndroidBootstrap] Sending command to android: {"cmd":"action","action":"find","params":{"strategy":"id","selector":"com.my.testApp:id/card_view","context":"","multiple":true}}
Appium: 1.6.1
io.appium:java-client:5.0.0-BETA3
ADB: 1.0.36
Appium Capabilities:
File appDir = new File(System.getProperty("user.dir") + properties.getProperty("appDir"));
File app = new File(appDir, System.getProperty("appName"));
capabilities.setCapability(MobileCapabilityType.APP, app.getAbsolutePath());
capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, System.getProperty("platform"));
capabilities.setCapability(MobileCapabilityType.UDID, System.getProperty("udid"));
capabilities.setCapability(MobileCapabilityType.NO_RESET, true);
capabilities.setCapability(MobileCapabilityType.FULL_RESET, false);
capabilities.setCapability(MobileCapabilityType.NEW_COMMAND_TIMEOUT, 88);
androidDriver = new AndroidDriver(new URL(System.getProperty("appiumUrl")), capabilities);
androidDriver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
Any ideas?
Reinstalling appium 1.6.1 not helped me.
But I resolved my issue after downgrade appium to 1.5.3 and upgrade back to 1.6.1.
Apparently version 1.5.3 pulled up the missing libraries. But why 1.6.1 didn't do it I don't know.
Appium session, could not find a connected Android device. Shows error in eclipse
If any one know how to fix please let me know.
**The Junit code: - **
import static org.junit.Assert.*;
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import org.junit.Test;
import org.openqa.selenium.remote.DesiredCapabilities;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.remote.MobileCapabilityType;
import io.appium.java_client.remote.MobilePlatform;
public class desiredCapab {
#Test
public void test() throws MalformedURLException {
File appDir = new File("C:\\Eclipse-Neon\\Project\\AppiumT\\Apk\\");
File app = new File (appDir, "WhatsApp.apk");
DesiredCapabilities cap = new DesiredCapabilities();
cap.setCapability(MobileCapabilityType.PLATFORM_NAME,MobilePlatform.ANDROID);
cap.setCapability(MobileCapabilityType.DEVICE_NAME, "Android Emulator");
cap.setCapability(MobileCapabilityType.APP, app.getAbsolutePath());
AndroidDriver driver = new AndroidDriver(new URL ("http://127.0.0.1:4723/wd/hub"), cap);
//{"address":"127.0.0.1","logNoColors":true,"platformName":"Android","platformVersion":"23","automationName":"Appium"}
}
}
Eclipse Junit Error :-
org.openqa.selenium.SessionNotCreatedException: A new session could not be created. (Original error: Could not find a connected Android device.) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 28.61 seconds
Build info: version: '2.49.0', revision: '365eeb4', time: '2016-01-13 18:33:29'
System info: host: 'DESKTOP-PC1SJR4', ip: '192.168.1.104', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_91'
AVD manager setting: - Image
Appium :- Error message
> info: --> POST /wd/hub/session {"desiredCapabilities":{"app":"C:\\Eclipse-Neon\\Project\\AppiumT\\Apk\\WhatsApp.apk","platformName":"Android","deviceName":"Android Emulator"}}
> info: Client User-Agent string: Apache-HttpClient/4.5.1 (Java/1.8.0_91)
> info: [debug] No appActivity desired capability or server param. Parsing from apk.
> info: [debug] No appPackage desired capability or server param. Parsing from apk.
> info: [debug] Using local app from desired caps: C:\Eclipse-Neon\Project\AppiumT\Apk\WhatsApp.apk
> info: [debug] Creating new appium session c9232f90-f519-4058-9e80-22cd2830de57
> info: Starting android appium
> info: [debug] Getting Java version
> info: Java version is: 1.8.0_101
> info: [debug] Checking whether adb is present
> info: [debug] Using adb from C:\Users\bizBoxChat\AppData\Local\Android\sdk\platform-tools\adb.exe
> info: [debug] Parsing package and activity from app manifest
> info: [debug] Checking whether aapt is present
> info: [debug] Using aapt from C:\Users\bizBoxChat\AppData\Local\Android\sdk\build-tools\24.0.3\aapt.exe
> info: [debug] Extracting package and launch activity from manifest.
> info: [debug] executing cmd: C:\Users\bizBoxChat\AppData\Local\Android\sdk\build-tools\24.0.3\aapt.exe dump badging C:\Eclipse-Neon\Project\AppiumT\Apk\WhatsApp.apk
> info: [debug] badging package: com.whatsapp
> info: [debug] badging act: com.whatsapp.Main
> info: [debug] Parsed package and activity are: com.whatsapp/com.whatsapp.Main
> info: [debug] Using fast reset? true
> info: [debug] Preparing device for session
> info: [debug] Checking whether app is actually present
> info: Retrieving device
> info: [debug] Trying to find a connected android device
> info: [debug] Getting connected devices...
> info: [debug] executing cmd: C:\Users\bizBoxChat\AppData\Local\Android\sdk\platform-tools\adb.exe devices
> info: [debug] 0 device(s) connected
> info: [debug] Could not find devices, restarting adb server...
> info: [debug] executing cmd: C:\Users\bizBoxChat\AppData\Local\Android\sdk\platform-tools\adb.exe kill-server
> info: [debug] Getting connected devices...
> info: [debug] executing cmd: C:\Users\bizBoxChat\AppData\Local\Android\sdk\platform-tools\adb.exe devices
> info: [debug] 0 device(s) connected
> info: [debug] Could not find devices, restarting adb server...
> info: [debug] executing cmd: C:\Users\bizBoxChat\AppData\Local\Android\sdk\platform-tools\adb.exe kill-server
> info: [debug] Getting connected devices...
> info: [debug] executing cmd: C:\Users\bizBoxChat\AppData\Local\Android\sdk\platform-tools\adb.exe devices
> info: [debug] 0 device(s) connected
> info: [debug] Could not find devices, restarting adb server...
> info: [debug] executing cmd: C:\Users\bizBoxChat\AppData\Local\Android\sdk\platform-tools\adb.exe kill-server
> info: [debug] Getting connected devices...
> info: [debug] executing cmd: C:\Users\bizBoxChat\AppData\Local\Android\sdk\platform-tools\adb.exe devices
> info: [debug] 0 device(s) connected
> info: [debug] Could not find devices, restarting adb server...
> info: [debug] executing cmd: C:\Users\bizBoxChat\AppData\Local\Android\sdk\platform-tools\adb.exe kill-server
> info: [debug] Getting connected devices...
> info: [debug] executing cmd: C:\Users\bizBoxChat\AppData\Local\Android\sdk\platform-tools\adb.exe devices
> info: [debug] 0 device(s) connected
> info: [debug] Sent shutdown command, waiting for UiAutomator to stop...
> warn: UiAutomator did not shut down fast enough, calling it gone
> info: [debug] Cleaning up android objects
> info: [debug] Cleaning up appium session
> error: Failed to start an Appium session, err was: Error: Could not find a connected Android device.
> info: [debug] Error: Could not find a connected Android device.
> at [object Object].ADB.getDevicesWithRetry (C:\Program Files (x86)\Appium\node_modules\appium\node_modules\appium-adb\lib\adb.js:606:15)
> at [object Object].androidCommon.prepareActiveDevice (C:\Program Files (x86)\Appium\node_modules\appium\lib\devices\android\android-common.js:400:12)
> at [object Object].<anonymous> (C:\Program Files (x86)\Appium\node_modules\appium\lib\devices\android\android-common.js:326:26)
> at C:\Program Files (x86)\Appium\node_modules\appium\node_modules\async\lib\async.js:607:21
> at C:\Program Files (x86)\Appium\node_modules\appium\node_modules\async\lib\async.js:246:17
> at iterate (C:\Program Files (x86)\Appium\node_modules\appium\node_modules\async\lib\async.js:146:13)
> at C:\Program Files (x86)\Appium\node_modules\appium\node_modules\async\lib\async.js:157:25
> at C:\Program Files (x86)\Appium\node_modules\appium\node_modules\async\lib\async.js:248:21
> at C:\Program Files (x86)\Appium\node_modules\appium\node_modules\async\lib\async.js:612:34
> at [object Object].androidCommon.ensureDeviceLocale (C:\Program Files (x86)\Appium\node_modules\appium\lib\devices\android\android-common.js:371:45)
> at [object Object].androidCommon.prepareEmulator (C:\Program Files (x86)\Appium\node_modules\appium\lib\devices\android\android-common.js:364:10)
> at [object Object].<anonymous> (C:\Program Files (x86)\Appium\node_modules\appium\lib\devices\android\android-common.js:325:26)
> at C:\Program Files (x86)\Appium\node_modules\appium\node_modules\async\lib\async.js:607:21
> at C:\Program Files (x86)\Appium\node_modules\appium\node_modules\async\lib\async.js:246:17
> at iterate (C:\Program Files (x86)\Appium\node_modules\appium\node_modules\async\lib\async.js:146:13)
> at C:\Program Files (x86)\Appium\node_modules\appium\node_modules\async\lib\async.js:157:25
> at C:\Program Files (x86)\Appium\node_modules\appium\node_modules\async\lib\async.js:248:21
> at C:\Program Files (x86)\Appium\node_modules\appium\node_modules\async\lib\async.js:612:34
> at [object Object].<anonymous> (C:\Program Files (x86)\Appium\node_modules\appium\lib\devices\android\android-common.js:344:9)
> at FSReqWrap.oncomplete (fs.js:95:15)
> info: [debug] Responding to client with error: {"status":33,"value":{"message":"A new session could not be created. (Original error: Could not find a connected Android device.)","origValue":"Could not find a connected Android device."},"sessionId":null}
> info: <-- POST /wd/hub/session 500 28492.200 ms - 206
Reason of above error is, any device or AVD could not be found to be connected. Following lines in your error message show this:
> info: [debug] Trying to find a connected android device
> info: [debug] Getting connected devices...
> info: [debug] executing cmd: C:\Users\bizBoxChat\AppData\Local\Android\sdk\platform-tools\adb.exe devices
> info: [debug] 0 device(s) connected
> info: [debug] Could not find devices, restarting adb server...
> info: [debug] Error: Could not find a connected Android device.
Just creating AVD in AVD manager is not sufficient. It has to be up and running (started and ready). To do that, select any AVD in your AVD manager, and click on "Start" button. Let the AVD boot. Wait. (It is similar to a real device switching on.)
Or, some real device needs to be connected. In that device, "Developer Options" should be On. "USB debugging" should be On.
Go to command prompt and run following command:
adb devices
Expected output: Some device or AVD should be shown as connected.
Once you see any device or AVD connected, and retry, then your problem will be solved.
Note:
On running "adb devices" command in command window, if you see message like "abd.exe is an unrecognized internal or external command or batch file...", then you need to have adb.exe in path. You can add its path in environment variables, or simply run following command before running "adb devices":
set path=%PATH%;"D:\AndroidSDK\platform-tools"
Note that adb.exe file is in platform-tools folder on my PC, in Android SDK folder. You will need to modify this path as it is on your PC.
Try to use real device, since emulators are very slow and booting time will also take more time. Even real device also I was facing this kind of issue,
Expecting causes :
Android emulator startup issue
ADB issue
System config
If adb issue, you need run following command in your cmd:
adb kill-server
adb start-server
Then you try with Android emulator and make ensure you system has enough memory these emulator like VM this will CPU & memory of your system accountable amount.
I am trying to solve this with xpath but I am open to another solution.
On different phones the document is created differently. Inside the LinearLayout the child is a Button on Samsung and TextView on LG.
I wanted to know if there is a easy way to get one or the other.
I tried to do this using xpath to check for the Button. If it exists then its for the samsung and click it. The problem is that Appium just hangs trying to find the Button. I figured it would look and move on.
I can setup the code to get the parent and then find by class the child and take the second index but I am wondering if there is a better way.
Is there any way to do the xpath to process the child without specifying its name/type?
By.xpath("//android.widget.LinearLayout[#index='0'][1]")
Here is the current code:
if (!StringUtility.isEmptyString(driver.findElement(By.xpath("//android.widget.Button[#index='0']")).getAttribute("name"))) {
driver.findElement(By.xpath("//android.widget.Button[#index='0']")).click();
} else { // LG or Other
driver.findElement(By.xpath("//android.widget.TextView[#index='0']")).click();
}
Appium log:
> info: [debug] Pushing command to appium work queue: ["find",{"strategy":"xpath","selector":"//android.widget.Button[#index='0']","context":"","multiple":false}]
> info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"xpath","selector":"//android.widget.Button[#index='0']","context":"","multiple":false}}
> info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
> info: [debug] [BOOTSTRAP] [debug] Got command action: find
> info: [debug] [BOOTSTRAP] [debug] Finding //android.widget.Button[#index='0'] using XPATH with the contextId: multiple: false
> info: [debug] [BOOTSTRAP] [debug] Returning result: {"status":7,"value":"Could not find an element using supplied strategy. "}
> info: [debug] Waited for 10987ms so far
You can create the xpath dynamically using the Capabilities
if(capabilities.getCapability("deviceName")).equals("Samsung")
xpath = "//android.widget.Button[#index='0']"
else
xpath = "//android.widget.TextView[#index='0']"
driver.findElement(By.xpath(xpath)).click();