NUnit Chrome Driver without path - visual-studio-2010

I am creating Selenium test using Chrome Driver. To run test on my machine, I run Chrome Driver from the path in my computer like,
Instance = new ChromeDriver(#"C:\Users\..\);
But the point is, if somebody want to run my test using NUnit, it doesn't work because the path of the Driver is the one associated to my machine no to the machine that the other person is using.
So, is it possible somehow to attach the Driver to the project without writing path and be able to run in all machines without changing anything?

I have not used NUnit. But I understand your issue & This is how i do.
I use TestNG framework to run my selenium-webdriver regression scripts. I run the scripts periodically using jenkins in different slave machines (windows/mac). Chrome and IE driver servers are part of my project. (i just added to my project folder). I find the absolute path to these drivers # runtime and use it to start the service. So this way it does NOT depend on the machines or users who runs it. It works great. I would suggest you the same!

Related

Polymer tests never end on windows machines

I've developed an application using Polymer 1.0. My developer computer is a Mac, and I've not had any problems during development process.
However, when I clone my application on a Windows machine (Windows 10), the tests don't work at all.
Whenever I execute polymer test or wct the command blocks the terminal and never ends.
On MACOS or Linux it works perfectly.
The following environment variable values have saved me in Win10 environment:
LAUNCHPAD_BROWSERS=chrome
LAUNCHPAD_CHROME=C:\Program Files (x86)\Google\Chrome\Application\chrome.exe
It is not obvious from Polymer and launchpad documentation the need to set only single browser with known location to minimize the test run time during ongoing development. Of course for multiple browsers autodetection it will take more time and traverse over all PATH with guess on all possible browsers takes forever. It would be reasonable not to rely on auto-detection and list in LAUNCHPAD_BROWSERS only browsers you have set in LAUNCHPAD_xxx location.
I finally found a workaround.
It seems that there is a bug in Web Component Tester. When it tries to find all the browsers installed on a windows machine it takes ages to locate some of them.
To solve this problem, just adds an environment variable that tells WCT which browsers are installed, so it can skip this step:
LAUNCHPAD_BROWSERS= _{coma delimited list of browsers}_
For instance:
LAUNCHPAD_BROWSERS=chrome,firefox,opera
Once this variable has been set, all the tests execute just like on any other OS.
More information about this feature here

Why CodedUI test runs in one browser and does not in another with the same version

I have a few automated UI tests implemented with CodedUI. I have a virtual machine where the tests are run by Test Manager (via test controller and test agent). The benefits of this set up is that I can do other work while the tests are run. If I use my desktop to run the tests.
Recently, these tests are failing. The test is not able to step over from a input field to input password field. So, every test fail due to the tests can't log in to the system under test.
When I run these tests on my desktop then the tests are run without any issue.
Since the tests have been failing there were no updates on either system. Only, restarts.
Both system is Windows 7. Both has the same IE10 version. I requested a new virtual machine and the issue is the same. Tests are failing.
I'm in the situation where I can't decide which way of working is the proper. I want my tests running on the virtual env.
Have anybody experienced like this? Do you know any method to identify what could be the problem?
Another part of the situation is that, if I set up the tests to run on Chrome, then they are running, but it seems CodedUI doesn't like working together with other browsers than IE. I got some "method is not implemented" exceptions. I feel this would be another hell.
First of all, Coded UI only works with IE, unless you use Selenium components.
If you can, add the error the test gives after failing.
In any case make sure your test machine has access to the system you're logging into. To run a Coded UI test on a remote machine you also need to have a user logged in.
The root of my problem is really simple, however annoying and this is not the first I'm looking for when I experience issue. The browsers I use for test have different Browser Mode and Document Mode settings.
That one where the tests failed had "Browser Mode: IE 10 Compatibility Mode" and "Document Mode: IE 7 Standards".
The another one where the tests have passed had "Browser Mode: IE 10" and "Document Mode: quirks".
I modified the browser set up values and the tests are running properly.

Starting webDriver endpoint in current users's desktop from linux through powershell

I have a test cluster that contains a linux machine, an iMac and a windows 7 PC.
The linux machine hosts junit tests that I wrote and the other two machine serve as endpoints for browser automation tests using webDriver.
The script that executes the junit tests loops through different browsers and executes the junit tests against each browser using selenium webDriver. So far, the browsers include iphone, ipad, safari (mac), firefox (mac), chrome (mac), IE10 (win7), firefox (win7), chrome (win7).
While developing this test cluster, I encountered random crashes of webDriver on each of the two endpoints and found it necessary to write a kill/restart of the webDriver jar file. Now, this was a relatively simple matter on the iMac, but on the Windows 7 PC this is proving to be extremely difficult.
The linux machine has a script that checks to see that the webDriver endpoint is available by checking http://windows.Host:4444/wd/hub/status and if it isn't, it shells into powershell on the Windows 7 PC (I have freesshd setup to point to powershell instead of cmd.exe) and runs these commands:
Stop-Process -name java
Start-Process -FilePath C:\webDriver.bat
webDriver.bat contains:
java -jar C:\selenium-server.standalone-2.33.0.jar
Here is the problem I am having:
when powershell restarts webDriver using the above comands, the wedDriver endpoint is reachable but not visible. My tests proceed but fail because the browser is not running in the current desktop but instead some virtual one or another users Desktop. When I run webDriver.bat manually, webDriver runs in a cmd.exe window and the tests execute against all win7 browsers fine, providing webDriver doesn't crash.
Here is my question:
How do I make webDriver execute in such a way that my tests proceed and run correctly, rather than in the background/another user's desktop? These tests are part of Build Verification and need to be run on demand, so having someone manually run webDriver.bat is not an option.
I previously tried to have webDriver's jar running as a service and using samba to restart that service as needed, but ran into the same problem. Powershell seemed to be a better alternative with better control and the ability to verify that the jar file is running, but I don't know if I am heading in the wrong direction here.
I don't relish having to learn powershell to accomplish something that was relatively easy on another OS, but understand that this may be my only option. I also know that the commands I'm using do not constitute a good script and welcome suggestions on how to better achieve my goal here.
Thanks.
Sounds like you just need to pass the host option like so:
java -jar selenium-server-standalone-2.37.0.jar -host 0.0.0.0
Powershell might have permission restrictions on binding to all ports that can be overcome by setting the correct policy. See my blog post here for ideas.
You question is pretty long winded...can you shorten it?

How to add lab process step that starts a RDP session?

Im working with VS2010 and TFS and the Coded UI tests (CUIT).
I created some CUIT and added them to several Test Cases in Microsoft Test Manager 2010.
These tests are executed in our build-deploy-test steps.
This looks as follows (simplified):
Build application
Deploy
2a. Set snapshot of the Virtual Machine to which the application will be deployed to the snapshot in which the application is not installed
2b. Install application
Run tests
Step 3 contains Coded UI tests, but they cannot be executed (will fail), since there is no active remote desktop connection, which they need to be executed.
Now I would like to add a build step 2c. That automatically connects to the Remote Desktop so that the Coded UI Tests kan be executed.
How should I create this step in the Process Template?
I attempted this myself by running a PowerShell script to connect to a machine via Remote Desktop (see here to see how to use the Remote Desktop command-line utility).
This didn't really work for me personally because I was running this script from the build machine - which I could only connect to via Remote Desktop - and so when I close Remote Desktop it would close the session on the build machine and thus I would not be able to obtain a remote desktop connection with my test environment (plus it wasn't ideal to have to launch Remote Desktop from the build machine).
Therefore, the solution I went with instead was to enable auto-logon on the test environment (there are various ways to do this, I can't remember how I did it, but it's easily Googled).
So in my PowerShell script, which launched from our build machine, I used a command to remotely restart the test environment. With auto-logon enabled, the test environment would start back up with an active session, then I could carry on with Visual Studio Coded UI testing. This worked for me without any issues.
The command I used was something like this:
Shutdown.exe /r \\mytestenvironment
Here is some documentation for it.. If you intend on using this command to remotely restart a computer, don't forget to give your machine permissions on the test environment, otherwise this command won't work.
I then launched a command to sleep for a few minutes, to give time for the remote test environment to start back up again (with an active session), then I launched the tests.
Personally, I used a PowerShell script but you could also use a DOS/Batch script if you are more familiar with that.
Also, are you trying to run the automated tests as part of a build process template?
Let me know if you need any further help.

