How to launch chrome driver on any remote machine - selenium

I have a requirement where i need to launch the chrome browser on a remote machine. I have explored selenium grid but it requires some static configuration on the remote machine. In my case the remote machine vary and the IP is taken from a properties file hence it is not possible to create all those machines as hub.
Could anyone help me with a more generic way by which i can dynamically launch the chrome driver on the machine for which i read the IP from properties file?

Option 1 :
Check with the team provisioned IP address for the machine. It is possible that IP you are using is public IP (public IP address may change when machine is restarted) . Team can provide you with a private IP(it remains static) and a VPN to access the machine. If you are able to access the machine using this solution , setup selenium grid ,and you will be able to run your tests
Option 2 :
If you get a new machine for every run, request the machine with docker enabled, so you can spin up a selenium grid infrastructure using docker and run your tests there

Related

How to launch the browser on client side using selenium webdriver

I am new to selenium. I am developed one application using a selenium web driver for doing some actions on the webpage. It's perfectly working when I am running locally i.e., it launches a browser in my machine. I deployed this application on a VM server so the script runs on the server(launched browser in VM Ware Machine), not on the client-side. Can anyone help me with how can I launch the browser on the client-side?
You have to create Hub and Nodes using selenium grid
You can refer this link to see step by step
http://www.seleniumeasy.com/selenium-tutorials/how-to-configure-selenium-grid
Your server will be hub and your client machine will be node
If you trigger from one machine, you can launch a browser on another machine using the selenium-grid concept
But both machines are under the same LAN.
Here you want to execute on the client machine. It is not possible, because your machine and client machine won't be under the same network

Can I use java to get the remote ip address of the Sauce Labs machine running my test?

I want to use the Robotil class to remotely press keys on a sauce labs machine but I need the IP and port for that machine and it can change each run. Is there a way to get this in runtime using java/selenium?
It is not possible. As per Robotil
1) Download Robotil.jar
2) Start Robotil server on a remote machine.
So you have to place the Robotil.jar in the remote machine and have to execute the jar file.
And SauceLabs only provides grid URL and can be used only to create RemoteDriver Instances , it wont allow you to execute shell/windows scrips or do file transfer and all.

PHPUnit Selenium tests fail on Docker localhost and pass using public IP

I'm trying to setup an automated testing platform with Docker and Selenium Grid.
In the diagram below you can see the structure that I'm using.
On top is the ubuntu server running on Compute Engine.
On the left is a docker container running ubuntu 14.04.
The container runs our project on localhost:8080 with Google App Engine.
On the right is the Selenium Hub with two nodes running on port 4444.
There is portforwarding from the host to the docker aswell as to the selenium hub. On 32772 and 32768 respectively.
When running my Selenium tests I send them to the hub, which in its turn will run the tests on the localhost of the docker.
My problem is that when I tell the hub to run the tests on 172.17.0.2:8080 it opens the startup screens, but it can't submit any forms.
When I submit the form the text areas get cleared. Like the page is refreshed in some way. The strange thing is that when I tell the hub to use the external ip of the host and the port of the docker like this xx.xx.xx.xx:32772, it does work.
And it has all the functionality. However for performance and automation reasons I'd like to run it on the internal ip adress.
Any help would be appreciated.
Tijn
The problem was in my .env file. The Session Domain was set to the host ip instead of the internal ip adress. By changing it, the website worked like it should.

How can I run Selenium tests when my site is in Vagrant?

I use Vagrant for my local development. Now I want to use Selenium for automated browser testing. When I setup Selenium in my VM, it works like a charm (great stuff by the way).
But now I want to move the Selenium testing out of the box. I tried to run the Java server on my host machine, forward port 4444 to port 4444 in virtualbox, and then fire the phpunit-command in VirtualBox, hoping to trigger the server on my host machine.
But instead I get a CURL-message that phpunit can't connect to 127.0.0.1:4444, so obviously there is no connection to my host machine on this port.
Can anyone tell me what I'm doing wrong?
Edit: I figured out that when I'm running the server on the host, I cannot access 127.0.0.1:4444 in my browser, however, I am able to access localhost:4444. Which is weird, because my hosts-file has the correct line (although it shouldn't matter since phpunit is trying to access a numeric address).
I think the best solution for this is to setup a "private network" this way you'll be able to use internal address to access your vm and host separately...
Depending of your vm provider different solution are possible (for example, Virtualbox support internal netowrk only)
Have a look at : http://docs.vagrantup.com/v2/networking/private_network.html

Why Selenium Grid need Host name or Ip address of the machine

If I have 10 similar machine (Browser, OS) to execute a test suite in selenium grid, why do ineed host name or Ip address of the machine?
Selenium hub needs to pass the commands to the RC which is running in other machines as http commands. You would obviously need the IP address or Name of the machine for hub to identify the machine. The below link would provide more details
http://selenium-grid.seleniumhq.org/how_it_works.html