Executing the selenium tests from remote java application - selenium

We have are planning to design a system where we are planning to invoke the Selenium test that is present in a remote machine with url for testing. The selenium program should open 3 browsers for example IE, FF and Chrome and open the page and take a screenshot of it. Later These screenshots should be sent from this machine to the java application.
Is it possible to achieve this functionality ? If so could you please guide me on how to do this ?

Yes, you need to start a Selenium Grid/Node server on the remote machine that is configured to run all 3 browser types. That configuration isn't easy but it involves launching the grid from a .json config file. Then, your local program needs to just run the 3 tests either in 3 simultaneous threads, or one at a time using typical Selenium code.
Each test needs to define a Selenium Augmenter to get screenshots. There are lots of examples on Google.

Related

Jmeter with Selenium runs scenario Sequentially and not paralelly

We have a Junit Framework where in we have written the methods using Java/Selenium ( which occasionally we use for regression testing as well). Same methods we are mapping it to JMX file and then triggering the Jmeter to test our performance tests. all the methods have #Test annotation for Jmeter to detect.
I am launching Jmeter through command prompt with command
jmeter.bat -n -t c:\dev\test.jmx -Jusers = 3
Jmeter launches 3 browsers, but operation on Browser will happen only when i bring the browser to focus, that is username will enter in Browser 1 if its in focus , similarly in Browser 2 if its in focus. If not in focus then its failing that method. How can i overcome this problem.
Thanks in advance.
Well-behaved Selenium tests shouldn't require the browser to be in focus otherwise executing tests via Selenium Grid or in Headless mode won't be possible.
So my expectation is that the problem is not connected with JMeter, it's rather about your Selenium Java code which is relying on the browser to be in focus, please review your code and ensure that you're only using Selenium API (or Java API) for any browser manipulations including:
filling in forms
uploading files
downloading files
etc.
For instance if you're using any Robot class functions - these classes are a subject for refactoring.
The above issue got resolved once we started executing Chrome in headless mode. It is working fine now.

i want to run my jmeter web driver script for 100 user without open browser

when i was run jmeter webdriver script multiple browser is open and this condition not get accurate load testing report so how i get proper load testing report without open Browser?
As per WebDriver Tutorial
Note: It is NOT the intention of this project to replace the HTTP Samplers included in JMeter. Rather it is meant to compliment them by measuring the end user load time.
So you should not be using WebDriver Samplers to create the main load as browsers are very resource intensive and most probably you won't be able to kick off more than 5-10 browsers on a single machine.
If your requirement is to conduct the load testing using 100 real browsers - you will have to go for Distributed Testing
If you want to use existing Selenium tests as a basis for a protocol-based load test you should record them using JMeter's HTTP(S) Test Script Recorder. You can set the proxy for your WebDriver tests as follows:
So we have an option to run webdriver smaplers without opening the browsers if you are using chrome browser for this. You add jp#gc - Chrome Driver Config config element and there are 3 tabs in that those are "proxy", "chrome" and "Experimental". So you click on "chrome" tab and check the check box of Use Chrome headless mode. See the screenshot below.
In reality if you want to run webdriver samplers for more than 100 browser then I would suggest you that u use distributed test. Because browsers are resource consuming if you run around 4 browsers then your system starts hanging. so you cannot run 100 browsers. So go with Distributed testing in jmeter.

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.

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.

How to setup Selenium RC to test any website on the internet?

I'm new in using Selenium.
Selenium IDE is a user-friendly firefox plugin. I have no problem in using it. However, I found that the documentation for other Selenium tools such as Selenium RC and Selenium Core is quite confusing for beginners. It seems that the author assume that the readers already have deep knowledge in using these tools.
For example, when I try to figure out how to setup Selenium RC to test a webserver, the only diagram i can find from the Selenium website is this:
http://www.sparksupport.com/blog/wp-content/uploads/2010/11/selenium-rc.png
From this diagram, i can't even see which one is the webserver under test and where should i install the Selenium components.
At first I thought this diagram is a bit weird and i should be able to get a better diagram from other websites. I was surprised to find that almost all Selenium RC setup diagram on the internet are similar to this diagram (clones). No one has ever attempted to create a different diagram or give more description for Selenium RC setup.
Appreciate if anyone can give me guidance on how to setup Selenium RC. The things that i want to know are:
Can i use Selenium RC to test any website on the Internet?
How to setup Selenium RC?
Is my current setup correct? My current setup is like this: In a LAN network which has access to the Internet, I have 3 servers. Server-1 comes with IE8, Server-2 comes with Firefox 3.6. Server-3 will be used as the Selenium RC server. So, Selenium RC in server-3 will remotely control server-1 and server-2 to start up IE and FF. Server-1 and 2 will use server-3 as the HTTP proxy to connect to any webserver on the Internet. If I want to test a website such as yahoo.com, I can write Selenium script and let it run in Server-3 to control the IE and FF in server-1 and 2.
This info is related to Selenium 1.
Selenium system consists of 3 parts:
selenium core - that is javascript library that will be used to simulate user actions
selenium RC - this is selenium-server.jar - mediation JETTY server that will receive requests from selenium client. Selenium Server RC (Remote Control) should be on the same machine where the Browser placed
Selenium client - java/ruby/... library that you will be use with your tests to communicate with Selenium RC.
It will be helpful if you provide language that you use for your tests and other technical details.
About your questions:
can
type in command line -> java selenium-server.jar
or you can use class SeleniumServer in your program
please use text formatting when ask questions.
server-1 will has IE8 and SeleiumServer
server-2 will has FF and yet one SeleniumServer
server-3 will has you client tests
FYI - you can run all together on one PC
The below diagram is of a web application test system that I've implemented on numerous occassions. This does not show you specifically details on installing Selenium RC, but it does show you, at a high level, all of the necessary system components and how they interface.
We hope you can use it to get ideas on how to implement your own systems using open source solutions like Selenium, MySQL and Perl.
Our team understands that not all web sites are created equal, and, in order for any automation initiative to be successful a thorough analysis must be performed of not only the web application, but the business as well. Since our client's QA team, while technically savvy, were not programmers we decided to implement a page object design pattern where all of the "magical selenium commands" were abstracted in a class and exposed to the test developers as methods they would call from their test scripts.
The resulting implementation, as seen in the diagram below, is currently deployed and keeping management and interested parties up to date on the status of key functional areas of the web site.
System Diagram - Click to View
In the coming weeks, we are going to be covering each implementation step in more detail. We look forward to any feedback!
Web and Mobile Automation Blog