Appium Error UI Automator - node.js

WINDOWS 7
Appium :1.4.16.1
Emulator Android from Android Virtual Device Manager
APPIUM REST RESPONSE:
Thanks for letting me know. if you think of what could be the source cause.
CODE FROM ECLIPSE:
'import org.openqa.selenium.By;
import org.openqa.selenium.chrome.ChromeDriverService;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import io.appium.java_client.MobileElement;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.ios.IOSElement;
import io.appium.java_client.remote.MobileBrowserType;
import io.appium.java_client.remote.MobileCapabilityType;
import io.appium.java_client.remote.MobilePlatform;
import org.openqa.selenium.Platform;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.BrowserType;
import java.util.concurrent.TimeUnit;
//WebDriver driver;
public class AA_Android1
#Test
public void test1() throws MalformedURLException, InterruptedException{
DesiredCapabilities capabilities = new DesiredCapabilities();
File app = new File("C:/Users/dd/Downloads/com.google.android.gm.4.5.apk");
capabilities.setCapability(MobileCapabilityType.DEVICE_NAME,"emulator- 5554");
capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, "Android");
capabilities.setCapability(MobileCapabilityType.BROWSER_NAME, "BROWSER");
capabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION, "6.0");
capabilities.setCapability("appPackage", "com.android.browser");
capabilities.setCapability("appActivity","com.android.browser.BrowserActivity");
capabilities.setCapability("browserName", MobileBrowserType.BROWSER);
WebDriver driver = new AndroidDriver<MobileElement>(new URL("http://127.0.0.1:4723/wd/hub"), capabilities );//error?
driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);'
APPIUM LOG:
'> Launching Appium server with command: C:\Appium\node.exe lib\server\main.js --address 127.0.0.1 --port 4723 --browser-name Chrome --session-override --platform-name Android --platform-version 23 --automation-name Appium --device-name "emulator-5554" --log-no-color
info: Welcome to Appium v1.4.16 (REV ae6877eff263066b26328d457bd285c0cc62430d)
info: Appium REST http interface listener started on 127.0.0.1:4723
info: [debug] Non-default server args: {"address":"127.0.0.1","sessionOverride":true,"logNoColors":true,"deviceName":"emulator-5554","platformName":"Android","platformVersion":"23","automationName":"Appium","browserName":"Chrome"}
info: Console LogLevel: debug
info: --> POST /wd/hub/session {"capabilities":{"desiredCapabilities":{"appPackage":"com.android.browser","appActivity":"com.android.browser.BrowserActivity","platformVersion":"6.0","browserName":"Browser","platformName":"Android","deviceName":"emulator-5554"},"requiredCapabilities":{}},"desiredCapabilities":{"appPackage":"com.android.browser","appActivity":"com.android.browser.BrowserActivity","platformVersion":"6.0","browserName":"Browser","platformName":"Android","deviceName":"emulator-5554"},"requiredCapabilities":{}}
info: Client User-Agent string: Apache-HttpClient/4.5.2 (Java/1.8.0_121)
info: Set mode: Proxying straight through to Chromedriver
info: [debug] Looks like we want chrome on android
info: [debug] Creating new appium session 6f152533-ef46-4327-9543-c62fb07906ad
info: [debug] Checking whether adb is present
info: [debug] Using adb from C:\Users\ddaunay\AppData\Local\Android\sdk\platform-tools\adb.exe
info: [debug] Using fast reset? true
info: [debug] Preparing device for session
info: [debug] Not checking whether app is present since we are assuming it's already on the device
info: Retrieving device
info: [debug] Trying to find a connected android device
info: [debug] Getting connected devices...
info: [debug] executing cmd: C:\Users\ddaunay\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\ddaunay\AppData\Local\Android\sdk\platform-tools\adb.exe -s emulator-5554 wait-for-device
info: [debug] executing cmd: C:\Users\ddaunay\AppData\Local\Android\sdk\platform-tools\adb.exe -s emulator-5554 shell "echo 'ready'"
info: [debug] Starting logcat capture
info: [debug] Pushing unlock helper app to device...
info: [debug] executing cmd: C:\Users\ddaunay\AppData\Local\Android\sdk\platform-tools\adb.exe -s emulator-5554 install "C:\Appium\node_modules\appium\build\unlock_apk\unlock_apk-debug.apk"
info: [debug] executing cmd: C:\Users\ddaunay\AppData\Local\Android\sdk\platform-tools\adb.exe -s emulator-5554 shell "dumpsys window"
info: [debug] Screen already unlocked, continuing.
info: [debug] Forwarding system:4724 to device:4724
info: [debug] executing cmd: C:\Users\ddaunay\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\ddaunay\AppData\Local\Android\sdk\platform-tools\adb.exe -s emulator-5554 push "C:\Appium\node_modules\appium\build\android_bootstrap\AppiumBootstrap.jar" /data/local/tmp/
info: Starting App
info: [debug] Attempting to kill all 'uiautomator' processes
info: [debug] Getting all processes with 'uiautomator'
info: [debug] executing cmd: C:\Users\ddaunay\AppData\Local\Android\sdk\platform-tools\adb.exe -s emulator-5554 shell "ps 'uiautomator'"
info: [debug] Cleaning up appium session
error: Failed to start an Appium session, err was: Error: Command failed: C:\Windows\system32\cmd.exe /s /c "C:\Users\ddaunay\AppData\Local\Android\sdk\platform-tools\adb.exe -s emulator-5554 shell "ps 'uiautomator'""
info: [debug] Error: Command failed: C:\Windows\system32\cmd.exe /s /c "C:\Users\ddaunay\AppData\Local\Android\sdk\platform-tools\adb.exe -s emulator-5554 shell "ps 'uiautomator'""
at ChildProcess.exithandler (child_process.js:751:12)
at ChildProcess.emit (events.js:110:17)
at maybeClose (child_process.js:1016:16)
at Process.ChildProcess._handle.onexit (child_process.js:1088:5)
info: [debug] Responding to client with error: {"status":33,"value":{"message":"A new session could not be created. (Original error: Command failed: C:\Windows\system32\cmd.exe /s /c \"C:\Users\ddaunay\AppData\Local\Android\sdk\platform-tools\adb.exe -s emulator-5554 shell \"ps 'uiautomator'\"\"\n)","killed":false,"code":1,"signal":null,"cmd":"C:\Windows\system32\cmd.exe /s /c \"C:\Users\ddaunay\AppData\Local\Android\sdk\platform-tools\adb.exe -s emulator-5554c\"\"","origValue":"Command failed: C:\Windows\system32\cmd.exe /s /c \"C:\Users\ddaunay\AppData\Local\Android\sdk\platform-tools\adb.exe -s emulator-5554 shell \"ps 'uiautomator'\"\"\n"},"sessionId":null}
info: <-- POST /wd/hub/session 500 10097.767 ms - 679
info: [debug] Logcat terminated with code 0, signal null'

