Reputation: 20078
I have prepared a test cases using selenium webdriver and I ran locally using MSTEST and it works fine and now I would like to move my test cases to JENKINS, and when i run from JENKINS it says Starting execution...
and its more than 15 mnts and still the same status so I have to stop it manually.
here is my console output:
Started by user anonymous
Started by user anonymous
Building in workspace D:\Jenkins\jobs\Selenium_Script\workspace
[workspace] $ cmd /c call C:\Users\XXXXXXX\AppData\Local\Temp\hudson4765437871038045571.bat
D:\Jenkins\jobs\SelScript\workspace>call "D:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\mstest" /testcontainer:D:\Sel\EmployeeTest\test.emp.admin.dll
Microsoft (R) Test Execution Command Line Tool Version 10.0.30319.1
Copyright (c) Microsoft Corporation. All rights reserved.
Loading D:\Sel\EmployeeTest\test.emp.admin.dll...
Starting execution...
Build was aborted
Finished: ABORTED
I wanted to execute the test case on Jenkins and check the result of execution
and here is my code I'm using just in case.
This is what I am using to instantiated my driver, do I have to use RemoteDriver
?
public static IWebDriver GetDriver()
{
string _url = new Uri(Common.Url).DnsSafeHost.ToString();
switch (Common.BrowserSelected)
{
case "ff":
FirefoxProfile profile = new FirefoxProfile();
profile.SetPreference("network.http.phishy-userpass-length", 255);
profile.SetPreference("network.automatic-ntlm-auth.trusted-uris", _url);
drv = new FirefoxDriver(profile);
break;
case "ie":
var options = new InternetExplorerOptions();
options.IntroduceInstabilityByIgnoringProtectedModeSettings = true;
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.SetCapability(CapabilityType.AcceptSslCertificates, true);
drv = new InternetExplorerDriver(options);
break;
case "chrome":
//_driver = new ChromeDriver();
break;
}
return drv;
}
Upvotes: 0
Views: 9338
Reputation: 29689
Jenkins is super easy. Just do this:
1. Allow Jenkins to check-out your code into the Jenkins workspace.
2. Navigate to that workspace on your Windows computer and manually run
the tests by executing the script that starts them.
By doing it this way Jenkins is temporarily out of the picture and is therefore no longer the cause of your problem. Then, you can focus on what the real actual problem is. Once you have resolved the problem, check your changes into your source code repo, then run the Jenkins build again and try to run manually again. If that also works, THEN finally, you are clear to setup a build task in Jenkins to run your test.
Upvotes: 0
Reputation: 8548
You can run your Selenium scripts in the Build
section of Jenkins.
Click on Add Build Step
and select Execute Shell
, over there you can directly run your commands as you would type in a Linux environment.
All of this assuming you are running your Jenkins of a Linux environment.
@Do I have to use RemoteDriver
?
Depends do you have xvfb installed to run your tests in a headless mode?
If not, then yes, you can redirect your tests to run remotely on a windows/mac machine.
UPDATE
If you have a windows machine, you do not need xvfb. So forget about that.
Shell script (defaults to sh, but this is configurable) for building the project. The script will be run with the workspace as the current directory. Type in the contents of your shell script. If your shell script has no header line like #!/bin/sh —, then the shell configured system-wide will be used, but you can also use the header line to write script in another language (like #!/bin/perl) or control the options that shell uses. By default, the shell will be invoked with the "-ex" option. So all of the commands are printed before being executed, and the build is considered a failure if any of the commands exits with a non-zero exit code. Again, add the #!/bin/... line to change this behavior.
As a best practice, try not to put a long shell script in here. Instead, consider adding the shell script in SCM and simply call that shell script from Jenkins (via bash -ex myscript.sh or something like that), so that you can track changes in your shell script.
Example -
You can run a ruby command like so
ruby testscripts.rb
or a shell script like so
./testscripts.sh
Upvotes: 2