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

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

Related

How to launch chrome driver on any remote machine

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

Hugo webserver not reaching my Windows vm

I want to test my website on edge and internet explorer so I tried using a windows VM, I am currently on linux mint 19.1, I start the gohugo server with "hugo server --disableFastRender" and create the VM in virtualbox using bridged adapter but I cant load localhost:1313 on the vm.
I tried using NAT and port forwarding but I have the same results, also tried the conection between the host and VM using ping and the VM can reach the host but the host cant connect to the VM so I guess that the problem is there but I dont know what to do now. The place where I am working uses IPv6 and I never worked with it before so maybe it has something to do with that
Start your site as usual with hugo server, which makes it available at http://localhost:1313
Leave your Windows VM network settings at their defaults
In your Windows VM, navigate to http://10.0.2.2:1313 to hit your hugo site
In a nutshell, 10.0.2.2 on your Windows VM (its default gateway) is equivalent to localhost on your linux host.
You can get the default gateway of your Windows VM by running ipconfig in Command Prompt.

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 the InternetExplorerDriver through a linux VM?

What are the options here as our plan is to be able to execute selenium tests on a linux (CentOS) vm using jenkins to schedule the execution using selenium and we only need to test Internet Explorer 9 at this time.
Has anyone had any luck using Wine with them?
What are my other options?
Thanks.
Hmm, consider this more like a guess than an answer:
I would go by the path of investigating the Selenium Grid in setup that your main machine with CentOS would play "hub" role and virtual machine would be "node" - Everything you need to investigate is how to "see" the virtual machine by entering its IP. I think this should be somehow possible, but do not know how to setup it