We faced a similar issue when working with Appium 1.4.16 version, and we have searched a lot in different forums and appium related support forumns. came to know that it is an issue and they gave an alternative for users to continue to work till they fix this in next releases.
Basically we need to modify file adb.js present inside of appium folder:
C:\Program Files (x86)\Appium\node_modules\appium\node_modules\appium-adb\lib\
Drafted those details clearly # http://www.testingtools.co/appium/error-command-failed-adb-exe-s-emulator-5554-shell-ps-uiautomator
hope it helps and you will be abl

Related

Jenkins Pipeline launches Protractor Selenium server, then freezes forever

I'm trying to launch Protractor tests in a Jenkins Pipeline job.
I get a success message, but then the job hangs forever.
I'm running the build on an Ubuntu machine.
The build's logs...
[Bac à sable pipeline] Running shell script
+ sudo webdriver-manager update
[17:46:51] I/update - chromedriver: file exists /usr/lib/node_modules/protractor/node_modules/webdriver-manager/selenium/chromedriver_2.29.zip
[17:46:51] I/update - chromedriver: unzipping chromedriver_2.29.zip
[17:46:52] I/update - chromedriver: setting permissions to 0755 for /usr/lib/node_modules/protractor/node_modules/webdriver-manager/selenium/chromedriver_2.29
[17:46:52] I/update - chromedriver: chromedriver_2.29 up to date
[17:46:52] I/update - selenium standalone: file exists /usr/lib/node_modules/protractor/node_modules/webdriver-manager/selenium/selenium-server-standalone-3.4.0.jar
[17:46:52] I/update - selenium standalone: selenium-server-standalone-3.4.0.jar up to date
[17:46:53] I/update - geckodriver: file exists /usr/lib/node_modules/protractor/node_modules/webdriver-manager/selenium/geckodriver-v0.16.1.tar.gz
[17:46:53] I/update - geckodriver: unzipping geckodriver-v0.16.1.tar.gz
[17:46:53] I/update - geckodriver: setting permissions to 0755 for /usr/lib/node_modules/protractor/node_modules/webdriver-manager/selenium/geckodriver-v0.16.1
[17:46:53] I/update - geckodriver: geckodriver-v0.16.1 up to date
[Pipeline] sh
[Bac à sable pipeline] Running shell script
+ webdriver-manager start --seleniumPort 4445
[17:46:56] I/start - java -Djava.security.egd=file:///dev/./urandom -Dwebdriver.chrome.driver=/usr/lib/node_modules/protractor/node_modules/webdriver-manager/selenium/chromedriver_2.29 -Dwebdriver.gecko.driver=/usr/lib/node_modules/protractor/node_modules/webdriver-manager/selenium/geckodriver-v0.16.1 -jar /usr/lib/node_modules/protractor/node_modules/webdriver-manager/selenium/selenium-server-standalone-3.4.0.jar -port 4445
[17:46:56] I/start - seleniumProcess.pid: 20154
17:46:58.246 INFO - Selenium build info: version: '3.4.0', revision: 'unknown'
17:46:58.247 INFO - Launching a standalone Selenium Server
2017-05-22 17:46:58.383:INFO::main: Logging initialized #1398ms to org.seleniumhq.jetty9.util.log.StdErrLog
17:46:58.669 INFO - Driver provider org.openqa.selenium.ie.InternetExplorerDriver registration is skipped:
registration capabilities Capabilities [{ensureCleanSession=true, browserName=internet explorer, version=, platform=WINDOWS}] does not match the current platform LINUX
17:46:58.687 INFO - Driver provider org.openqa.selenium.edge.EdgeDriver registration is skipped:
registration capabilities Capabilities [{browserName=MicrosoftEdge, version=, platform=WINDOWS}] does not match the current platform LINUX
17:46:58.687 INFO - Driver class not found: com.opera.core.systems.OperaDriver
17:46:58.688 INFO - Driver provider com.opera.core.systems.OperaDriver registration is skipped:
Unable to create new instances on this machine.
17:46:58.688 INFO - Driver class not found: com.opera.core.systems.OperaDriver
17:46:58.691 INFO - Driver provider com.opera.core.systems.OperaDriver is not registered
17:46:58.701 INFO - Driver provider org.openqa.selenium.safari.SafariDriver registration is skipped:
registration capabilities Capabilities [{browserName=safari, version=, platform=MAC}] does not match the current platform LINUX
2017-05-22 17:46:58.964:INFO:osjs.Server:main: jetty-9.4.3.v20170317
2017-05-22 17:46:59.226:INFO:osjsh.ContextHandler:main: Started o.s.j.s.ServletContextHandler#475530b9{/,null,AVAILABLE}
2017-05-22 17:46:59.353:INFO:osjs.AbstractConnector:main: Started ServerConnector#393c0317{HTTP/1.1,[http/1.1]}{0.0.0.0:4445}
2017-05-22 17:46:59.356:INFO:osjs.Server:main: Started #2371ms
17:46:59.356 INFO - Selenium Server is up and running
EDIT:
Here are the Jenkins logs
May 23, 2017 9:10:19 AM jenkins.model.Jenkins <init>
INFO: 09:10:19.335 INFO - Started org.openqa.jetty.jetty.servlet.ServletHandler#22345313
May 23, 2017 9:10:19 AM jenkins.model.Jenkins <init>
INFO: 09:10:19.336 INFO - Started HttpContext[/wd,/wd]
May 23, 2017 9:10:19 AM jenkins.model.Jenkins <init>
INFO: 09:10:19.336 INFO - Started HttpContext[/selenium-server/driver,/selenium-server/driver]
May 23, 2017 9:10:19 AM jenkins.model.Jenkins <init>
INFO: 09:10:19.336 INFO - Started HttpContext[/,/]
May 23, 2017 9:10:19 AM jenkins.model.Jenkins <init>
INFO: 09:10:19.340 INFO - Started SocketListener on 0.0.0.0:4444
May 23, 2017 9:10:19 AM jenkins.model.Jenkins <init>
INFO: 09:10:19.344 INFO - Started org.openqa.jetty.jetty.Server#6eb7407d
May 23, 2017 9:10:19 AM jenkins.model.Jenkins <init>
INFO: 09:10:19.375 INFO - Starting auto registration thread. Will try to register every 5000 ms.
May 23, 2017 9:10:19 AM jenkins.model.Jenkins <init>
INFO: 09:10:19.376 INFO - Registering the node to the hub: http://mydomain.foobar:9093/grid/register
May 23, 2017 9:10:19 AM jenkins.model.Jenkins <init>
INFO: 09:10:19.431 INFO - The node is registered to the hub and ready to use
And the Jenkins Selenium Plugin logs:
May 23, 2017 9:10:19 AM org.openqa.grid.internal.Registry add
INFO: Registered a node http://172.17.0.1:4444
May 23, 2017 9:16:01 AM org.openqa.grid.internal.Registry add
INFO: Registered a node http://172.17.0.1:9095
This one, or this one, didn't help. Any ideas?
I managed to run the task without hang using this command:
xvfb-run -a webdriver-manager start --seleniumPort 4445 &
-a makes xvfb run on the first available display, and & makes this task run in the background.

