Unable to removeapp by using appium - getting an exception - appium

I've tried
driver.removeApp("com.my.app");
but getting an exception :
Exception in thread "main" org.openqa.selenium.WebDriverException: undefined status object (WARNING: The server did not provide any stacktrace information)
and the appium log :
info: --> POST /wd/hub/session/71a4c5ca-92b5-4e94-99f5-f8a795671d82/appium/device/remove_app {"bundleId":"com.my.app"}
info: [debug] Responding to client with error: {"status":1,"value":{"message":"undefined status object"},"sessionId":"71a4c5ca-92b5-4e94-99f5-f8a795671d82"}
info: <-- POST /wd/hub/session/71a4c5ca-92b5-4e94-99f5-f8a795671d82/appium/device/remove_app 500 1.802 ms - 109
any idea why it doesn't work ?
thanks

Related

NullPointerException when using AndroidDriver and calling WebDriverWait

My code below tries to wait until our native app loads. But it receives NPE:
RemoteWebDriver driver =
new AndroidDriver<MobileElement>//this gets NPE below
//new RemoteWebDriver //this works!!
(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
new WebDriverWait(driver, 30).until(
ExpectedConditions.presenceOfElementLocated(
By.xpath("//*[contains(#text, 'Tan')]")));
When I replace AndroidDriver with RemoteDriver, everything works as expected! Our app launches and our test code waits until the app loads. The problem is, we cannot use mobile device specific API using RemoteDriver.
Appium GUI v1.4.16.1 (Ophiuchus). Please tell if any other version info is needed, as I'm not good at npm etc. But I downloaded all of the stuff last week.
Here is the stack trace:
java.lang.NullPointerException
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:152)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:636)
at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:40)
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.findElement(RemoteWebDriver.java:369)
at io.appium.java_client.DefaultGenericMobileDriver.findElement(DefaultGenericMobileDriver.java:56)
at io.appium.java_client.AppiumDriver.findElement(AppiumDriver.java:1)
at io.appium.java_client.android.AndroidDriver.findElement(AndroidDriver.java:1)
at org.openqa.selenium.remote.RemoteWebDriver.findElementByXPath(RemoteWebDriver.java:474)
at io.appium.java_client.DefaultGenericMobileDriver.findElementByXPath(DefaultGenericMobileDriver.java:134)
at io.appium.java_client.AppiumDriver.findElementByXPath(AppiumDriver.java:1)
at io.appium.java_client.android.AndroidDriver.findElementByXPath(AndroidDriver.java:1)
at org.openqa.selenium.By$ByXPath.findElement(By.java:361)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:361)
at io.appium.java_client.DefaultGenericMobileDriver.findElement(DefaultGenericMobileDriver.java:52)
at io.appium.java_client.AppiumDriver.findElement(AppiumDriver.java:1)
at io.appium.java_client.android.AndroidDriver.findElement(AndroidDriver.java:1)
at org.openqa.selenium.support.ui.ExpectedConditions.findElement(ExpectedConditions.java:895)
at org.openqa.selenium.support.ui.ExpectedConditions.access$000(ExpectedConditions.java:41)
at org.openqa.selenium.support.ui.ExpectedConditions$6.apply(ExpectedConditions.java:181)
at org.openqa.selenium.support.ui.ExpectedConditions$6.apply(ExpectedConditions.java:178)
at org.openqa.selenium.support.ui.FluentWait.until(FluentWait.java:238)
Here is what I see on Appium GUI:
> info: [debug] Appium session started with sessionId 4153c447-cfba-45db-a23a-1e603a3e0e7c
> info: <-- POST /wd/hub/session 303 17598.310 ms - 74
> info: --> GET /wd/hub/session/4153c447-cfba-45db-a23a-1e603a3e0e7c {}
> info: [debug] Responding to client with success: {"status":0,"value":{"platform":"LINUX","browserName":"Android","platformVersion":"4.4.2","webStorageEnabled":false,"takesScreenshot":true,"javascriptEnabled":true,"databaseEnabled":false,"networkConnectionEnabled":true,"locationContextEnabled":false,"warnings":{},"desired":{"app":"C:\\Temp\\appium\\akbank-release.apk","appActivity":"com.akbank.akbankdirekt.ui.prelogin.SplashActivity","platformName":"Android","deviceName":"OJOBUCIBGEKNTKYS"},"app":"C:\\Temp\\appium\\akbank-release.apk","appActivity":"com.akbank.akbankdirekt.ui.prelogin.SplashActivity","platformName":"Android","deviceName":"OJOBUCIBGEKNTKYS"},"sessionId":"4153c447-cfba-45db-a23a-1e603a3e0e7c"}
> info: <-- GET /wd/hub/session/4153c447-cfba-45db-a23a-1e603a3e0e7c 200 4.362 ms - 667 {"status":0,"value":{"platform":"LINUX","browserName":"Android","platformVersion":"4.4.2","webStorageEnabled":false,"takesScreenshot":true,"javascriptEnabled":true,"databaseEnabled":false,"networkConnectionEnabled":true,"locationContextEnabled":false,"warnings":{},"desired":{"app":"C:\\Temp\\appium\\akbank-release.apk","appActivity":"com.akbank.akbankdirekt.ui.prelogin.SplashActivity","platformName":"Android","deviceName":"OJOBUCIBGEKNTKYS"},"app":"C:\\Temp\\appium\\akbank-release.apk","appActivity":"com.akbank.akbankdirekt.ui.prelogin.SplashActivity","platformName":"Android","deviceName":"OJOBUCIBGEKNTKYS"},"sessionId":"4153c447-cfba-45db-a23a-1e603a3e0e7c"}
> info: --> POST /wd/hub/session/4153c447-cfba-45db-a23a-1e603a3e0e7c/element {"using":"xpath","value":"//*[contains(#text, 'Tan')]"}
> info: [debug] Waiting up to 0ms for condition
> info: [debug] Pushing command to appium work queue: ["find",{"strategy":"xpath","selector":"//*[contains(#text, 'Tan')]","context":"","multiple":false}]
> info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"xpath","selector":"//*[contains(#text, 'Tan')]","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 //*[contains(#text, 'Tan')] using XPATH with the contextId: multiple: false
> info: [debug] [BOOTSTRAP] [debug] Returning result: {"value":"Could not find an element using supplied strategy. ","status":7}
> info: [debug] Condition unmet after 8397ms. Timing out.
> info: [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":"Could not find an element using supplied strategy. "},"sessionId":"4153c447-cfba-45db-a23a-1e603a3e0e7c"}
> info: <-- POST /wd/hub/session/4153c447-cfba-45db-a23a-1e603a3e0e7c/element 500 8402.114 ms - 230
I've put a sleep before wait and now I don't get NPE:
RemoteWebDriver driver =
new AndroidDriver<MobileElement>//this gets NPE below
//new RemoteWebDriver //this works!!
(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
Thread.sleep(15000);
new WebDriverWait(driver, 30).until(
ExpectedConditions.presenceOfElementLocated(
By.xpath("//*[contains(#text, 'Tan')]")));
NPE was thrown as soon as the app was first loaded. I think this is an internal Appium problem.

Responding to client with error "An unknown server-side error occurred while processing the command"

Can anyone explain what is the error in this????
Responding to client with error: {"status":13,"value":{"message":"An unknown server-side error occurred while processing the command.","origValue":"Coordinate [x=800.0, y=619.0] is outside of element rect: [0,0][800,1205]"},"sessionId":"d19ce74a-bc57-4b86-bac4-0a63c9471c0b"}
info: <-- POST /wd/hub/session/d19ce74a-bc57-4b86-bac4-0a63c9471c0b/touch/perform 500 16.024 ms - 242
info: [debug] [BOOTSTRAP] [debug] Display bounds: [0,0][800,1205]
info: [debug] [BOOTSTRAP] [debug] Returning result: {"status":13,"value":"Coordinate [x=800.0, y=619.0] is outside of element rect: [0,0][800,1205]"}

Appium server throwing Unhandled error: Error: connect ECONNREFUSED

I'm using appium 1.4. Just before client connection to appium server, an appium server socket is created on port 4274. But when client is trying to connect it gets the following exception:
2015-06-03 08:52:32:541 - info: [debug] [BOOTSTRAP] [debug] Socket opened on port 4724
2015-06-03 08:52:32:554 - info: [debug] [BOOTSTRAP] [debug] Appium Socket Server Ready
2015-06-03 08:52:32:555 - info: [debug] [BOOTSTRAP] [debug] Loading json...
2015-06-03 08:52:32:555 - info: [debug] [BOOTSTRAP] [debug] Registered crash watchers.
2015-06-03 08:52:33:552 - error: Unhandled error: Error: connect ECONNREFUSED
at errnoException (net.js:904:11)
at Object.afterConnect [as oncomplete] (net.js:895:19) context: [POST /wd/hub/session {"desiredCapabilities":{"automationName":"Appium","platformVersion":"Nokia X software platform 1.1","deviceName":"Nokia XL Dual SIM","platformName":"Android","browserName":"Browser"}}]
But, there is no server socket created on port 4274 on host where appium is running.
Could someone suggest me what went wrong and how to resolve this issue ?

Getting errors in sendkeys command in appium (v.1.2.0) under selendroid mode (Real Device < 17 )

I just updated Appium 1.1.0 to 1.2.0, With previous version automation worked fine. But surprisingly when i update Appium i got below errors in sendkeys.
Appium Logs:
info: <-- POST /wd/hub/session/892ef5c3-267a-f50d-e28b-9b26a9ccd785/element 200 70.640 ms - 122
info: --> POST /wd/hub/session/892ef5c3-267a-f50d-e28b-9b26a9ccd785/element/d764396c-6598-5920-d8c1-85ee7c2f44e5/value {"id":"d764396c-6598-5920-d8c1-85ee7c2f44e5","value":["abc"]}
debug: Appium request initiated at /wd/hub/session/892ef5c3-267a-f50d-e28b-9b26a9ccd785/element/d764396c-6598-5920-d8c1-85ee7c2f44e5/value
debug: Request received with params: {"id":"d764396c-6598-5920-d8c1-85ee7c2f44e5","value":["abc"]}
debug: Setting text on element 'd764396c-6598-5920-d8c1-85ee7c2f44e5': 'abc'
debug: Making http request with opts: {"url":"http://localhost:8080/wd/hub/session/892ef5c3-267a-f50d-e28b-9b26a9ccd785/element/d764396c-6598-5920-d8c1-85ee7c2f44e5/value","method":"POST","json":{"value":["abc"]}}
**debug: Responding to client with error: {"status":13,"value":{"message":"An unknown server-side error occurred while processing the command. (Original error: connect ECONNREFUSED)","code":"ECONNREFUSED","errno":"ECONNREFUSED","syscall":"connect","origValue":"connect ECONNREFUSED"},"sessionId":"892ef5c3-267a-f50d-e28b-9b26a9ccd785"}**
info: <-- POST /wd/hub/session/892ef5c3-267a-f50d-e28b-9b26a9ccd785/element/d764396c-6598-5920-d8c1-85ee7c2f44e5/value 500 7.627 ms - 293
info: --> DELETE /wd/hub/session/892ef5c3-267a-f50d-e28b-9b26a9ccd785 {}
Driver info: test.utils.SwipeableWebDriver
Capabilities [{automationName=selendroid, platformVersion=16, platform=ANDROID, acceptSslCerts=true, javascriptEnabled=true, platformName=android, handlesAlerts=true, browserName=selendroid, networkConnectionEnabled=true, rotatable=true, takesScreenshot=true, version=0.10.0}]
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:204)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:156)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:599)
at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:84)
at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:268)
at org.openqa.selenium.remote.RemoteWebElement.sendKeys(RemoteWebElement.java:89)
at test.screens.SignUpPage.fillPassword(SignUpPage.java:37)
at test.utils.Functions.UserLogin(Functions.java:98)
at test.LaunchTest.testLogin(EnigmaLaunchTest.java:121)
Thanks,
Priyank Shah
I was having a similar error message and the problem was solved by changing the none default Selendroid port number to the default 8080. Try that and see what happens...

