Running EdgeDriver in Jenkins - selenium

I have Selenium tests that I am running through Jenkins on a build server. The tests all run as expected in Chrome (using ChromeDriver) and Firefox (using FirefoxDriver). However, the tests don't run in Edge using EdgeDriver.
When the tests run it gives an error:
Microsoft Web Driver can't be used with the Built-In Administrator account or while User Account Control is turned off.
I have tried turning UAC on, but that no effect. I tried running the Jenkins service as a different user and that also had no effect. I've tried the suggestions from: MicrosoftWebDriver fails when constructing while running under TeamCity agent's windows service
I can run the tests in the same location from a command prompt, just not through Jenkins.

If you configure jenkins slave agent as a windows services, Will get the issues. Because Edge won't run as a headless browsers.
For avoid those issues. we are not suppose to set a slave agent as window services.
Follow the below steps for setup slave agent and then run your script:
***** Then download the agent.jar and place it under jenkins working directory("D:/Jenkins")
***** Open the command prompt as admin user and execute the commands.
java -jar agent.jar -jnlpUrl http://srv-cbe-com4:8080/computer/T/slave-agent.jnlp -secret 07ba92bb8017901287acb979cf30d40a45c17abd2c0edba5b2b3f17cc94915e8 -workDir "D:/Jenkins"

Related

Chrome WebDriver cannot be initialised when selenium-server-standalone runs as a Windows service

WebDriver cannot be initialised when selenium-server-standalone is run as Windows service.
I'm connecting with Windows machine from Jenkins on centOS using SSH.
On Windows I installed selenium-server-standalone as service using nssm, so I run following command:
nssm start SeleniumWebDriver
The service is run as the same local Windows user that I'm using to log in.
The command is working correctly as I can see the process running in Task Manager and I'm able to access the hub and create the Chrome session.
But when the next step in Jenkins job is run, that is tests, it fails immediately because the WebDriver cannot be initialised.
When I run manually on Windows selenium-server-standalone (not as a service), the tests are executed because Chrome is being open. When run through service, Chrome is open but somewhere in the background (probably another session) and I and the tests cannot see the window.
How to change it to make the Chrome appearing so the WebDriver could be initialised and GUI actions be performed?

When selenium test runs by Jenkins and MSUnit, the browser doesn't come up however there are valid results

I put together a machine (Windows Server 2012R2) for POC reasons where a Jenkins installed and it executes Selenium UI tests using msunit
But, when I log in the server where the Jenkins runs and I watch what happens during CI build (compile and test execution) I can't see that the browser (Firefox) starts automatically, however, the test results and the logs show that a browser was executed.
My question is that, what the is happening when my tests are executed by Jenkins? If I execute the command which from visual studio on the same machine then I can see that Firefox starts, does what is programmed in the tests and the results are in the result.trx.Can I somehow set up Jenkins the way the browser really executed (I can believe it when I see it :)
In Jenkins when you run selenium test cases, they are executed in the background by default.
Your Jenkins might be configured to run those test cases in some video buffer(usually it happens on Linux but can also be configured on Windows) or in a headless state.
As your question, if you are using MSTest which basically used to convert the test cases result from trx to JMX format but also can be used to run selenium tests. when you run the same in Jenkins it will run in background on any slave or on master.

Jenkins running selenium tests without opening browser

I browsed a lot on this topic. There are different variations of this question or no answer to fix my issue. Any help is appreciated.
I have installed firefox on my VM as root in /usr/bin/firefox.
I downloaded the maven project to run selenium tests, and run it
manually on my VM using mvn clean install command. This opens the
browser and also successfully runs the test.
Now I run Jenkins as myself ( JAVA_HOME is /usr/java/latest and started the service as
nohup java -jar jenkins.war --httpPort=-1 --httpsPort=8082; version
is 1.522).
Create a new freestyle s/w project; Configure the job
to download the maven project and invoke maven target 'clean
install';
When I run the job, I can see the steps in the console
output but the browser is not opening. It also locks up my AD account.
Why is this happening? What is the fix?
nohup runs Jenkins in the background (http://en.wikipedia.org/wiki/Nohup), in which case according to this post Jenkins will start the browser in the background as well.
Try starting jenkins without nohup so that it runs in the foreground (java -jar jenkins.war --httpPort=-1 --httpsPort=8082).
Or you can start Jenkins as a daemon (this Jenkins Wiki page contains an example of init script). When Jenkins is started as daemon, the browser started by its job is visible.

How to use Selenium Grid to run some commands on the node and system commands locally

I'm trying to solve a problem and I was hoping I could do it with Selenium Grid but I'm not entirely sure that it's possible. Here's my problem...I'm developing test cases using Selenium WebDriver and I need my tests to run on a Windows machine however the AUT runs on a Linux server. I have several tools that only run on Linux and I would like to be able to run some commands/tests on the Windows machine and others in the Linux server. For instance
Test Starts -> Firefox launches (Windows machine)
Login to site (Windows machine)
Run command in Linux server
Return running commands/tests on the Windows box.
Alternatively I could figure out how to run those commands remotely from a Windows machine but I'm not looking forward to doing that.
Out of the box, you cannot use selenium to run commands on your local machine. Selenium/Webdriver is a browser testing tool and can interact only with browser.
Updated Answer based on your comments
Common part to both ways (which I think you already know)
In your java code you should have the code for webdriver/selenium commands that will do step 1 and 2. Your java code should also the contain the logic/code to execute the linux commands as step 3. Step 4 should again be your webdriver command.
This test code should run from the linux server so that the java command execution will happen in the linux box.
Now the only pending part is the execution of test in remote machine.
Method 1 without using grid
Start the selenium server in the windows machine. Point your java tests to the selenium server running in this machine. If your windows machine IP is 10.0.0.1, you should initialize the webdriver object as
WebDriver wd = new RemoteWebDriver(new URL("http://10.0.0.1:4444/wd/hub"),DesiredCapabilities.Firefox());
This will send all your webdriver commands to the selenium server running in 10.0.0.1 on port 4444. Your tests will then get executed in the windows machine. For this to work, your linux server and windows machine should be in same network.
Method 2 using grid.
Its all the same as above, but instead of giving the ip/dns name of windows machine, you should give the ip/dns name of the hub machine. You should also have windows machine registered as an RC to that hub.
I think with AutoIT kind of windows frameworks, we can invoke C:\Windows\System32\cmd.exe to open a command prompt and run some .bat files. If it is Linux /bin/csh or /bin/bash myscript.sh.

Selenium server cannot be started inside Bamboo

I am trying to configure a Selenium testing through Bamboo. I am able to run Selenium scripts directly from command line, however it always fails if I run it through Bamboo remote agent. The error is:
: Could not start Selenium session: Failed to start new browser session: Error while launching browser
at com.thoughtworks.selenium.DefaultSelenium.start(DefaultSelenium.java:107)
I took some advice from the web, and checked "Allow service to interact with desktop" for Bamboo remote agent service. However, it does not work.
Anyone have other suggestions?
You must run Bamboo in Console Mode for this to work. Also, the build machine desktop must be active - and not covered or minimized if you want mouse simulations to work. I know right!