Run android emulator on remote machine - appium

I am running appium test and during the test I am trying to activate emulator from remote machine...
My test code is starting appium server on the remote machine and then creates android driver.
In the remote machine I have emulator and appium installed without running the server.
The remote machine IP is : 192.168.14.23 port 4723
In the running machine I have also appium installed.
I am using appium version 1.4.13
Here is the log:
Going to execute start appium server: cmd /c
C://appium//Appium//node.exe
C://appium//Appium//node_modules\appium\bin\appium.js --address
192.168.14.23 --port 4723
[33mwarn[39m: Appium support for versions of node < 0.12 has been deprecated and will be removed in a future version. Please
upgrade!
[31merror[39m: Couldn't start Appium REST http interface listener. Requested address is not available.
2015-11-19 14:26:03,586 INFO [main] (Drivers.java:329) - Trying to set ANDROID driver
org.openqa.selenium.remote.UnreachableBrowserException: Could not start a new session. Possible causes are invalid address of the remote
server or browser start-up failure.
Build info: version: '2.42.2', revision: '6a6995d31c7c56c340d6f45a76976d43506cd6cc', time: '2014-06-03
10:52:47'
System info: host: 'QTVR-AII015', ip: '192.168.23.43', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version:
'1.7.0_79'
Driver info: driver.version: AndroidDriver
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:593)
at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:180)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:240)
at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:126)
at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:153)
at io.appium.java_client.AppiumDriver.(AppiumDriver.java:109)
at io.appium.java_client.android.AndroidDriver.(AndroidDriver.java:39)
at com.ui.service.drivers.Drivers$Appium.createAndroidDriver(Drivers.java:362)
at com.ui.service.drivers.Drivers$Appium.setDriver(Drivers.java:338)
at com.ui.service.drivers.Drivers.setDriver(Drivers.java:52)
at appium.messaging.basic_concurrent.VisitorThread.initAppiumDriver(VisitorThread.java:67)
at appium.messaging.basic_concurrent.VisitorThread.init(VisitorThread.java:57)
at appium.messaging.basic_concurrent.VisitorThread.

Disable the firewall of both the machines and retry..
You can execute test while hosting appium server in remote machine..
This may also occur if you use virtual network..
is your remote machine is VM??

Related

how can appium which is run on WAN server(cloud server) connect to phone devices which are usb connected to local PC?

server environment:
CentOS 8 on remote cloud server
appium 1.21.0 on CentOS 8
java version "1.8.0_261"
PC environment:
windows 10
phone device connect to windows10 using usb
how can I connect the appium server with PC?
Architecture:
Credit Github: https://github.com/appium/appium/issues/10503
Here we are running scripts from a remote/local Appium server while the devices are connected to another system in the network.
Setup:
Start adb server in the system in which devices are connected:
Just run the below command in cmd (given adb is available in path)
adb kill-server
adb -a -P 5037 server nodaemon
Appium capabilities:
Now to run appium tests we need to add the below capability:
Try appium inspector from the remote system with below capability (edit all other fields according to your setup except remoteAdbHost,systemport and adbPort)
here remoteadbhost is the remote system which has connected devices change 192.168.0.7 to correct addres, system port is the uiautomator2 server port which is 8021 by default and finally adbport
This will allow you to inspect the remote devices from your local system
{
“platformName”: “Android”,
“appium:platformVersion”: “11”,
“appium:deviceName”: “sr”,
“appium:app”: “C:\\Users\\Downloads\\ApiDemos-debug.apk”,
“appium:automationName”: “UiAutomator2”,
"remoteAdbHost":"192:168.0.7",
"systemPort":8021,
"adbPort":5037
}
Note: when using webdriverio 7 add appium: infront of all the capabilities as its the new syntax for w3c.

Problems running Protractor on a Windows Jenkins Slave Node

