Selenium Grid + Jenkins Infrastructure execution - selenium

Pardon me for the lengthy description:
I have the following infrastructure where I am attempting to deploy the Selenium grid via Jenkins. For the sake of simplicity, I am using simplified IP addresses.
Machine 1 (Jenkins):
IP: 1.1.1.1
Machine 2 (The Test Script + The Firefox RC instance resides on this)
IP: 2.2.2.2
Machine 3 (The IE RC instance resides on this)
IP: 3.3.3.3
Now, I am starting instances of RC as follows:
Machine 2:
RC 1: ant -Dport=5555 -Denvironment=*firefox -Dhost=2.2.2.2 -DhubURL=http://1.1.1.1:4444 launch-remote-control
Machine 3:
RC 2: ant -Dport=5556 -Denvironment=*iexplore -Dhost=3.3.3.3 -DhubURL=http://1.1.1.1:4444 launch-remote-control
After doing this, I am able to establish connection on the Jenkins Selenium console for both Machine 2 and Machine 3.
As far as my test script (residing solely on Machine 2) is concerned -
For firefox,
selenium = new DefaultSelenium("1.1.1.1",4444,"*firefox","http://mytestURL.com")
For IE,
selenium = new DefaultSelenium("1.1.1.1",4444,"*iexplore","http://mytestURL.com")
The problem is that I unable to get the test script to execute on Machine 3, where the IE instance resides.
What settings do I have to make in the DefaultSelenium object to get the test script residing on Machine 2 to execute on Machine 3, via the Jenkins grid?
Thanks for looking.

The problem was with the host's IP address on Machine 3. This works as expected.

Related

Selenium Standalone Servers giving error "DefaultRemoteProxy unknown version,Connect to 10.0.2.15:5566 [/10.0.2.15] failed: connect timed out"

Selenium Grid Testing:
I have installed virtual box in my system and I am trying to use my local system as hub and the windows machine in the virtual box as node.
Whatever the selenium standalone server I use ( I tried a lot of versions) but it is always giving me the error "DefaultRemoteProxy unknown version,Connect to 10.0.2.15:5566 [/10.0.2.15] failed: connect timed out" on the grid console.
In the Command Prompt initially it is saying that the node is registered successfully but after some time it is saying " Marking the node http://10.0.2.15:5566 as down: cannot reach the node for 2 tries".
I have attached the screenshot. Because of this the tests are failing.
I have disable the windows firewall as well on both local and virtual box windows systems. But still no luck.
Is there anything wrong I am doing?
Can someone please help me with this?
Selenium Grid Console:
After trying a lot, I got the answer finally. This is related to network setup between my local host and the VM.
In VMBox, under the settings for a particular system, under network I have added one more adapter which is "Host-only adapter" in addition to the NAT and it resolved my problem.

Testing site with IP addr whitelist using BrowserStack automate + cloud hosted CI

I have a test system (various web pages / web applications), that is hosted in an environment accessible only via machines with IP addresses that are white listed. I control the white list.
Our CI system is cloud hosted (Gitlab), so VMs are spun up dynamically as needed to run automated integration tests as a part of the build pipeline.
The tests in question use BrowserStack automation to run Selenium based tests, which means the source IP addresses of the BrowserStack automation driven requests that hit the test environment are dynamic, as BS is cloud hosted. Also the IP addresses of our test runner machines that call / invoke the BrowserStack automation are dynamic as well.
The whole system worked fine before the intro of IP white listing on the test environment. Since white listing was enabled, the BrowserStack tests can no longer access the environment URLs (due to not being able to white list the dynamic IPs).
I have been trying to get the CI driven tests working again using BS "Local Testing" feature, outlined here https://www.browserstack.com/local-testing.
I have set-up a dedicated Linux VM with a static IP address (cloud hosted). I have installed and am running the BrowserStackLocal.exe binary, using our BS key. It starts up fine and says it has connected to BrowserStack via a web socket. My understanding is this should cause all http(s) etc requests that come from my CI / BrowserStack automation driven tests to be routed through that stand-alone machine (via BS cloud), resulting in it's static IP address being the source of the requests seen at the test environment. This IP addr is white listed.
This is the command that is running on the dedicated / static IP machine:
BrowserStackLocal.exe --{access key} --verbose 3
I have also tried the below, but it made no apparent difference:
BrowserStackLocal.exe --{access key} --force-local --verbose 3
However, this does not seem to work? Either through "live" testing if I try and access the test env directly through BrowserStack, or through BS automate. In both cases the http(s) requests all time out and cannot access our test environment URLs. Also even with --verbose 3 logging level enabled on the BrowserStackLocal.exe process, I never see any request being logged on the stand-alone / static IP machine when I try to run the tests in various ways.
So I am wondering if this is the correct way to solve this problem? Am I misunderstanding how to do this? Do I need to run the BrowserStackLocal.exe perhaps on the same CI runner machine that is invoking the BS automation? This would be problematic as these have dynamic IPs as well (currently).
Thanks in advance for any help!
EDIT/UPDATE: I managed to get this to work!! (Sort of) - it's just a bit slow. If I run the following command on my existing dedicated / static IP server:
BrowserStackLocal.exe --key {mykey} --force-local --verbose 3
Then on another machine (like my dev laptop) if I hit the BS web driver server http://hub-cloud.browserstack.com/wd/hub, and access the site http://www.whatsmyip.org/ to see what IP address comes back, and it did (eventually) come back with my static IP machines address! The problem though is it was quite slow - 20-30 secs for that one site hit, so still looking at alternative solutions. Note for this to work your test code must set the "local" browserstack capability flag to 'true' - eg for Node.js:
// Input capabilities
var capabilities = {
'browserstack.local' : 'true'
}
UPDATE 2: Turning down the --verbose logging level on the local binary (or leaving that flag off completely) seemed to improve things - I am getting 5-10 sec response times now for each request. That might have to do. But this does work as described.
SOLUTION: I managed to get this to work - it's just a bit slow. If I run the following command on my existing dedicated / static IP server (note adding verbose logging seems to slow things down more, so no --verbose flag used now):
BrowserStackLocal.exe --key {mykey} --force-local
Then on another machine (like my dev laptop) if I hit the BS web driver server http://hub-cloud.browserstack.com/wd/hub, and access the site http://www.whatsmyip.org/ to see what IP address comes back, and it did come back with my static IP machines address. Note for this to work your test code must set the "local" browserstack capability flag to 'true' - eg for Node.js:
// Input capabilities
var capabilities = {
'browserstack.local' : 'true'
}
So while a little slow, that might have to do. But this does work as described.

