I would like to run local server tests on real devices using appium. Are there any existing capabilities which i could use to do so ? I basicall have a server running on a port on my local machine but would like to test it on a real device.
For example i want to test http://locahost:3000 on a real device. how can this port be avaialble on the real mobile device? I know Browser/Stack or Sauce labs implement this using their own local binaries. Can this be done with appium ?
Note: I have my grid setup ready with real devices configured and i can run other tests normally.
EDIT: Just to make it clear and to avoid irrelevant answers. I am looking for something like network sharing from the machine where the tests are invoked to run on real devices. i want to to test a server which is hosted locally and not avilable on the internet.
In order to test on real device, your device must be connected to your computer. To run the test on multiple devices, multiple instance of appium server must be run. You must use device udid in DesiredCapabilities to run the test on the specific device.
To run the appium server in port 3000 you must run the following command in terminal:
appium -a 127.0.0.1 -p 3000 --session-override
Appium server must be installed in your system in order to run above command.
Using port 3000 is not recommended as other program may be using the same port.
To run the app in real device you can define your AppiumDriver and DesiredCapabilities like following:
public class Test1(){
public static AppiumDriver<MobileElement> driver;
public static void main(String[] args){
DesiredCapabilities caps=new DesiredCapabilities();
caps.setCapability(MobileCapabilityType.UDID, "your device udid");
caps.setCapability(MobileCapabilityType.DEVICE_NAME, "android device");
caps.setCapability(MobileCapabilityType.PLATFORM_NAME, MobilePlatform.ANDROID);
caps.setCapability("appPackage", appPackage);
caps.setCapability("appActivity", appActivity);
caps.setCapability(MobileCapabilityType.AUTOMATION_NAME, "uiautomator2");
try{
driver == new AndroidDriver<MobileElement>(new URL("http://127.0.0.1:3000/wd/hub"), caps);
}catch(Exception e){
e.printStackTrace();
}
}
Please check below link to apply proxy settings in Appium.
https://www.npmjs.com/package/appium-proxy#setup-a-basic-appium-proxy
Related
We have Jenkins server hosted in Linux server, and we want to trigger our selenium tests from Jenkins to different remote desktops (Windows) using selenium grid (Here, Jenkins, hub, and node all three are in different machines).
Note: We aren't allowed to host Selenium hub in the same machine where we have Jenkins or install any Selenium Grid plugin in Jenkins.
You can use remote driver. Here is simple example
options = webdriver.ChromeOptions()
driver = webdriver.Remote(command_executor='http://<your_windows_IP_ADDR>:4444/wd/hub', options=options)
It will be in your code, you will run Selenium Server(Grid) on your Windows device. Then you can configure any setup after that.
In my protractor config file, I had this line, seleniumAddress: 'http://localhost:4444/wd/hub'. On running Protractor I was getting an error "ECONNREFUSED connect ECONNREFUSED". After going through lot of other existing issues and solutions, I removed "seleniumAddress" property. That resolved the issue. Selenium standalone server gets started. "Selenium standalone server started at http://192.168.1.156:64477/wd/hub"
But when I turn on the VPN, then I get an error "Error: Timed out waiting for the WebDriver server at http://192.168.1.156:63199/wd/hub", which I have been not able to resolve.
I am on a HP laptop which has Windows 7 Professional and I am using Cisco VPN.
(Hi, so I can't comment yet (low rep)...)
Could you try running webdriver-manager start before running protractor? It will run in the address http://localhost:4444/wd/hub which is the seleniumAddress referred to in the protractor config. Does that change anything?
This might be related (VPN-workaround): protractor stand alone selenium fails: Error: Timed out waiting for the WebDriver server at
Check the settings of the firewall that stays between Selenium standalone server (which might run also on your local host) and your working station (usually your localhost).
In my case (running on local Linux station) I had a very restrictive iptables firewall rules such that the WebDriver process launched on localhost could not access the Selenium standalone server which also run on localhost at whatever TCP port.
Just try to turn it off and check if that is the case ; then accommodate your firewall settings such that the respective connection passes your firewall rules.
If you want your scripts communicate directly with the Firefox|Chrome Driver (bypassing the Selenium server entirely) then try adding the directConnect: true in your protractor.conf.js
Git and other tools, often use the git: protocol for accessing files
in remote repositories. Some firewall configurations are blocking
git:// URLs, which leads to errors when trying to clone repositories
or download dependencies. (For example corporate firewalls are
"notorious" for blocking git:.)
If you run into this issue, you can force the use of https: instead,
by running the following command: git config --global
url."https://".insteadOf git://
(see Common Issues on Angular tutorial)
I'm using Java but this isn't necessarily a Java question. Google's "java-compat" image is Debian (3.16.7-ckt20-1+deb8u3~bpo70+1 (2016-01-19)).
Here is my Dockerfile:
FROM gcr.io/google_appengine/java-compat
RUN apt-get -qqy update && apt-get qqy install curl xvfb x11vnc
RUN mkdir -p ~/.vnc
RUN x11vnc -storepasswd xxxxxxxx ~/.vnc/passwd
EXPOSE 5900
ADD . /app
And in the Admin Console I created a firewall rule to open up 5900. And lastly I am calling the vnc server itself in the "_ah/start" startup hook with this command:
x11vnc -forever -usepw -create
All seems to be setup correctly but I'm unable to connect with TightVNC. I use the public (ephemeral) IP address for the instance I find in the Admin Console followed by ::5900 (TightVNC requires two colons for some reason). I'm getting a message that the server refused the connection. And indeed when I try to telnet to port 5900 it's blocked.
Next I SSH into the container machine and when I test the port on the container with wget xxx.xxx.xxx.xxx:5900 I get a connection. So it seems to me the container is not accepting connections on port 5900. Am I getting this right? Is it possible to open up ports and route my VNC client into the docker container? Any help appreciated.
Why I can't use Compute Engine. Just to preempt some comments about using google's Compute Engine environment instead of Managed VMs. I make heavy use of the Datastore and Task Queues in my code. I don't think those can run (or run natively/efficiently) on Compute Engine. But I may pose that as a separate question.
Update: Per Paul in the comments... having learned some of the docker terminology: Can I publish a port on the container in Google's environment?
Out of curiosity - why are you trying to VNC into your instances? If it's just for management purposes, you can SSH into Managed VM instances.
That having been said - you can use the network/forwarded_ports config to route traffic from the VM to the application container:
network:
forwarded_ports:
- 5900
instance_tag: vnc
Put that in your app.yaml, and re-deploy your app. You'll also need to open the port in your firewall (if you intend on accessing this from the public internet):
gcloud compute firewall-rules create default-allow-vnc \
--allow tcp:5900 \
--target-tags vnc \
--description "Allow vnc traffic on port 5900"
Hope this helps!
I am trying to set up an environment for end-to-end testing on a droplet running Ubuntu server 12.04.3 on digital ocean.
What I am trying to achieve in the end is for my jenkins (installed on the one droplet) to be able to run my end-to-end tests. Now, the server is ofcourse headless and the end-to-end tests need to run through a browser (I am using protractor with the selenium standalone server with chromedriver).
My question is: how do I spawn a browser on that machine? I have installed xorg and if I do startx on the server, log out and ssh -X to it, I can manually run the end-to-end tests (a browser pops up on my local machine). But I can get it to work without ssh -X to it, and since jenkins is on the same droplet where the tests are to be run. Well I dont get a browser to spawn.
NOTE: I know I might be missing something really trivial here since I don't fully understand the configuration nor the xorg.
Any hints or a complete answer is very much appreciated, this is giving me gray hair.
Edit: After a little digging I think i got the xorg stuff a bit wrong, i am guessing the purpose of X is to be able to spawn a window on a remote machine ( ie my local machine). And what i am after is more along the lines of a virtual frame buffer such as Xvfb...
There is PhantomJS but with Protractor is buggy and a dead-end.
You can still use Chrome & Firefox headless through docker-selenium or, if you don't like Docker you can do it yourself with ubuntu-headless sample. Both solutions provide Chrome & Firefox by using Xvfb even though there is no real DISPLAY.
UPDATE 2 Seems to be possible to run Xvfb in OSX: http://xquartz.macosforge.org/landing/
UPDATE 1 Mac OSX selenium headless solution:
Enable multi-user remote desktop access to OSX machine
So can test selenium headless on mac. Not headless really but as another user so it doesn't interfere with your current user display.
To do this you need kickstart: http://support.apple.com/en-us/HT201710
Begin using the kickstart utility
sudo /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart -restart -agent
Activate Remote Desktop Sharing, enable access privileges for all users and restart ARD Agent:
sudo /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart -activate -configure -access -on -restart -agent -privs -all
Apple Remote Desktop 3.2 or later only
Allow access for all users and give all users full access
sudo /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart -configure -allowAccessFor -allUsers -privs -all
Kickstart help command
sudo /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart -help
A lot of angular apps use Travis CI to perform Protractor based end-to-end integration tests on headless vms all the time. I do not know the details of exactly how they do it but I do know that they use a linux service called xvfb which is a headless x windows implementation. Looking at a typical Travis configuration file, it appears that all they do before firing up their web server, selenium server and kicking off Protractor is to call sh -e /etc/init.d/xvfb start to start this service.
I have a host with IP 192.168.3.146. This IP is a static IP given from DHCP server.
Now I have VM with network configured as Bridged.
I am seeing the IP as 10.0.2.15.
Since it's bridged should I be getting anything in the range 192.168.3.x assigned to the VM as well?
When I register from this VM to the host I am not able to register the web driver, it just says "Registering" and does nothing until I kill it.
Command used to register the node:
java -jar selenium-server-standalone-2.26.0.jar -role web driver -hub http:/192.168.3.146:4444/grid/register -port 5558 -host 10.0.2.15 -browser "browserName=firefox, version=6, platform=WINDOWS"
Also tried:
java -jar selenium-server-standalone-2.26.0.jar -role node -port 5558 -hub http:/192.168.3.146:4444/grid/register
NOTE: in both commands http:/ is deliberate - please ignore it. I'm actually using // since I was getting error while posting I have used :/
Any suggestions please?
The easiest way to get this setup is to use NAT Networking, and local port forwarding. What's nice about this setup is that you can run everything offline, and not rely on a constantly changing dynamic IP address. Here's how you do that:
Configure the Guest VM to use NAT Networking, add Port Forwarding rules for ports 4444 and 5555.
Host Machine, as Hub
java -jar selenium-server-standalone.jar -role hub -port 4444
Guest Machine, as Node
java -jar selenium-server-standalone.jar -role node -host 127.0.0.1 -port 5555 -hub http://10.0.2.2:4444/grid/register
I use this setup to run multiple instances of the modern.ie VM machines in VirtualBox, and it works very nicely.
hmmmmm....
how about simply running selenium server on remote machine with:
java -jar selenium-server-standalone-2.26.0.jar
and in your e.g. BaseTest.java (where you have your webDriver initialization) you simply add:
static WebDriver driver;
private String loginBaseUrl;
#BeforeClass
public static void firefoxSetUp() throws MalformedURLException {
DesiredCapabilities capability = DesiredCapabilities.firefox();
driver = new RemoteWebDriver(new URL("http://192.168.4.52:4444/wd/hub"), capability);
driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
driver.manage().timeouts().pageLoadTimeout(30, TimeUnit.SECONDS);
driver.manage().window().setSize(new Dimension(1920, 1080));
}
#Before
public void homePageRefresh() throws IOException {
driver.manage().deleteAllCookies();
driver.get(propertyKeysLoader("login.base.url"));
}
#AfterClass
public static void closeFirefox(){
driver.quit();
}
i faced the same issue while trying to run the Remotely via VM's from host. I used Oracle VM Virtual Box.
Since the VM is assigned 2 different IP's one via NAT & other via Bridge adapter ...Hence Selenium node fails to register itself with the Selenium HUB as by default it registers for NAT.
Disconnect/disable the internet of VM NAT N/W adapter for which "10.0.2.15" IP is assigned. Don't Touch the bridge adapter settings...Then try to register the node...it works.
I would suggest to connect Bridge Adapter via VM >> Settings>> Network Screen
Please check the Links below...
http://www.thegeekstuff.com/2012/03/virtualbox-guest-additions/
https://blogs.oracle.com/fatbloke/entry/networking_in_virtualbox1
Hope this helps...All the best :-)
I had the same issue. I have NAT and "Host-only adapter" networks configurated for the virtual machine with default properties. I solved it using the the IP of the "Host-only adapter".
For me, the IP of NAT is 10.0.2.15 (same as you) and the IP of "Host-only adapter" is 192.168.56.101. So I used:
java -jar selenium-server-standalone-2.26.0.jar -role webdriver -hub http://192.168.3.146:4444/grid/register -port 5558 -host 192.168.56.101 -browser "browserName=firefox, version=6, platform=WINDOWS"