Cannot create a new Browser using jxbrowser on linux

I have a small test program using jxbrowser working on a Mac. I am trying to run the test program on a Fedora install and I connot get an instance of a Browser object.
Here is the logging of the program. Does anyone have an idea of what can cause jxbrowser to fail creating the browser ?
-- Product name: JxBrowser
-- Licensed version: 6.x
-- Licensed to:
-- License type: Evaluation
-- Generation date: Feb 23, 2017
-- Expiration date: Mar 25, 2017
-- License info: Single-user license
-- Current date: Feb 28, 2017 JxBrowser license valid. 04:27:24 INFO: OS name: Linux 04:27:24 INFO: OS version:
4.8.6-300.fc25.x86_64 04:27:24 INFO: JRE version: 1.8.0_111 64-bit 04:27:24 INFO: JxBrowser version: 6.12 04:27:24 INFO: Temp: /tmp
16:27:24:208 INFO [main] (be.lyncos.ivista.tools.Test) - Before new
Browser 04:27:24 INFO: JxBrowser type: HEAVYWEIGHT 04:27:24 INFO:
Starting IPC... 04:27:24 INFO: Starting IPC Server... 04:27:24
INFO: Starting socket server 04:27:24 INFO: Starting socket server
at port 1101... 04:27:24 INFO: Starting IPC Process... 04:27:24
INFO: Starting Chromium process... 04:27:24 INFO: The
'/lib/x86_64-linux-gnu/libudev.so.0' library exists: FALSE 04:27:24
INFO: The '/tmp/jxbrowser-chromium-55.0.2883.87.6.12/libudev.so.0'
library exists: TRUE 04:27:24 INFO: The
'/lib/x86_64-linux-gnu/libgcrypt.so.11' library exists: FALSE
04:27:24 INFO: The
'/tmp/jxbrowser-chromium-55.0.2883.87.6.12/libgcrypt.so.11' library
exists: TRUE 04:27:24 INFO: The
'/lib/x86_64-linux-gnu/libcrypto.so.1.0.0' library exists: FALSE
04:27:24 INFO: The
'/tmp/jxbrowser-chromium-55.0.2883.87.6.12/libcrypto.so.1.0.0' library
exists: TRUE 04:27:24 INFO: Command line:
/tmp/jxbrowser-chromium-55.0.2883.87.6.12/jxbrowser-chromium
--port=1101 --pid=7360 --lang=en-us 04:27:24 INFO: [0228/172724:ERROR:browser_main_loop.cc(1426)] Unable to open X
display. 04:27:24 INFO: Shared Memory Name: JXB1-7360 04:27:24
INFO: IPC connection has been established. Connection ID:
140474291099776 04:27:24 INFO: READ: OnHelloMessage{type=OnHello,
uid=1, message='cid:0,type:Main', null 04:27:24 INFO: Channel has
been accepted: SocketChannel{cid=0, bid=-1, type=Main} 04:27:24
INFO: IPC is started. 04:27:24 INFO: WRITE:
CreateBrowserMessage{type=CreateBrowser, uid=1, channelId=0,
contextId=0, cacheDir='user-data-dir/Cache',
memoryDir='user-data-dir/Memory', dataDir='user-data-dir',
currentLocale='en-us', proxyType=-1, proxyRules='null',
proxyBypassRules='null', proxyAutoConfigURL='null',
defaultZoomLevel=0.0, isOffScreenMode=false, storageType=1,
SocketInfo{cid=0, bid=-1, channelType=Main} 04:27:25 INFO: Shutting
down event queue... 04:27:25 INFO: Shutting down event queue...
[DONE] 04:27:25 INFO: Shutting down event queue... 04:27:25 INFO:
Shutting down event queue... [DONE] 04:27:25 INFO: Channel has been
disconnected: SocketChannel{cid=0, bid=-1, type=Main} 04:27:25 INFO:
IPC connection has been closed. Connection ID: 140474291099776
04:27:25 INFO: Pending IPC connections: 0 04:27:25 INFO: Chromium
process exit code 139
com.teamdev.jxbrowser.chromium.internal.ipc.IPCException: Failed to get Browser browserChannel 0
at com.teamdev.jxbrowser.chromium.Browser.a(SourceFile:396)
at com.teamdev.jxbrowser.chromium.Browser.<init>(SourceFile:207)
at com.teamdev.jxbrowser.chromium.Browser.<init>(SourceFile:178)
at com.teamdev.jxbrowser.chromium.Browser.<init>(SourceFile:145)
at be.lyncos.ivista.tools.Test.testJxBrowser(Test.java:6942)
at be.lyncos.ivista.tools.Test.main(Test.java:382)
16:29:24:674 ERROR [main] (be.lyncos.ivista.tools.Test) - Failed to get Browser browserChannel 0
com.teamdev.jxbrowser.chromium.internal.ipc.IPCException: Failed to get Browser browserChannel 0
at com.teamdev.jxbrowser.chromium.Browser.a(SourceFile:396)
at com.teamdev.jxbrowser.chromium.Browser.<init>(SourceFile:207)
at com.teamdev.jxbrowser.chromium.Browser.<init>(SourceFile:178)
at com.teamdev.jxbrowser.chromium.Browser.<init>(SourceFile:145)
at be.lyncos.ivista.tools.Test.testJxBrowser(Test.java:6942)
at be.lyncos.ivista.tools.Test.main(Test.java:382)
04:29:24 INFO: Stopping Server...
04:29:24 INFO: Stopping Server... [DONE]
04:29:24 INFO: Waiting process exit...
Thank you for your help,
Regards,
Christophe
Please make sure that your Linux environment isn't a headless environment. JxBrowser doesn't support headless linux environments without running X Server: https://jxbrowser.support.teamdev.com/support/solutions/articles/9000013733-system-requirements

How do I use Xvfb to run protractor headless on Jenkins with chrome?

I am trying to run my protractor program from Jenkins, but since Jenkins doesn't have a display, I need to run chrome in headless mode. Since chrome doesn't have headless mode, I need to emulate a display using xvfb.
I followed a bunch of tutorials but when I run protractor, chrome crashes.
Here's what I have:
Build - Execute Shell (In Jenkins job)
#emulate display
echo "Starting xvfb on :99..."
Xvfb -ac :99 -screen 0 1280x1024x16 &
export DISPLAY=:99
echo "Checking that xvfb started ok..."
xdpyinfo -display :99 >/dev/null 2>&1 && echo "xvfb is using :99" || echo "xvfb is not using :99, it's free."
#now start my program
xvfb-run -a --server-args='-screen 0, 1024x768x16' protractor conf.js
And here's my output:
+ echo Starting xvfb on :99...
Starting xvfb on :99...
+ export DISPLAY=:99
+ echo Checking that xvfb started ok...
Checking that xvfb started ok...
+ xdpyinfo -display :99
+ Xvfb -ac :99 -screen 0 1280x1024x16
+ echo xvfb is using :99
xvfb is using :99
[22:26:25] I/local - Starting selenium standalone server...
[22:26:25] I/launcher - Running 1 instances of WebDriver
[22:26:26] I/local - Selenium standalone server started at http://10.0.0.82:54385/wd/hub
[22:27:26] E/launcher - unknown error: Chrome failed to start: crashed
(Driver info: chromedriver=2.24.417424 (c5c5ea873213ee72e3d0929b47482681555340c3),platform=Linux 4.4.0-47-generic x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 60.16 seconds
Build info: version: '2.53.1', revision: 'a36b8b1', time: '2016-06-30 17:37:03'
System info: host: 'ip-10-0-0-82', ip: '10.0.0.82', os.name: 'Linux', os.arch: 'amd64', os.version: '4.4.0-47-generic', java.version: '1.8.0_111'
Driver info: org.openqa.selenium.chrome.ChromeDriver
[22:27:26] E/launcher - WebDriverError: unknown error: Chrome failed to start: crashed
(Driver info: chromedriver=2.24.417424 (c5c5ea873213ee72e3d0929b47482681555340c3),platform=Linux 4.4.0-47-generic x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 60.16 seconds
Build info: version: '2.53.1', revision: 'a36b8b1', time: '2016-06-30 17:37:03'
System info: host: 'ip-10-0-0-82', ip: '10.0.0.82', os.name: 'Linux', os.arch: 'amd64', os.version: '4.4.0-47-generic', java.version: '1.8.0_111'
Driver info: org.openqa.selenium.chrome.ChromeDriver
at WebDriverError (/jenkins/workspace/myjob/src/js/node_modules/selenium-webdriver/lib/error.js:27:5)
at Object.checkLegacyResponse (/jenkins/workspace/myjob/src/js/node_modules/selenium-webdriver/lib/error.js:639:15)
at parseHttpResponse (/jenkins/workspace/myjob/src/js/node_modules/selenium-webdriver/http/index.js:538:13)
at client_.send.then.response (/jenkins/workspace/myjob/src/js/node_modules/selenium-webdriver/http/index.js:472:11)
at ManagedPromise.invokeCallback_ (/jenkins/workspace/myjob/src/js/node_modules/selenium-webdriver/lib/promise.js:1379:14)
at TaskQueue.execute_ (/jenkins/workspace/myjob/src/js/node_modules/selenium-webdriver/lib/promise.js:2913:14)
at TaskQueue.executeNext_ (/jenkins/workspace/myjob/src/js/node_modules/selenium-webdriver/lib/promise.js:2896:21)
at asyncRun (/jenkins/workspace/myjob/src/js/node_modules/selenium-webdriver/lib/promise.js:2820:25)
at /jenkins/workspace/myjob/src/js/node_modules/selenium-webdriver/lib/promise.js:639:7
at process._tickCallback (internal/process/next_tick.js:103:7)
From: Task: WebDriver.createSession()
at Function.createSession (/jenkins/workspace/myjob/src/js/node_modules/selenium-webdriver/lib/webdriver.js:329:24)
at Builder.build (/jenkins/workspace/myjob/src/js/node_modules/selenium-webdriver/builder.js:458:24)
at Local.DriverProvider.getNewDriver (/jenkins/workspace/myjob/src/js/node_modules/protractor/built/driverProviders/driverProvider.js:37:33)
at Runner.createBrowser (/jenkins/workspace/myjob/src/js/node_modules/protractor/built/runner.js:198:43)
at /jenkins/workspace/myjob/src/js/node_modules/protractor/built/runner.js:277:30
at _fulfilled (/jenkins/workspace/myjob/src/js/node_modules/q/q.js:834:54)
at self.promiseDispatch.done (/jenkins/workspace/myjob/src/js/node_modules/q/q.js:863:30)
at Promise.promise.promiseDispatch (/jenkins/workspace/myjob/src/js/node_modules/q/q.js:796:13)
at /jenkins/workspace/myjob/src/js/node_modules/q/q.js:604:44
at runSingle (/jenkins/workspace/myjob/src/js/node_modules/q/q.js:137:13)
[22:27:26] E/launcher - Process exited with error code 199
I keep getting Chrome failed to start: crashed with everything I tried... is this a problem with how I'm starting or configuring xvfb? Or is this a problem with my protractor code? The stacktrace isn't helping me at all x.x
I would recommend using the Jenkins Xvfb Plugin. It works really well without having to mess too much with configurations.
To set up a job, just click on the xvfb option to run at the start of the job and shut down xvfb at the end of your job. Once you've set that, you can execute your Protractor commands without the xvfb stuff: protractor conf.js.

Appium Grid hub sending wrong set of capabilities to nodes

I am trying to configure Appium Grid with below node configuration.
-Hub is receiving proper capabilities from testng but hub is sending wrong capabilities to my only two nodes. (node configs are as follows )
Please do suggest where am I going wrong.
Emulator Node config
Command running the node with : node appium.js --port 4723 --nodeconfig G:\Selenium2\Grid\AppiumEmulatorNode.json
{
"capabilities": [{
"browserName": "Emulator_5.1.0",
"version": "5.1.0",
"maxInstances": 1,
"platform": "ANDROID"
}],
"configuration": {
"cleanUpCycle": 2000,
"timeout": 30000,
"proxy": "org.openqa.grid.selenium.proxy.DefaultRemoteProxy",
"url": "http://192.168.0.104:4723/wd/hub",
"host": 192.168.0.104,
"port": 4723,
"maxSession": 1,
"register": true,
"registerCycle": 5000,
"hubPort": 4444 ,
"hubHost": "192.168.0.104"
}
}
Real device Node config
Command running the node with : node appium.js --port 4724 --nodeconfig G:\Selenium2\Grid\AppiumRealDevice.json
{
"capabilities": [{
"browserName": "Sony Xperia SP",
"version": "5.1.1",
"maxInstances": 1,
"platform": "ANDROID"
}],
"configuration": {
"cleanUpCycle": 2000,
"timeout": 30000,
"proxy": "org.openqa.grid.selenium.proxy.DefaultRemoteProxy",
"url": "http://192.168.0.104:4724/wd/hub",
"host": "192.168.0.104",
"port": 4724,
"maxSession": 1,
"register": true,
"registerCycle": 5000,
"hubPort": 4444 ,
"hubHost": "192.168.0.104"
}
}
Testng file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="TestsSuite" parallel="tests" thread-count="2" verbose="5">
<test name="Test1">
<parameter name="UdidOrDeviceName" value="YT910LQ91K"></parameter>
<parameter name="MobileVersion" value="5.2.0"></parameter>
<classes>
<class name="com.apps.AppiumTest.AppiumMessengerTest" />
</classes>
</test>
<test name="Test2">
<parameter name="UdidOrDeviceName" value="192.168.113.101:5555"></parameter>
<parameter name="MobileVersion" value="5.1.0"></parameter>
<classes>
<class name="com.apps.AppiumTest.AppiumMessengerTest" />
</classes>
</test>
</suite>
Grid hub Output
19:47:56.092 INFO - Registered a node http://192.168.0.104:4723
19:51:05.917 INFO - Registered a node http://192.168.0.104:4724
19:51:31.419 INFO - Got a request to create a new session: Capabilities [{appActivity=com.android.mms.ui.ConversationList, appPackage=com.android.mms, platformVersion=5.2.0, newCOmmandTimeout=1000, platformName=Android, deviceName=YT910LQ91K}]
19:51:31.433 INFO - Available nodes: [http://192.168.0.104:4723, http://192.168.0.104:4724]
19:51:31.438 INFO - Got a request to create a new session: Capabilities [{appActivity=com.android.mms.ui.ConversationList, appPackage=com.android.mms, platformVersion=5.1.0, newCOmmandTimeout=1000, platformName=Android, deviceName=192.168.113.101:5555}]
19:51:31.438 INFO - Trying to create a new session on node http://192.168.0.104:4723
19:51:31.460 INFO - Trying to create a new session on test slot {maxInstances=3, platformName=ANDROID, deviceName=192.168.113.101:5555, version=5.1.0}
19:51:31.476 INFO - Available nodes: [http://192.168.0.104:4724, http://192.168.0.104:4723]
19:51:31.486 INFO - Trying to create a new session on node http://192.168.0.104:4724
19:51:31.501 INFO - Trying to create a new session on test slot {browserName=Sony Xperia SP, maxInstances=1, version=5.1.1, platform=ANDROID}
Emulator Node output
This node receiving wrong set of data from Selenium Grid.It should receive emulator capabilities but it has received real device capabilities
C:\Program Files (x86)\Appium\node_modules\appium\bin>node appium.js --port 4723 --nodeconfig G:\Selenium2\Grid\AppiumEmulatorNode.json
info: Welcome to Appium v1.4.16 (REV ae6877eff263066b26328d457bd285c0cc62430d)
info: Appium REST http interface listener started on 0.0.0.0:4723
info: [debug] Non-default server args: {"nodeconfig":"G:\\Selenium2\\Grid\\AppiumEmulatorNode.json"}
info: Console LogLevel: debug
info: [debug] starting auto register thread for grid. Will try to register every 5000 ms.
info: [debug] Appium successfully registered with the grid on 192.168.0.104:4444
info: --> GET /wd/hub/status {}
info: [debug] Responding to client with success: {"status":0,"value":{"build":{"version":"1.4.16","revision":"ae6877eff263066b26328d457bd285c0cc62430d"}}}
info: <-- GET /wd/hub/status 200 28.871 ms - 105 {"status":0,"value":{"build":{"version":"1.4.16","revision":"ae6877eff263066b26328d457bd285c0cc62430d"}}}
info: <-- GET /wd/hub/status 200 11.314 ms - 105 {"status":0,"value":{"build":{"version":"1.4.16","revision":"ae6877eff263066b26328d457bd285c0cc62430d"}}}
info: --> POST /wd/hub/session {"desiredCapabilities":{"appActivity":"com.android.mms.ui.ConversationList","appPackage":"com.android.mms","platformVersion":"5.2.0","newCOmmandTimeout":1000,"platformName":"Android","deviceName":"YT910LQ91K"}}
info: Client User-Agent string: Apache-HttpClient/4.5.1 (Java/1.8.0_65)
Real Device Node output
This node receiving wrong set of data from Selenium Grid.It should receive Real device capabilities but it has received emulator capabilities
C:\Program Files (x86)\Appium\node_modules\appium\bin>node appium.js --port 4724 --nodeconfig G:\Selenium2\Grid\AppiumRealDevice.json
info: Welcome to Appium v1.4.16 (REV ae6877eff263066b26328d457bd285c0cc62430d)
info: Appium REST http interface listener started on 0.0.0.0:4724
info: [debug] Non-default server args: {"port":4724,"nodeconfig":"G:\\Selenium2\\Grid\\AppiumRealDevice.json"}
info: Console LogLevel: debug
info: [debug] starting auto register thread for grid. Will try to register every 5000 ms.
info: [debug] Appium successfully registered with the grid on 192.168.0.104:4444
info: --> GET /wd/hub/status {}
info: [debug] Responding to client with success: {"status":0,"value":{"build":{"version":"1.4.16","revision":"ae6877eff263066b26328d457bd285c0cc62430d"}}}
info: <-- GET /wd/hub/status 200 22.103 ms - 105 {"status":0,"value":{"build":{"version":"1.4.16","revision":"ae6877eff263066b26328d457bd285c0cc62430d"}}}
info: --> GET /wd/hub/status {}
info: [debug] Responding to client with success: {"status":0,"value":{"build":{"version":"1.4.16","revision":"ae6877eff263066b26328d457bd285c0cc62430d"}}}
info: <-- GET /wd/hub/status 200 12.602 ms - 105 {"status":0,"value":{"build":{"version":"1.4.16","revision":"ae6877eff263066b26328d457bd285c0cc62430d"}}}
info: --> GET /wd/hub/status {}
info: [debug] Responding to client with success: {"status":0,"value":{"build":{"version":"1.4.16","revision":"ae6877eff263066b26328d457bd285c0cc62430d"}}}
info: <-- GET /wd/hub/status 200 11.690 ms - 105 {"status":0,"value":{"build":{"version":"1.4.16","revision":"ae6877eff263066b26328d457bd285c0cc62430d"}}}
info: --> GET /wd/hub/status {}
info: [debug] Responding to client with success: {"status":0,"value":{"build":{"version":"1.4.16","revision":"ae6877eff263066b26328d457bd285c0cc62430d"}}}
info: <-- GET /wd/hub/status 200 11.460 ms - 105 {"status":0,"value":{"build":{"version":"1.4.16","revision":"ae6877eff263066b26328d457bd285c0cc62430d"}}}
info: --> GET /wd/hub/status {}
info: [debug] Responding to client with success: {"status":0,"value":{"build":{"version":"1.4.16","revision":"ae6877eff263066b26328d457bd285c0cc62430d"}}}
info: <-- GET /wd/hub/status 200 11.927 ms - 105 {"status":0,"value":{"build":{"version":"1.4.16","revision":"ae6877eff263066b26328d457bd285c0cc62430d"}}}
info: --> POST /wd/hub/session {"desiredCapabilities":{"appActivity":"com.android.mms.ui.ConversationList","appPackage":"com.android.mms","platformVersion":"5.1.0","newCOmmandTimeout":1000,"platformName":"Android","deviceName":"192.168.113.101:5555"}}
info: Client User-Agent string: Apache-HttpClient/4.5.1 (Java/1.8.0_65)
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. : newCOmmandTimeout
info: [debug] Didn't get app but did get Android package, will attempt to launch it on the device
info: [debug] Creating new appium session 515cbed7-46c0-4fce-a2e0-652976c5a659
info: Starting android appium
info: [debug] Getting Java version
info: Java version is: 1.8.0_71
info: [debug] Checking whether adb is present
info: [debug] Using adb from C:\Users\Harsha\AppData\Local\Android\sdk\platform-tools\adb.exe
warn: No app capability, can't parse package/activity
info: [debug] Using fast reset? true
info: [debug] Preparing device for session
info: [debug] Not checking whether app is present since we are assuming it's already on the device
info: Retrieving device
info: [debug] Trying to find a connected android device
info: [debug] Getting connected devices...
info: [debug] executing cmd: C:\Users\Harsha\AppData\Local\Android\sdk\platform-tools\adb.exe devices
info: [debug] 2 device(s) connected
info: Found device 192.168.113.101:5555
info: [debug] Setting device id to 192.168.113.101:5555
info: [debug] Waiting for device to be ready and to respond to shell commands (timeout = 5)
info: [debug] executing cmd: C:\Users\Harsha\AppData\Local\Android\sdk\platform-tools\adb.exe -s 192.168.113.101:5555 wait-for-device
info: [debug] executing cmd: C:\Users\Harsha\AppData\Local\Android\sdk\platform-tools\adb.exe -s 192.168.113.101:5555 shell "echo 'ready'"
info: [debug] Starting logcat capture
info: [debug] Getting device API level
info: [debug] executing cmd: C:\Users\Harsha\AppData\Local\Android\sdk\platform-tools\adb.exe -s 192.168.113.101:5555 shell "getprop ro.build.version.sdk"
info: [debug] Device is at API Level 22
info: Device API level is: 22
info: [debug] Extracting strings for language: default
info: [debug] Apk doesn't exist locally
info: [debug] Could not get strings, but it looks like we had an old strings file anyway, so ignoring
info: [debug] executing cmd: C:\Users\Harsha\AppData\Local\Android\sdk\platform-tools\adb.exe -s 192.168.113.101:5555 shell "rm -rf /data/local/tmp/strings.json"
info: [debug] Not uninstalling app since server not started with --full-reset
info: [debug] Skipping install since we launched with a package instead of an app path
info: [debug] Forwarding system:4724 to device:4724
info: [debug] executing cmd: C:\Users\Harsha\AppData\Local\Android\sdk\platform-tools\adb.exe -s 192.168.113.101:5555 forward tcp:4724 tcp:4724
info: [debug] Pushing appium bootstrap to device...
info: [debug] executing cmd: C:\Users\Harsha\AppData\Local\Android\sdk\platform-tools\adb.exe -s 192.168.113.101:5555 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\Harsha\AppData\Local\Android\sdk\platform-tools\adb.exe -s 192.168.113.101:5555 install "C:\Program Files (x86)\Appium\node_modules\appium\build\settings_apk\settings_apk-debug.apk"
info: [debug] Pushing unlock helper app to device...
info: [debug] executing cmd: C:\Users\Harsha\AppData\Local\Android\sdk\platform-tools\adb.exe -s 192.168.113.101:5555 install "C:\Program Files (x86)\Appium\node_modules\appium\build\unlock_apk\unlock_apk-debug.apk"
info: --> GET /wd/hub/status {}
info: [debug] Responding to client with success: {"status":0,"value":{"build":{"version":"1.4.16","revision":"ae6877eff263066b26328d457bd285c0cc62430d"}},"sessionId":"515cbed7-46c0-4fce-a2e0-652976c5a659"}
info: <-- GET /wd/hub/status 200 69.204 ms - 156 {"status":0,"value":{"build":{"version":"1.4.16","revision":"ae6877eff263066b26328d457bd285c0cc62430d"}},"sessionId":"515cbed7-46c0-4fce-a2e0-652976c5a659"}
info: Starting App
info: [debug] Attempting to kill all 'uiautomator' processes
info: [debug] Getting all processes with 'uiautomator'
info: [debug] executing cmd: C:\Users\Harsha\AppData\Local\Android\sdk\platform-tools\adb.exe -s 192.168.113.101:5555 shell "ps 'uiautomator'"
info: [debug] No matching processes found
info: [debug] Running bootstrap
info: [debug] spawning: C:\Users\Harsha\AppData\Local\Android\sdk\platform-tools\adb.exe -s 192.168.113.101:5555 shell uiautomator runtest AppiumBootstrap.jar -c io.appium.android.bootstrap.Bootstrap -e pkg com.android.mms -e disableAndroidWatchers false
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_RESULT: shortMsg=java.lang.IllegalStateException
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_RESULT: longMsg=UiAutomationService android.accessibilityservice.IAccessibilityServiceClient$Stub$Proxy#1034d97calready registered!
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_CODE: 0
info: [debug] UiAutomator exited
info: [debug] executing cmd: C:\Users\Harsha\AppData\Local\Android\sdk\platform-tools\adb.exe -s 192.168.113.101:5555 shell "echo 'ping'"
info: [debug] Attempting to uninstall app
info: [debug] Not uninstalling app since server not started with --full-reset
info: [debug] Cleaning up android objects
error: UiAutomator quit before it successfully launched
info: [debug] Cleaning up appium session
error: Failed to start an Appium session, err was: Error: UiAutomator quit before it successfully launched
info: [debug] Error: UiAutomator quit before it successfully launched
at [object Object].<anonymous> (C:\Program Files (x86)\Appium\node_modules\appium\lib\devices\android\android.js:205:23)
at [object Object].<anonymous> (C:\Program Files (x86)\Appium\node_modules\appium\lib\devices\android\android-hybrid.js:249:5)
at Object.async.eachSeries (C:\Program Files (x86)\Appium\node_modules\appium\node_modules\async\lib\async.js:142:20)
at [object Object].androidHybrid.stopChromedriverProxies (C:\Program Files (x86)\Appium\node_modules\appium\lib\devices\android\android-hybrid.js:233:9)
at [object Object].<anonymous> (C:\Program Files (x86)\Appium\node_modules\appium\lib\devices\android\android.js:200:10)
at [object Object].<anonymous> (C:\Program Files (x86)\Appium\node_modules\appium\lib\devices\android\android.js:222:9)
at [object Object].androidCommon.uninstallApp (C:\Program Files (x86)\Appium\node_modules\appium\lib\devices\android\android-common.js:478:5)
at [object Object].<anonymous> (C:\Program Files (x86)\Appium\node_modules\appium\lib\devices\android\android.js:220:12)
at [object Object].<anonymous> (C:\Program Files (x86)\Appium\node_modules\appium\lib\devices\android\android.js:229:11)
at C:\Program Files (x86)\Appium\node_modules\appium\node_modules\appium-adb\lib\adb.js:901:7
at [object Object].<anonymous> (C:\Program Files (x86)\Appium\node_modules\appium\node_modules\appium-adb\lib\adb.js:180:9)
at ChildProcess.exithandler (child_process.js:194:7)
at emitTwo (events.js:87:13)
at ChildProcess.emit (events.js:172:7)
at maybeClose (internal/child_process.js:818:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)
info: [debug] Responding to client with error: {"status":33,"value":{"message":"A new session could not be created. (Original error: UiAutomator quit before it successfully launched)","origValue":"UiAutomator quit before it successfully launched"},"sessionId":null}
Here's how the Grid decides to which node should a test be routed to.
It uses something called as a Capability Matcher, to help it decide as to which among its nodes should a test be routed to. If you don't provide a custom capability matcher [ You can take a look at this blog of mine to understand how to plugin in your own custom variant ], it resorts to relying on the DefaultCapabilityMatcher for doing this matching job.
Since you haven't set any of the attributes that the default capability matcher understands [ see here for learning what are those ], it always matches the first node with a test. That is why you are seeing the mess up.
It only understands browserName, platform, version and applicationName and for browserName, platform you cannot pass in any arbitrary values but can only use predefined values. See BrowserType and Platform java classes.
So to solve your problem, you have two options.
Option 1 : You build your own capability matcher which suites your needs (you can refer to my blog post link that I have shared above) and work with it.
Option 2 : You resort to using the capability "applicationName" wherein you provide a unique value to this for each of your nodes and then rely on your test to add this extra capability at the test level.
That should resolve your problem.

Blank Firefox Window Issue in Selenium PHPUnit Test in Linux Mint

I was trying to test out a page of mine using Selenium and phpunit. I had coded it properly and tried it out on a Ubuntu 14.04 machine. It tested out properly.
However I do not remember the version of selenium server and firefox used.
Now after some issues, I had removed Ubuntu and intalled Mint on my system.
While testing the page, I get a lot of error messages and a blank firefox screen.
Current version of firefox is 30 and Selenium 2.4.2
Tried with firefox versions 25,26,27,30.
I have posted the codes below.
Any help will be appreciated.
Output of Selenium starting
java -jar selenium-server-standalone-2.42.2.jar25 Jun, 2014 3:36:17 PM org.openqa.grid.selenium.GridLauncher main
INFO: Launching a standalone server
15:36:17.264 INFO - Java: Sun Microsystems Inc. 20.45-b01
15:36:17.264 INFO - OS: Linux 3.13.0-24-generic amd64
15:36:17.280 INFO - v2.42.2, with Core v2.42.2. Built from revision 6a6995d
15:36:17.347 INFO - Default driver org.openqa.selenium.ie.InternetExplorerDriver registration is skipped: registration capabilities Capabilities [{platform=WINDOWS, ensureCleanSession=true, browserName=internet explorer, version=}] does not match with current platform: LINUX
15:36:17.398 INFO - RemoteWebDriver instances should connect to: http://127.0.0.1:4444/wd/hub
15:36:17.399 INFO - Version Jetty/5.1.x
15:36:17.400 INFO - Started HttpContext[/selenium-server/driver,/selenium-server/driver]
15:36:17.401 INFO - Started HttpContext[/selenium-server,/selenium-server]
15:36:17.401 INFO - Started HttpContext[/,/]
15:36:17.419 INFO - Started org.openqa.jetty.jetty.servlet.ServletHandler#a39ab89
15:36:17.419 INFO - Started HttpContext[/wd,/wd]
15:36:17.422 INFO - Started SocketListener on 0.0.0.0:4444
15:36:17.422 INFO - Started org.openqa.jetty.jetty.Server#5abb7465
Output of Running a PHPUnit Test
phpunit testBooking.php
PHPUnit 3.7.28 by Sebastian Bergmann.
E
Time: 5.24 seconds, Memory: 3.00Mb
There was 1 error:
1) TestBookingBlockDate::testBlock
RuntimeException: POST /session/url
Build info: version: '2.42.2', revision: '6a6995d', time: '2014-06-03 17:42:03'
System info: host: 'Sworoop', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '3.13.0-24-generic', java.version: '1.6.0_45'
Driver info: driver.version: unknown
/var/www/Folder/UnitTests/TurningStone/testBooking.php:13
/var/www/Folder/UnitTests/TurningStone/testBooking.php:13
FAILURES!
Tests: 1, Assertions: 1, Errors: 1.
PHP Fatal error: Uncaught exception 'RuntimeException' with message 'DELETE /session
Build info: version: '2.42.2', revision: '6a6995d', time: '2014-06-03 17:42:03'
System info: host: 'Sworoop', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '3.13.0-24-generic', java.version: '1.6.0_45'
Driver info: driver.version: unknown' in /usr/share/php/PHPUnit/Extensions/Selenium2TestCase/Driver.php:127
Stack trace:
#0 /usr/share/php/PHPUnit/Extensions/Selenium2TestCase/Session.php(137): PHPUnit_Extensions_Selenium2TestCase_Driver->curl('DELETE', Object(PHPUnit_Extensions_Selenium2TestCase_URL))
#1 /usr/share/php/PHPUnit/Extensions/Selenium2TestCase/Session.php(117): PHPUnit_Extensions_Selenium2TestCase_Session->stop()
#2 [internal function]: PHPUnit_Extensions_Selenium2TestCase_Session->__destruct()
#3 {main}
thrown in /usr/share/php/PHPUnit/Extensions/Selenium2TestCase/Driver.php on line 127
PHP Stack trace:
PHP 1. {main}() /usr/bin/phpunit:0
PHP 2. PHPUnit_TextUI_Command::main() /usr/bin/phpunit:46
PHP 3. PHPUnit_TextUI_Command->run() /usr/share/php/PHPUnit/TextUI/Command.php:129
During this I get a blank firefox window which I have to manually close.
Solved it after reinstalling PHPUnit using composer instead of apt.
Thanks everyone :)

Resources