I'm getting an issue while trying to run Protractor on IE11 on a Windows Jenkins Slave Node.
When I connect by remote desktop, I'm able to run Protractor with no issues. However, when I try to run Protractor from Jenkins I run into this issue:
[launcher] Error: UnknownError: JavaScript error (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 396 milliseconds
Build info: version: '2.47.1', revision: '411b314', time: '2015-07-30 03:03:16'
System info: host: 'Win7', ip: '142.133.132.199', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_60'
Driver info: org.openqa.selenium.ie.InternetExplorerDriver
Capabilities [{browserAttachTimeout=0, enablePersistentHover=true, ie.forceCreateProcessApi=false, pageLoadStrategy=normal, ie.usePerProcessProxy=false, ignoreZoomSetting=false, handlesAlerts=true, version=11, platform=WINDOWS, nativeEvents=true, ie.ensureCleanSession=false, elementScrollBehavior=0, ie.browserCommandLineSwitches=, requireWindowFocus=false, browserName=internet explorer, initialBrowserUrl=http://localhost:12492/, takesScreenshot=true, javascriptEnabled=true, ignoreProtectedModeSettings=true, enableElementCacheCleanup=true, cssSelectorsEnabled=true, unexpectedAlertBehaviour=dismiss}]
Session ID: a43ccc90-f9f7-4465-98c3-dfb88751a5a9
at new bot.Error (C:\Jenkins\workspace\sandbox\node_modules\protractor\node_modules\selenium-webdriver\lib\atoms\error.js:108:18)
at Object.bot.response.checkResponse (C:\Jenkins\workspace\sandbox\node_modules\protractor\node_modules\selenium-webdriver\lib\atoms\response.js:109:9)
at C:\Jenkins\workspace\sandbox\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver\webdriver.js:379:20
at Array.forEach (native)
at goog.async.run.processWorkQueue (C:\Jenkins\workspace\sandbox\node_modules\protractor\node_modules\selenium-webdriver\lib\goog\async\run.js:130:15)
at process._tickCallback (node.js:356:9)
[launcher] Process exited with error code 100
This is weird, because I can run the same tests using any other browsers. Here are some things I tried:
Made sure that Jenkins is using the same account as the one I'm logging in.
Followed the steps on this blog: http://elgalu.github.io/2014/run-protractor-against-internet-explorer-vm/
Changed the protected settings, zoom level and registry key as per this website: https://code.google.com/p/selenium/wiki/InternetExplorerDriver
Tried using the x86 version of the IEDriverServer
Is there anything that I am missing?
I found out that reading documentation is a good thing :) https://code.google.com/p/selenium/wiki/InternetExplorerDriver
Read the configuring section
For IE 11 only, you will need to set a registry entry on the target
computer so that the driver can maintain a connection to the instance
of Internet Explorer it creates. For 32-bit Windows installations, the
key you must examine in the registry editor is
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet
Explorer\Main\FeatureControl\FEATURE_BFCACHE. For 64-bit Windows
installations, the key is
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Internet
Explorer\Main\FeatureControl\FEATURE_BFCACHE. Please note that the
FEATURE_BFCACHE subkey may or may not be present, and should be
created if it is not present. Important: Inside this key, create a
DWORD value named iexplore.exe with the value of 0.
Worked for me...
I too had problems with Protractor tests under Jenkins, all worked well when I run the test in console, but not in Jenkins.
Turned out, that IEDriverServer does not work, when Jenkins is running as a service (as is the default with jenkins window installer). For IE tests Jenkins MUST NOT RUN AS A SERVICE, instead Jenkins service must be closed and Jenkins started with
java -jar jenkins.war
(in jenkins directory)
(see https://github.com/SeleniumHQ/selenium/wiki/InternetExplorerDriver)
Make sure the versions of your node modules, specifically selenium, are the same on both the local machine and the remote machine.

How to run appium on headless Linux

How do I run tests in headless fashion (for web testing I use XVFB for running browser tests in headless on Jenkins), so how it will work for automation on AVD/Device
I am trying to run a mobile web test using appium on Centos 6 headless linux but I am keep getting this error:
"info: [CHROMEDRIVER STDERR] No protocol specified
info: Responding to client with error: {"status":13,"value":{"message":"An unknown server-side error
occurred while processing the command.","origValue":"**unknown error: an X display is required for
keycode onversions, consider using Xvfb\n** (Session info: chrome=webview)\n
(Driver info:chromedriver=2.9.248316,platform=Linux 2.6.32042stab088.4x86_64)"},
"sessionId":"8563fbe5972f3ba87673c7a082d49d22"}POST /wd/hub/session/8563fbe5972f3ba87673c7a082d49d22/element/0.06753459526225924-1/value 500 1927ms - 395b
debug: Appium request initiated at /wd/hub/session/8563fbe5972f3ba87673c7a082d49d22
debug: Request received with params: {}
info: Shutting down appium session..."
It opens up the chrome browser and navigates to the given url. After that it tries sendKeys to the username field and then it fails.
We just had this issue and solved it by wrapping the appium server call in a call to xvfb:
xvfb-run appium --session-override --command-timeout=0 &
(or whatever you appium server settings are)
xvfb-run will then handle the headless server setup and shutdown for you.

How to set up grid on remote machien and run webdriver test cases?

What I have; I have putty.exe to access a remote ubuntu machine xxx.xx.xxx.xx.
What I want; I want that when I run my test cases on this remote machine using jenkins it would launch a browser that I can see popping up on my windows machine.
What I have tried; I have tried to use firefox with Xvfb(both located on remote machine) but that is headless and I cant see errors, I cant get much help from reports. I want to see whats happening on UI
So I wanted to use remote webdriver. I tried to register on remote machine as;used putty.exe
sudo java -jar selenium-server-standalone-2.35.0.jar -role node -hub http://localhost/xxx.xx.xxx.xx:4444/grid/register
but that gave error :
Sep 27, 2013 9:24:24 AM org.openqa.grid.selenium.GridLauncher main
INFO: Launching a selenium grid node
Sep 27, 2013 9:24:24 AM org.openqa.grid.internal.utils.SelfRegisteringRemote startRemoteServer
WARNING: error getting the parameters from the hub. The node may end up with wrong timeouts.The target server failed to respond
09:24:24.961 INFO - Java: Oracle Corporation 23.7-b01
09:24:24.962 INFO - OS: Linux 3.5.0-21-generic amd64
09:24:24.971 INFO - v2.35.0, with Core v2.35.0. Built from revision c916b9d
09:24:25.111 INFO - RemoteWebDriver instances should connect to: http://127.0.0.1:5555/wd/hub
09:24:25.113 INFO - Version Jetty/5.1.x
09:24:25.114 INFO - Started HttpContext[/selenium-server/driver,/selenium-server/driver]
09:24:25.115 INFO - Started HttpContext[/selenium-server,/selenium-server]
09:24:25.116 INFO - Started HttpContext[/,/]
09:24:36.415 INFO - Started org.openqa.jetty.jetty.servlet.ServletHandler#49af0a45
09:24:36.416 INFO - Started HttpContext[/wd,/wd]
09:24:36.423 INFO - Started SocketListener on 0.0.0.0:5555
09:24:36.426 INFO - Started org.openqa.jetty.jetty.Server#1f4a8824
09:24:36.428 INFO - using the json request : {"class":"org.openqa.grid.common.RegistrationRequest","capabilities":[{"platform":"LINUX","seleniumProtocol":"Selenium","browserName":"*firefox","maxInstances":5},{"platform":"LINUX","seleniumProtocol":"Selenium","browserName":"*googlechrome","maxInstances":5},{"platform":"LINUX","seleniumProtocol":"Selenium","browserName":"*iexplore","maxInstances":1},{"platform":"LINUX","seleniumProtocol":"WebDriver","browserName":"firefox","maxInstances":5},{"platform":"LINUX","seleniumProtocol":"WebDriver","browserName":"chrome","maxInstances":5},{"platform":"LINUX","seleniumProtocol":"WebDriver","browserName":"internet explorer","maxInstances":1}],"configuration":{"port":5555,"register":true,"host":"10.158.96.150","proxy":"org.openqa.grid.selenium.proxy.DefaultRemoteProxy","maxSession":5,"role":"node","hubHost":"localhost","registerCycle":5000,"hub":"http://localhost/184.73.224.98:4444/grid/register","hubPort":-1,"url":"http://10.158.96.150:5555","remoteHost":"http://10.158.96.150:5555"}}
09:24:36.430 INFO - Starting auto register thread. Will try to register every 5000 ms.
09:24:36.430 INFO - Registering the node to hub :http://localhost:-1/grid/register
09:24:36.446 INFO - couldn't register this node : Error sending the registration request.
09:24:41.479 INFO - couldn't register this node : Hub is down or not responding: Hub is down or not responding.
I have already tried :
http://rationaleemotions.wordpress.com/2012/01/23/setting-up-grid2-and-working-with-it/
https://code.google.com/p/selenium/wiki/Grid2
Understanding Selenium Grid2 implementation running on EC2
but these failed on initial step when I have to register a node on remote ubuntu machine.
Its not entirely clear what your error is. This might help where you can vnc onto a headless Xvfb box using ssh tunnels
after installing any missing packages on your remote server
Xvfb -screen 0 800x600x16 -ac &
export DISPLAY=:0
xterm &
java -jar selenium-server-standalone-2.35.0.jar -role node -hub http://mywebsiteip:4444/grid/register
then tunnel to your server from your own machine
ssh -l kaltpost -L 5900:localhost:5900 mywebsiteip 'x11vnc -localhost -display :0'
which will wait, so in another terminal
vncviewer localhost&
Which is all taken from here http://gpio.kaltpost.de/?page_id=84
++edit
I just saw you started your selenium server with the ip of the host, this needs to be localhost and then mywebsite id when you connect your tests to it

How to run webdriver test cases on remote staging server(ubuntu) using jenkins?

I pushed the code on github
I have configured Jenkins on
staging.website.com:8xxx , its a Ubuntu machine
I am able to access this ubuntu machine via putty.exe from my windows7 machine
I am able to fetch the code on github via Jenkins means I am able to run the build via Jenkins but it fails as Problem: I am not able to launch the browser.
I tried
DesiredCapabilities capability = DesiredCapabilities.firefox();
capability.setCapability("platform", Platform.LINUX);
capability.setCapability("binary", "usr/bin/firefox");
driver= new FirefoxDriver();
driver.get("mytestproject.com");
but it gives error( though I am using latest selenium jar 2.35.0, tried maven clean and restart of server) :
Failed to connect to binary FirefoxBinary(/usr/bin/firefox) on port 7055; process output follows: Error: no display specified Error: no display specified Build info: version: '2.35.0', revision: '8df0c6bedf70ff9f22c647788f9fe9c8d22210e2', time: '2013-08-17 12:46:41' System info: os.name: 'Linux', os.arch: 'amd64', os.version: '3.5.0-21-generic', java.version: '1.7.0_25' Driver info: driver.version: FirefoxDriver
org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:118)
at org.openqa.selenium.firefox.FirefoxDriver.startClient(FirefoxDriver.java:251)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:110)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:195)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:190)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:186)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:99)
I have checked using sudo lsof -i :7055that nothing is using this port (via putty on remote ubuntu machine)
But after reading many forums I couldnt solve it. So I tried to use phantomjs but it also gave error :
I tried :
dCaps = new DesiredCapabilities();
dCaps.setJavascriptEnabled(true);
dCaps.setCapability("takesScreenshot", false);
driver = new PhantomJSDriver(dCaps);
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
driver.get(Prod);
It gave red line below driver = new PhantomJSDriver(dCaps); . Actually I dont know how to use Phantom.js in Maven project.
What I want to achieve : I want to run test case on this remote ubuntu staging server, nomatter headless (ghostdriver) or firefox.
I think it might be failing from Jenkins because it is running in a new terminal window with no display defined. It appears as though the Firefox process doesn't allow this.
"Error: no display specified"
This might help:
How can I specify a display?
Why you not let it to use default Firefox binary? Jenkins need only Firefox that is installed for All Users. If i remember correctly firefox is default in any Ubuntu.
Failed to connect to binary FirefoxBinary(/usr/bin/firefox) on port 7055;

Resources