Is it possible to connect physical nodes to a docker selenium hub - selenium

When I spin up an AWS instance with a docker selenium image, would I be able to connect nodes that are not running the docker image as a node?
For example, use an AWS instance with the docker-selenium image and then attempt to connect a MacBook to a node (with safari) assuming the networking has been set up correctly, would this work?

I don't see any reason why this would not work, as all interaction between nodes and hub is done through http as far as I remember.
Have you tried it?

Related

Is there any limitation of using selenium hub inside the docker container?

Is there any limitation of using selenium hub inside the Docker container?
Use case: Want to use the selenium hub inside the docker container. I am talking about only hub node will be a virtual machine.
No limitation, you have an example in this repository

Selenium Standalone server

I want to run the selenium test cases in the remote machine.
These are the steps I have followed:
Steps I did in server machine:
I have downloaded selenium-server-standalone-3.9.1.jar + Chrome Driver & placed it in a folder and added it to $PATH environmental variable.
I have started selenium server using java -jar selenium-server-standalone-3.9.1.jar -role hub in the Terminal.
Steps I did in local machine:
I have installed selenium-webdriver & selenium-server-standalone-3.9.1.jar
I wrote a sample testcase using selenium webdriver.
I have started a node here using command java -jar selenium-server-standalone-3.9.1.ja-role node -hub http://172.24.111.70:4444/grid/register in the terminal. The node got connected to the hub.
I run the command node test.js in the terminal. I expect the chrome instance to open in the remote machine. But it is running in the local machine.
Screenshots:
Hub:(Remote)
Node:(Local)
Can you please explain me the mistake I have did here? Have I understood the concept wrong?
The web browser instance which will run your tests will get created on a node not the hub. The hub is how you can register a number of nodes so you can spread the load between different machines/nodes. From what I can tell, you have a hub on the remote machine which you connect a local node to.
What I think you want is to run the node on the remote machine also, registering to the hub on the same machine (you might have to change the IP address of the hub to localhost when registering the node).
So, the problem is you are wanting the tests to run on the Remote Machine, but they are running locally?
From the sounds of it you have done all the setup correctly, and the Hub/Nodes should be working fine. All you need to do, is instead of running the Node from your local machine, run it from the Remote Machine. You just need to think of the Hub as the Supervisor, who hands out work to the Nodes (their employees) to do. The Hub doesn't run any tests itself, it just sends the data to the Nodes and load balances between multiple Nodes.
We have a set up of 6 Remote Machines. Machine 1 has the Hub and a Node, and the other 5 have Nodes. In our project we are pointing towards the Hub, so when the tests run, they get sent there. The hub does the rest (depending on the nodecfg file and the settings you've got in there)

Does Docker Cloud bring your own nodes need to all have the same OS?

Currently, all our nodes are on Ubuntu, but I'm considering switching to CentOS. But I want to stagger the switch over.
Short answer: Yes.
See Introducing Docker Cloud
You can also provide your own node or nodes. This means you can use any Linux host connected to the Internet as a Docker Cloud node as long as you can install a Cloud agent. The agent registers itself with your Docker account, and allows you to use Docker Cloud to deploy containerized applications.

How can anyone run access Selenium test scripts without having to install/run it locally?

I am looking for ways to set up like a central 'hub' for Selenium in my work, allowing anyone to access in within the company. For example, Tester A writes test scripts, the Person B can run without having to manually copy over the test scripts to their local workstation)
So far, I've only thought of installing Selenium in a VM which will then execute as per normal. But if I run Selenium Grid, it will run VMs within VM (?). My only concern with VMs is that it'd run slowly.
If anyone can think of a better solution or recommendation please do give me some advice. Thank you in advance.
One idea. You can create an infrastructure combining Jenkins/Selenium/Amazon.
The following is my solution from another post.
You can do it with a grid.
First of all you need to create a Selenium hub with an EC2 ubuntu 14.04 AMI without UI and link it as a jenkins slave to your Jenkins master. Or as directly a master. What you want. Only command line. Download Selenium Server standalone. (be careful on downloading the version. If you Download the Selenium3Beta, things could change). Here you can configure the HUB. You can also add the Selenium Hub as a service and configure to run automatically at server start. its important that you open the Selenium default port (or the one that you configured) so the nodes can connect to it. You can do that on the Amazon EC2 console when you have created your instance. You just need to add a security group with an inbound rule for TCP in the port you want for the IPs you want.
Then, you can create a Windows server 2012 instance server (for example, that's what I did), and do the same process. Download the same version for Selenium and the chromedriver (there is no need to download any firefoxdriver for Selenium versions before Selenium3). Generate a txt file and prepare the Selenium command to link to the HUB as a NODE. And convert it to *.bat in order to execute it. If you want to run the bat at start you can create a service with the task scheduler or use NSSM (https://nssm.cc/). Don't forget to add the rules to the security groups for this machine too!
Next, create the Jenkins server. You can use the Selenium Hub as the Jenkins master or as a slave.
Last step is configuring a job to be run in the Jenkins-Selenium machine. This job needs to be linked to your code repository (git, mercurial...) Using the parametrized build plugion for jenkins you can tell that job to pull the revision you want (where every developer can pull the revision with the new changes and new tests) and run the Selenium tests in that build with the current breanch/revision and against one unique selenium. You can use ANT or Maven to run the Selenium tests in Jenkins.
May be it's complicated to understand because there are so many concepts here but it's robust and it works fine!
If you have doubts, tell me!
If Internet Explorer is not one of the browsers on which you must run your automation tests, I would recommend that you consider docker selenium.
Selenium is providing pre-configured docker images for both Selenium Hub and Node ( refer here for more information ). For making use of docker selenium all you need to do is find a machine (preferably unix machine), install docker on it by following instructions detailed here and then start the hub and node by starting off those containers. In the case of docker you can literally transform a VM (or) a physical machine into a VM farm and yet not have to worry about slowness etc., because I believe docker is optimised for these and it runs your VM as a process.
Resorting to using Amazon cloud for running your selenium nodes is all fine, but if you have corporate policies that prevent in-coming traffic from the internet into your intranet region, then I am not sure how far Amazon cloud would be useful.
Also remember that Jenkins is not something that is absolutely required but is more of a good to have part in the setup because it would let anyone run their tests from a web UI. This will however require that all your tests are checked-in and made available in a central version control system in your organization.
PS : The reason why called out Internet Explorer as an exception is because IE runs only on windows and there are no docker images (yet) for windows. All the docker images are UNIX based images.

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.