How to restrict access to Selenium Standalone Server instance?

I have an instance of Selenium Standalone server in a virtual Widows box to run my tests on. It's being started in the following way:
java -jar selenium-server-standalone-2.46.0.jar -D"webdriver.chrome.driver"=chromedriver_2.13.exe -D"webdriver.ie.driver"=IEDriverServer_2.44.exe
Today I've noticed in the output some unexpected lines. The tests are running in the night and after that I see following:
08:46:20.197 INFO - Couldn't proxy to http://www.cv7.waw.pl/108258/Dachy/artykul.html because host not found
11:12:07.873 INFO - Couldn't proxy to http://g1nkaku.bieszczady.pl/damy-rade-zespol-na-wesele-bydgoszcz because host not found
11:49:49.204 INFO - Couldn't proxy to http://www.swiat.opt.waw.pl/Kryszyn/planeta-102-7/ because host not found
None of my tests were accessing any of such links, especially at these timestamps, and I have no idea where it can come from. My assumption is that someone found out the link to this instance of Selenium server and was sending requests through it.
What are my options to restrict access to Selenium server? Are there any options to request some custom login/password for all clients of this server? It's being used by several people in our team from multiple locations, so IP based checks are not an option.

SeleniumRC with Jenkins

I wrote some junit test cases using seleniumrc . I am trying to integrate the test cases with Jenkins.
I installed seleniumrc-plugin for eclipse.I am unable to add the test cases to jenkins.
In Jenkins--> COnfigureProject --> Build Environment --> Create Seleniumrc instance ,I entered all the details for
Host , Port ,Browser ,OS
After that,I don't know what to choose for Build. I tried going through this source
https://wiki.jenkins-ci.org/display/JENKINS/SeleniumRC+Plugin
but couldnt figure out a way. Can anyone please explain me in detailed what to do next?
Try to configure Selenium manager and Remote Agents according to pt. 1 and 2.
After that on Jenkins CI configure Host and Port which must point to machine where "Selenium manager instance" is launched (it can be the same or another machine)

How to connect selenium grid on other machine?

Here what i have done :
1) created testcase in selenium IDE - TestNg format( local system)
2) altered in Eclipse
3) Installed selenium grid on different machine (call ex 123.123.12.12 - linux)
4) Trying to run build.xml from local system
Default Selenium(host, port,browser, url)
Now its not connecting to 123.123.12.12 for runnin test case
what i have to do? Is it i am missing something or what is the procedure to achive this scenario?.
Thanks a lot.
By.
Mani
Download Selenium Grid on the different machines that are needed.(One to run Hub (Hub) and other to launch the RC instances(RC1 & RC2))
Example:
- Hub: 192.168.1.10
- RC1: 192.168.1.1
- RC2: 192.168.1.2
Launch the hub
a. Log in the machine you want to use as the hub (192.168.1.10).
b. Enter “ant launch-hub” command to launch the hub.
Launch RC1 :
a. log in the machine you want to launch the first RC instance (192.168.1.1)
b. enter “ant -Dport=5556 -Dhost=192.168.1.1 -DhubURL=http://192.168.1.10:4444 launch-remote-control”
Launch RC2 :
a. log in the machine you want to launch the first RC instance (192.168.1.2)
b. enter “ant -Dport=5556 -Dhost=192.168.1.2 - DhubURL=http://192.168.1.10:4444 launch-remote-control”
Enter http://192.168.1.10:4444/console link in address bar of browser and verify that ports are available.
Now run the tests.
a. Log in the host machine 192.168.1.10.
b. Enter “ant run-demo-in-parallel” command.