firefoxProfileTemplate doesn't prevent certificate prompt in Mozilla - firefox

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.

Related

Debug Firefox on CI server

I build my project on Travis CI. I run tests the following way:
Run Firefox with index.html parameter, which loads script that attempts to connect repeatedly to websocket server.
Run simple websocket server that sends commands to Firefox.
Script in Firefox reads these commands (they may contain some JavaScript code to test), executes JavaScript code.
This works when I run things locally. This also used to work on Travis a couple of weeks ago. However, things that worked for years, had broken unexpectedly. Firefox reports no errors, but node.js server receives no incoming connections for some timeout. I don't know the way to debug the problem. Script that runs in Firefox uses console.log extensively, however I can't retrieve these logs from Travis. Is there any way to get some information from Firefox that runs on CI server?
Note: I run Firefox 53. After things got broken, I tried to upgrade to recent version. Also, I used to run following commands before running Firefox:
export DISPLAY=:99.0
sh -e /etc/init.d/xvfb start
sleep 10
And I tried to remove these lines and use headless more, however this didn't work.
Script that runs in Firefox uses console.log extensively, however I can't retrieve these logs from Travis. Is there any way to get some information from Firefox that runs on CI server?
Firefox 65+ supports a new devtools.console.stdout.content about:config preference, which you can set to true to make the Console output be dumped to stdout (and appear in Travis, I believe).
There doesn't seem to be a good solution for earlier versions: Selenium's driver.get_log() doesn't work in Firefox, and other solutions look unsatisfactory to me.
You seem to run index.html as a file:/// URL, in my opinion that's asking for trouble - I recommend spending time to set up a local https:// server, to save time debugging ever-increasing "security" restrictions the browsers add for non-https content.
If the above doesn't help, try reproducing this with a minimal testcase in a separate repo; if the problem persists, you can share that repo in another question.
You can run vnc with xvfb and connect to it with vncviewer. Here you have some more details: https://www.alexkras.com/debugging-xvfb-server-with-vnc/

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?

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.

Jasmine in windows command-line

How to run jasmine from command-line using a Windows machine ? I have seen jasmine scripts run in Linux. I want jasmine standalone in command-line without phantomjs or any other javascript code that mocks the server(I need jasmine only, if possible with maven).
I'm lost... Assuming the question is "can I run JavaScript on default Windows install, can I run tests with Jasmine this way"?
CScript/WScript will run JavaScript, both a part of default Windows install (I believe starting W2K or WinXP).
You can also compile JavaScript with .Net compiler (JSC.exe) again available on most machines (.Net is not default on WinXP - so may not be present, Windows Vista/7/8 come with a version .Net by default).
Note that JavaScript by itself has nothing to do with browser and both above tools are not going to provide you any support for browser objects. You can run logic code/manipulate files and configuration, output text.
There is some chance that Jasmine can be run from command line without browser objects - try yourself if you goal is running non-browser related JavaScript from Windows command prompt.
There is also option to automate IE and run script there (again default IE may not be latest version - but Windows 8 comes with IE 10 - should be enough for most browser related tests). You should be able to write your own automation framework (similar to Selenium) if needed, even using JavaScript...
Sample JavaScript to run with CScript /nologo launchIE.js from command prompt:
// save as launchIE.js
WScript.Echo("Launching IE to Bing"); // outputs text to console
var oIE = new ActiveXObject("InternetExplorer.Application.1");
oIE.Visible=1;
oIE.Navigate("http://www.bing.com");

Selenium RC 2.24.1 + Firefox 10.0.2 Profiles

After many tests with many old versions of Firefox (3.0.19, 3.6.28, 10.0.2) I have some trouble.
My last test was to launch "selenium-server-standalone-2.24.1.jar" with this args : -firefoxProfileTemplate C:\Users\XXXXXXXX\AppData\Roaming\Mozilla\Firefox\Profiles\g3c1ac71.Profile_FF_10
In this profile I have configured language to French but it doesn't work, my website is display in English. I also had an SSL exception but when selenium launch my site, Firefox give me an alert about selfsigned certificate
With version 3.0.19, profile was used but Firefox crashed because of Flash plugin, so I know I know use profile.
It's really hard to understand compatibilty between selenium and Firefox.
Is this a special step I forgot ?
Regard
After I reboot my computer, all work like a charm. Strange !

Resources