I have developed a Console App using VS2015 which uses Selenium WebDriver to test some websites.
I now want to install this app onto a server and run it there.
I have already installed the app on the server, but when I try to run it, I get an error saying that "Firefox binary couldn't be found in PATH or default". Firefox is installed in the default path C:\Program Files\Mozilla.
Have you got any suggestions on this? Do I need to install any part of Selenium on the server? (Selenium Standalone Server for example)
The server is running Windows Server 2012 R2
Looks like it's unable to find the Firefox binary on its own. So you have to specify the binary of Firefox explicitly. Use the below code to find the Firefox binary
FirefoxBinary binary = new FirefoxBinary(new File("path/to/binary"));
FirefoxProfile profile = new FirefoxProfile();
WebDriver driver = new FirefoxDriver(binary, profile);
What I would recommend is for you to be using Firefox binary in your test suites and call the path of the executable from a properties file so that you don't have to compile all of your test cases again.
The issue was actually caused by the environment variable %PATH%. The variable didn't contain the path for Firefox default installation, which is
C:\Program Files\Mozilla Firefox
To fix the problem, I simply added that path to the environment variable %PATH% (you can find it by clicking Start, typing "environment variables", and clicking on "Environment Variables..." button on the bottom right of the System Properties tab that open when you look for "environment variables" in the Start menu.
That solved the issue.
Thank you Khaja for you answer anyways.
Related
I have created a centos vm. Installed maven, firefox on it and placed selenium automation code to test my web application on it. The only issue is my automation code works on a specific profile where I need to enable the 'Open new windows in a new tab instead' firefox setting.
How can I create a custom firefox profile including this setting on a vm ?
I did a ssh on my vm and then did
firefox -CreateProfile Selenium
I cant find on which location this profile is created. Also I still could not figure out how to add custom settings, as the above just creates a profile I guess.
Here is a description on how to create (and move and remove) Firefox profiles using the built-in Profile Manager. On linux it is usually located in $HOME/.mozilla/firefox/. Profile names are mapped to directories in profiles.ini
A custom profile can be used both programmatically (using FirefoxProfile, FirefoxOptions, FirefoxDriver) or by command line parameter.
I want to install an browser extension before my tests starts. I read on the documentation here that I should create a prerun executable to do this for me. However I am not sure how to this. I have no experience with creating executables
Using the pre-run will only upload the extension onto the SauceLabs Virtual Machine, it won't install it onto the respective browser.
If you want the extension to be installed on the browsers, you may want to consider setting a custom Firefox profile or Chrome options.
Here is a simple Java Example for setting a firefox profile (make sure to use the full path otherwise you will likely get an error):
FirefoxProfile profile = new FirefoxProfile();
profile.addExtension(new File(<PATH TO EXTENSION>));
caps.setCapability(FirefoxDriver.PROFILE, profile);
Firefox is showing "Cannot find firefox binary in PATH." error in MAC OS.
As per my understanding this issue occurs if the Mozilla is not installed in their default location. I am new in MAC OS
I have also tried with firefox profile and already I have set selenium provided DesiredCapabilities
WebDriver driver = new FirefoxDriver(new FirefoxBinary(new File("/Applications/Firefox.app/Contents/MacOS/firefox-bin")), profile);
I have also tried with different path of mozilla in MAC OS like:-
/Applications/Firefox.app/Contents/MacOS/firefox-bin
/Applications/Firefox.app/Contents/MacOS/firefox
/Applications/Firefox.app
Also please provide a snippet for the same.
Chrome is working fine for me in MAC OS. Only Mozilla is creating problem
Surely, I am missing something. I am attaching the snapshot regarding same.
Also, Is there any method present by which I can locate any application installed location using java code?
According to https://github.com/SeleniumHQ/selenium/wiki/FirefoxDriver there is a property you have to set to set the binary path:
webdriver.firefox.bin
so i assume you have to do following:
System.setProperty("webdriver.firefox.bin","/Applications/Firefox.app/Contents/MacOS/firefox-bin");
WebDriver driver = new FirefoxDriver();
I hope this helps :)
If you have installed firefox, check whether the Firefox application is in the /Applications folder. If not move the application to /Application folder and run the test again.
If above worked, you don't have to add a system property "webdriver.firefox.bin"
Possibly updated for the current situation with this I did this:
Installed geckodriver, available since 2018, to /usr/local/bin (arbitrary choice and made sure it could execute. This placement made it unnecessary to add it to my $PATH.
Installed Firefox to /Applications (I had the developer version)
Added this line to my setUp method: driver = new FirefoxDriver(new FirefoxOptions().setHeadless(true));
All this in macOS 10.11 "Big Sur" (aarch64) using current selenium.
After installing Selenium components for Coded UI Cross Browser Testing, and try to run test case on chrome, "System.Exception: The playback engine could not find the binaries required to run cross browser coded UI tests. This may be because the Selenium .NET bindings and Selenium Chrome driver are not installed or an older version of the Selenium Components Installer was used. For more information about installing the binaries, see http://go.microsoft.com/fwlink/?LinkID=267598" occurs. Can anyone help to resolve the issue? Thanks...
This can occur when the cross browser plugin has not installed correctly.
These are the manual steps to install the driver.
Download chrome driver from:
http://chromedriver.googlecode.com/files/
Download selenium dot net bindings from:
http://selenium.googlecode.com/files/
Right click on the downloaded zip files.
Select "properties".
Under "General" tab, click on the "Unblock" button.
Now unzip both the files and copy the contents to the following path (for the selenium-dotnet 2.29.1 binaries, copy the contents of net40 folder):
"%ProgramFiles%\Common Files\microsoft shared\VSTT\Cross Browser Selenium Components" (for 32 bit machines)
"%ProgramFiles(x86)%\Common Files\microsoft shared\VSTT\Cross Browser Selenium Components" (for 64 bit machines)
You need to Install Selenium components
On the Extensions menu, choose Manage Extensions.
In the Manage Extensions dialog box, search for Selenium components for Cross Browser Testing.
Highlight the extension and choose Download.
I'm running selenium-rc 1.0.3 on a Mac OS X & Windows 7 and both seem to be giving my the annoying accept cert error in firefox. In reading the docs they say I should be able to just use the *firefox run mode and rc should take care of it for me via a proxy or something, but this appears to not work. The only solution that I was able to find on the internet was to create a skeleton profile and pass the path into the rc startup, but thats not a real option. As that doesn't solve problems of testing in IE/Chrome/Safari. Does any know of any other solution that will work.
Selenium-RC docs on HTTPS - http://seleniumhq.org/docs/05_selenium_rc.html#handling-https-and-security-popups
I have tried the solution given by this article (Thanks elliot) and it works well for me! Basically
1. Create a firefox profile:
a. Starting your firefox -ProfileManager (or firefox -P) in cmd.exe (make sure the firefox installation folder path is in your path environment variable, by default it should be just created when you installed firefox) and create a new profile.
b. Select this new profile to browse to the HTTPS URL and accept the self-signed certificate when prompted.
c. Go to the Firefox profile directory.
d. Delete everything in the directory except for the cert_override.txt and cert8.db files.
2. Run your selenium RC server using this profile:
such as java -jar selenium-server.jar -firefoxProfileTemplate c:/Firefox_Profile
If this is an issue with self-signed certificates, you could try using the RCE plugin for Firefox in a custom profile: http://sejq.blogspot.com/2009/01/remember-certificate-exception.html
Internet Explorer's warnings can be disabled through the advanced settings (specifics depend on the version of IE). Worth Googling around for a solution.
For Google Chrome I believe this is an unresolved issue related to: http://code.google.com/p/chromium/issues/detail?id=2010&can=5&colspec=ID%20Stars%20Pri%20Area%20Feature%20Type%20Status%20Summary%20Modified%20Owner%20Mstone%20OS