Appium scripts do not work after switch to WebView

I tried to run test cases in hybrid app.
I can switch to WebView with using driver.context("WEBVIEW").
But after I switch to webview, driver.findElement() method to do not perform under webview, and it returns the error in the Appium server as below. Could you help me how to solve this?
Below are my test scripts:
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(CapabilityType.BROWSER_NAME, "");
capabilities.setCapability("deviceName","066e28s70b115a3b");
capabilities.setCapability("platformVersion", "4.4.2");
capabilities.setCapability("platformName","Android");
capabilities.setCapability("app", "/Users/lin/codes/tester.apk");
capabilities.setCapability("app-package", "com.test.tester");
capabilities.setCapability("app-activity", "com.test.tester.myActivity");
AppiumDriver driver = new AppiumDriver(new URL("http://my.local.address:4723/wd/hub"), capabilities);
Set<String> contextNames = driver.getContextHandles();
System.out.println(contextNames.size());
for (String contextName : contextNames) {
System.out.println(contextName);
if (contextName.contains("WEBVIEW")){
driver.context(contextName);
}
}
Thread.sleep(5000);
driver.findElement(By.xpath("//div[#class='item item-entrance']/h2[#class='grey-title mb20']")).click();
The following code doesn't not work:
driver.findElement(By.xpath("//div[#class='item item-entrance']/h2[#class='grey-title mb20']")).click();
And here is the error message from Appium server log:
info: Available contexts: NATIVE_APP,WEBVIEW_1
info: Responding to client with success: {"status":0,"value":["NATIVE_APP","WEBVIEW_1"],"sessionId":"7dd9ea41-f47c-4466-a108-21ce90284ad1"}
GET /wd/hub/session/7dd9ea41-f47c-4466-a108-21ce90284ad1/contexts 200 50ms - 124b
debug: Appium request initiated at /wd/hub/session/7dd9ea41-f47c-4466-a108-21ce90284ad1/context
debug: Request received with params: {"name":"WEBVIEW_1"}
info: Getting a list of available webviews
debug: executing: "/Users/lin/tools/android-sdk-macosx/platform-tools/adb" -s 066e28s70b115a3b shell "cat /proc/net/unix"
info: ["webview_devtools_remote_20051"]
info: Available contexts: NATIVE_APP,WEBVIEW_1
info: Connecting to chrome-backed webview
info: Creating Chrome session
info: Ensuring Chromedriver exists
info: Killing any old chromedrivers, running: ps -e | grep /Users/lin/codes/appiumGit/appium/build/chromedriver/mac/chromedriver | grep -v grep |grep -e '--port=9515$' | awk '{ print $1 }' | xargs kill -15
info: Successfully cleaned up old chromedrivers
info: Spawning chromedriver with: /Users/lin/codes/appiumGit/appium/build/chromedriver/mac/chromedriver
info: [CHROMEDRIVER] Starting ChromeDriver (v2.10.267517) on port 9515
Only local connections are allowed.
info: Making http request with opts: {"url":"http://my.local.address:9515/wd/hub/session","method":"POST","json":{"sessionId":null,"desiredCapabilities":{"chromeOptions":{"androidPackage":"com.test.tester","androidUseRunningApp":true,"androidDeviceSerial":"066e28s70b115a3b"}}}}
info: Could not connect yet; retrying
info: Making http request with opts: {"url":"http://my.local.address:9515/wd/hub/session","method":"POST","json":{"sessionId":null,"desiredCapabilities":{"chromeOptions":{"androidPackage": "com.test.tester","androidUseRunningApp":true,"androidDeviceSerial":"066e28s70b115a3b"}}}}
info: Didn't get a new command in 60 secs, shutting down...
info: Shutting down appium session...
info: [ADB] Pressing the HOME button
debug: executing: "/Users/lingzhixiang/tools/android-sdk-macosx/platform-tools/adb" -s 066e28s70b115a3b shell "input keyevent 3"
info: Stopping logcat capture
debug: Logcat terminated with code null, signal SIGTERM
info: Cleaning up Chromedriver
info: Killing chromedriver
info: Responding to client with error: {"status":13,"value":{"message":"An unknown server-side error occurred while processing the command. (Original error: socket hang up)","code":"ECONNRESET","origValue":"socket hang up"},"sessionId":"7dd9ea41-f47c-4466-a108-21ce90284ad1"}
POST /wd/hub/session/7dd9ea41-f47c-4466-a108-21ce90284ad1/context 500 60649ms - 270b
info: Chromedriver exited with code null
info: (killed by signal SIGTERM)
info: [BOOTSTRAP] [info] Got data from client: {"cmd":"shutdown"}
info: [BOOTSTRAP] [info] Got command of type SHUTDOWN
info: [BOOTSTRAP] [info] Returning result: {"value":"OK, shutting down","status":0}
info: [BOOTSTRAP] [info] Closed client connection
BTW, I started the Appium 1.0.0 server from source (>node appium.js --no-reset).
# xlzdew Please change driver.context("WEBVIEW") to driver.context("WEBVIEW_1")
Your log said it couldn't start chrome driver on your device. So pls check the chromedriver in
/Users/lin/codes/appiumGit/appium/build/chromedriver/mac/chromedriver
is working or not, or it requires execution permission. You can test it by using some chrome driver commands.
I believe that when you're in a WebView, finding elements by xpath does not work. The only method of finding an element that I have had success with is By.CSS_SELECTOR and the elements class (.menu-item).
http://appium.io/slate/en/v1.2.0/?java#automating-hybrid-android-apps

Resources