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

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?

Related

AWS EC2 Windows schedule job fails while offline

I created a Windows instance on AWS EC2 with T2 Micro, where I set up a schedule job that calls a .bat file at 6 every morning.
The .bat job invokes a few other scripts that mainly carry out some Internet-related transactions, including launching browsers, call services and perform I/O operations.
The issue is in most of the time the .bat file is not able to complete its job (Sometimes it does, but pretty rare). Later on, if I connect to the EC2 instance via remote desktop with the same username and manually call that .bat file, everything works fine.
Anyone has ever experienced this kind of problem and what is the resolution?
Thank you.
It's a common problem with automation. Some of the things you're doing such as "launching browsers" may not work for unattended execution.
A good example is Selenium, if you want to run web tests unattended then you need the headless version of Selenium, here's how to set it up for Headless:
Running Selenium with Headless Chrome Webdriver

NUnit Chrome Driver without path

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!

Upon executing a selenium test, spin new Windows VM, execute commands, then exit?

I am running a Mac but need to test Web applications in IE. Ideally, I would love to be able to execute a selenium command on my box, and it would spin up a VM (VirtualBox, VMWare, something like that), run the commands in IE, and then exit the VM once I'm done. Is that possible? If not, does anyone else have a better idea of how to run selenium commands in a Windows environment from a box that is not Windows? My commands are in Python 2.7, if that matters. Thanks
Your requirements shall be possible to fulfill.
Selenium can be using "Selenium Server" and your python code using selenium package shall be able talking to it - it uses http protocol for such a remote control.
Selenium server is using Java, and as it is started, it shows url on which it awaits commands.
These urls can be then used in your python code when constructing driver for your browser, there you specify url of remote Selenim server and shall be able continuing as if you would work locally.
Description how to connect is here.
Feel free to comment or reply to me how it went, it sounds very interesting but I do not have any real experience with that so far.

selenium web driver on windows 7 parallels vm - browser hidden - allow service to interact with desktop?

I am using a script on my mac host to launch a selenium node on a local parallels VM.
Something like
"prlctl exec Win7-VM-Name-Here 'C:\path_here\start_node.bat'"
The node starts up nicely and registers itself with the hub. I can run tests fine against this node.
However, when the tests are running, the browser is not visible on the VM, which means that screenshots are useless.
I think it has something to do with allowing a service to interact with the desktop, but I can't figure out which one, or how to proceed.
Any help?
Thank you.
Unfortunately, this is a common problem with selenium (or any other browser automation software) on Windows. If selenium is running in the background as a service, the browser will not appear when the tests are being run and taking screenshots will just result in a black picture. If you want to be able to watch the tests being run and grab screenshots, the general consensus is to start your script manually from the command line and leave it running.

firefoxProfileTemplate doesn't prevent certificate prompt in Mozilla

I am running Selenium Server. I'm also launching an automated test script that I exported from the Mozilla Selenium IDE and exported to my Java client driver program which I compiled and ran in Eclipse using JUnit 4.8. Two windows start up in Mozilla (since I'm using the "*chrome"/Firefox argument when instantiating my browser window object from the Java program). One window looks like it contains logging information of some kind, and the other window is the actual automated test browser window.
Here's how I'm starting the Selenium Server.
cd C:\Program Files\Java\jdk1.6.0_26\bin\Selenium
java -jar .\selenium-server-standalone-2.0rc3.jar -interactive -firefoxProfileTemplate "C:\Users[Windows-Login]\AppData\Local\Mozilla\Firefox\Profiles\lcllklng.default"
The server starts up fine. The reason I put the -firefoxProfileTemplate attribute into the start-up command because I kept getting the untrusted certificate in Mozilla. I guess this is supposed to default my Windows login Mozilla profile. However, it didn't work. I have to click through the prompts each time I run my test cases. Is there a way to make it avoid the untrusted certificate? Could it be because I'm running Windows 7?
You'd also be my hero if you can help me avoid this for IE, Google Chrome and Safari. But only if you feel helpful today. Thanks!
Switch to WebDriver to avoid this.

Resources