Jmeter with Selenium runs scenario Sequentially and not paralelly - selenium

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.

Related

Is there a way to test web application using Selenium and either Driver Firefox or Chrome on a server Centos7 without graphical interface?

On my local machine, I arrived to test my applications with Selenium with any problems.
But, when I'm doing the same operations on a server Centos7 (I have no graphical interface), I've many errors such as web element not found.
I'm using Docker containers for selenium (hub and nodes). The installation is OK and I can see my drivers on Http://:4444/grid/console.
Does Selenium require a graphical interface for its work?
Yes. Selenium requires the browser GUI to be present - which is also called viewport.
If you want that Selenium execution happen, without the browser GUI to be present, then you need to use a headless browser, which , as the name suggests is headless, which means there would be no GUI for them.
Examples of these headless browser include PhantomJS- link. Now Chrome also has a headless mode - link, which you can specify using ChromeOptions. Cheers!

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.

Take over browser from selenium session

I'm not sure if there is a term for what I'm trying to do. I currently have a test suite using codeception for a php application. What I would like to do is be able to either of the following:
watch the browser automation in an actual browser
take over the browser at a specific point ( Sort of like a hand over from the script to the browser to allow me to continue to run a session )
Is this possible? If so what is it called in the selenium documentation
a) Selenium runs the actual browser and you can see what it is doing unless you configured Selenium to run some headless browser (but I don't know anything about headless browsers supported by Selenium);
b) Use Codeception's pauseExecution method to stop execution at specific point.
Documentation:
Pauses test execution in debug mode. To proceed test press “ENTER” in
console.
This method is useful while writing tests, since it allows you to
inspect the current page in the middle of a test case.

Selenium Golang binding without server

There are many selenium webdriver binding package of Golang.
However, I don't want to control browser throught server.
How can I control browser with Golang and selenium without selenium server?
You can try github.com/fedesog/webdriver which says in its documentation:
This is a pure go library and doesn't require a running Selenium driver.
I would characterize the Selenium webdriver as a client rather than a server. Caveat: I have used the Selenium webdriver (Chrome version) from .Net and I am assuming it is similar for Go.
The way Selenium works is that you will launch an instance of it from within code, and it creates a live version of the selected browser (i.e. Chrome) and your program retains control over it. Then you write code to tell the browser to navigate to a page, inspect the response, and interact with the browser by filling out form data, clicking on buttons, etc. You can see what is happening on the browser as the code runs, so it is easy to troubleshoot when the interaction doesn't go as planned.
I have used Selenium to upload tens of thousands of records to a website that has no API and only a graphical user interface. Give it a chance.

Executing the selenium tests from remote java application

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.