is selenium grid a solution to my problem with executiontimes? - selenium

Hi all I am using TestNG framework for selenium webdriver scripts. I run them on Jenkins on two slaves one being windows the other being linux. I have close to 100 test cases and they take 2hrs 40 mins on each machine. I would want to speed up the execution time. will selenium grid be helpful in this case?

No. Selenium grid would not be the solution. Selenium grid can multiply the same action, not taking different actions in parallel.
You should look for the opportunities in test parallelization.

Selenium grid is designed to allow you to run test in parallel
The page says:
Selenium Grid allows us to run tests in parallel on multiple machines, and to manage different browser versions and browser configurations centrally (instead of in each individual test).
However it's not as easy as installing it and connecting up.
You'll need to ensure the rest of your framework and tests are capable of parallel execution. Most important part is to watch out for your test data e.g. if multiple tests rely on the same data source and they try and update it at the same time you'll get flaky results.
You're also capable of running tests in parallel on a local machine without selenium grid. If i were you i'd start with this first.
Typically most machines have the resources to run more than one browser - get it running locally before you go to far down the grid rabbit hole.
Here's a link for testng
Also worth a review is zalenium - a docker image that contains a grid + auto scaling nodes allowing easier browser control on a single machine.

Related

Is it possible to login different nodes with different login ID's parallelly using selenium grid?

I am tiring to login to Gmail account with different user name with selenium grid (java) parallelly. I have 5 nodes each node should use different user name. All the user names are provided in excel. Can anyone help me to do this action?
Selenium Grid allows the execution of WebDriver scripts on remote machines (virtual or real) by routing commands sent by the client to remote browser instances. It aims to provide an easy way to run tests in parallel on multiple machines.
Selenium Grid allows us to run tests in parallel on multiple machines, and to manage different browser versions and browser configurations centrally (instead of in each individual test).
Selenium Grid is not a silver bullet. It solves a subset of common delegation and distribution problems, but will for example not manage your infrastructure, and might not suit your specific needs.
Please note Grid 3 is not supported anymore and the Selenium project recommends to use Grid 4

Execute a Firefox Browser in a Docker Container for Selenium testing

I have a Java Application, which controls an automated GUI test in a FF-Browser via Selenium WebDriver Libraray. The Java App reads test cases from a database and executes them according to the code logic.
For instance, if the app reads in a Field, it'll search it by using the "findElement"-method from the Selenium framework. I do not use any test scripts for Selenium.
Currently this is happening on a local workingstation of an employee.
Now I want to move this whole environment into a Docker container.
Is it even possible to instantiate a Firefox Browser in a Container?
btw: I do not need to see the actual GUI of my browser.
And secondly:
There are several containers with selenium on dockerhub ready to use, but these do not fit my surroundings am I right?
As far as I know the SeleniumGrid expects testscripts and cannot be executed through runtime.
I open up a Linux VM (Debian:Jessie distribution) with Vagrant, in which then runs Docker.
I am still a beginner with Docker.
I couldn't find any question around here regarding my purpose.
Thanks in advance!
Is it even possible to instantiate a Firefox Browser in a Container?
Yes. The simplest way to do this is would be using the selenium images on Docker Hub.
There are several containers with selenium on dockerhub ready to use, but these do not fit my surroundings am I right?
If you think the Selenium images don't work for you because they are all based on Selenium Grid, you can use the StandaloneFirefox and StandaloneChrome images instead. These are individual instances, they do not use Selenium Grid.
BTW, the non-Debug Selenium images do not have a GUI. You mentioned you didn't need to see the browsers running so these should be fine. If you do need to see the browsers, the Debug images have a VNC server installed so you can run the image, connect with a VNC client, and watch the browsers run the tests.

Can manipulate multiple windows in Xvfb simultaneously

I'm using Xvfb + Selenium standalone server to do some webpage testing. I have multiple remote web drivers(threads) to send request to selenium server, but looks like if multiple testings run in parallel, the performance is much slower than that of running tests one by one.
Does Xvfb has restriction on the number of windows that can be opened, say firefox windows/instances?
If two firefox windows are running inside Xvfb, can these two windows be manipulated at same time, say clicking a link on the page? As we know, on a desktop display, only the most top window can be manipulated, like clicking and entering something on the page.
Do I need to setup a Xvfb process for each selenium test to get better performance?
Thanks!

Automated testing web application

I am looking for a tool to functionally test my Yii/ Node.js web application. The first thing I looked into was Selenium. The app runs on a headless Ubuntu server so successfully setting up xvfb and run a test was really painfull and drove me to another tool.
The error I kept getting is:
Xlib: extension "RANDR" missing on display :0
The other tool was Casperjs along with Phantomjs . Aside from the 5 minute setting up, I wrote few tests and integrated all with Jenkins CI. I really believe there should be more tools like this one. So I feel I've earned something on the short term, but I'm afraid that on the long term I'll hit a dead end. Could you give me some feedback? Am I going the wrong road?
Another thing that's crossing my mind is to setup the Selenium RC and Jenkins on a Windows machine with all browsers set up. I think this will give my tests a better and more accurate perspective.
* I would also like to be able to do some parallel functional tests (interactions) since the website is socket-driven. Does Selenium handle that?
First off, don't use Selenium RC if you can avoid it, it's officially deprecated in favor of Selenium Webdriver (also known as Selenium 2).
About headlessness - Webdriver can be easily run on top of HtmlUnit and also PhantomJS - both should work right away.
If you want to run the tests on actual browsers, people have been successful in running that on headless systems, too, but as you said, it's a pain. Instead, you can run the tests remotely on a different machines with your headless server commanding them all.

selenium grid 2 ready, how do I send a "test" job to the remote server?

On my linux box somewhere in the United States, it's running Selenium Grid 2.
Currently 3 people will be regularly running parallel tests, but there's potential for more people to join and running more parallel tests....
now they are in other parts of the world, they need to submit an xml file which contains the test data, and the server needs to parse this and figure out the rules.
How can the client invoke a test to run on the remote server? via HTTP POSTing the xml file to the url in which the grid is running on?
Is it cheaper to just rent out a fast linux server and then buy more as number of parallel tests increase?
Or should I right off the bat, hook it up to Amazon ec2? If there are parallel tests on an ajax heavy web applications running 24/7, would it be cheaper to go with the single dedicated box or amazon? google app engine (no plugins for grid?)?
I am not sure I understood the xml submitting part in your question. However, I can tell you an example which will help to you understand how to submit the tests to grid.
Three people, PersonA, PersonB and PersonC are creating selenium tests in their local machine. They currently run the test using an ANT build (or something similar) against the selenium server jar which is in their local machine. In their code they would be having a line of code which tells which selenium instance should be used to run this test. This will be mostly like
new DefaultSelenium("localhost",port,browsername,URL)
Now these people want to move to selenium grid (1 or 2). Here is what they will have to do to use the grid
All they have to do is change the command
new DefaultSelenium("localhost",port,browsername,URL)
to
new DefaultSelenium("hubIPAddress",portInWhichHubWasStarted,browsername,URL)
Note:- browserName - Make sure there is a remote node registered in Hub for the same browserName.
Now all the commands will be sent to Selenium Hub and Hub would execute the commands using the remote nodes.
Hope this helps. Please post if you have any questions.