How to Starting specific RC from selenium grid which is running through Hudson plugin?

My environment:
Hudson -> with selenium grid plugin - Installed on linux machine
Hudson -> Having 4 machines ( 1 linux , 3 Windows ) as node
TestCases -> MyTestCases are in TestNG
In Hudson server I checked the selenium console http://localhost:4444/console. It shows the node machines registered as RC with random port numbers. I run the test (test is configured as another job) . Test is running on any one of the machine / RC.
But I want to execute tests on specific environment Machine 1 / Machine 3 . How can I achieve this? What and how do I have to change the configuration files on selenium-grid on server to do this?
If your machines are providing different environments, simply declare different environments in your grid_configuration.yml file and then have your client request those environments.
There is no out of the box way to do this in Selenium 1.0. Hub can pass the command to any of the registered RCs. There are workarounds
Easy way - Register RC ONLY from the machine you want to use for execution.
A little harder way - In the RC machine that you are trying to execute the script, start the browser with a different name. If you are using *firefox now, change it to FirefoxForWindows or something similar. List of browsers will be there in grid console. Internally both will start tests on firefox browser only. Now you will have 3 RCs supporting *firefox browser and one supporting FirefoxOnWindows browser. Now change the browsername you pass to the test from *firefox to FirefoxOnWindows. Hub will see that only one machine has that configuration and it will pass the commands to that RC alone.
If you are using Selenium-1.0 for your test.The following link will help.
http://selenium-grid.seleniumhq.org/run_the_demo.html
In the link it is mentioned how to give particular name to the RC while registering them to hub.
And using code how to connect to a particular env. in hub

Resources