FirefoxDriver always starting on "firstrun" page, breaking all test scripts - firefox

Starting just last night, the FirefoxDriver has been always opening on this page: https://www.mozilla.org/en-US/firefox/42.0/firstrun/learnmore/. I have tried changing the default profile settings and have not had any success.
The following question, http://stackoverflow.com/questions/33937067/firefox-webdriver-opens-first-run-page-all-the-time, is similar, but I do not see where to implement the four lines of code, and my personal attempts of throwing it into my scripts have proved futile.
This problem started absolutely out of the blue last night. I have presentations to do today and I can't get any of my scripts to work.
Instantiating my WebDriver instance like so will cause a NoSuchMethodError:
FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("browser.startup.homepage", "about:blank");
profile.setPreference("startup.homepage_welcome_url", "about:blank");
profile.setPreference("startup.homepage_welcome_url.additional", "about:blank");
driver = new FirefoxDriver(profile);
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
But getting rid of profile in FirefoxDriver brings it back to the firstrun page mentioned above.

I was having this problem when running RSpec/Capybara tests using a Selenium Webdriver and Poltergeist with Firefox as the browser for a Rails app. Tried reconfiguring Firefox in various ways to no avail but managed to fix by simply updating the selenium-webdriver gem in my Gemfile (gem 'selenium-webdriver'):
bundle update selenium-webdriver
Credit goes to #lucetzer

I had the same problem with the first run page, after some searching I found that this worked for me (I use WebDriver 2.53.0 and FF 45.0.1):
FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("browser.startup.homepage_override.mstone", "ignore");
profile.setPreference("startup.homepage_welcome_url", "about:blank");
profile.setPreference("startup.homepage_welcome_url.additional","about:blank");
profile.setPreference("browser.startup.homepage","about:blank");
WebDriver driver = new FirefoxDriver(profile);

Go to profile manager using "Firefox.exe - p"
You will have more than one profile. Please select default profile and make it default all time.
It should not open that page. i tested and it works fine.
You can try this code. I am pretty sure it will work.
ProfilesIni profile = new ProfilesIni();
FirefoxProfile ffprofile = profile.getProfile("default");
WebDriver driver = new FirefoxDriver(ffprofile);
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);

There is an issue with the certificates in the first run splash screen of the Mozilla homepage. I filed a ticket for this in Bugzilla: https://bugzilla.mozilla.org/show_bug.cgi?id=1269500
To fix this issue in Selenium/Capybara/Cucumber, we need to change the default homepage for new profiles to blank or another page. To do so, register your firefox/selenium driver in the configuration:
Capybara.register_driver :firefox do |app|
profile = Selenium::WebDriver::Firefox::Profile.new
profile['browser.startup.homepage_override.mstone'] = 'ignore'
profile['startup.homepage_welcome_url.additional'] = 'about:blank'
Capybara::Selenium::Driver.new(app, :browser => :firefox, :profile => profile)
end

Related

How to modify the Firefox profile used by Watir-Webdriver

I'm working on web-application automation using Ruby 1.9.3p484 and Watir-webdriver (0.8.0) with Firefox 41.0 for Ubuntu.
I want the browser to not load any images. To do that, I try to change the 'permissions.default.image' firefox parameter to 2.
I have tried the following code:
profile = Selenium::WebDriver::Firefox::Profile.new
profile['permissions.default.image'] = 2
browser = Watir::Browser.new(:firefox, :profile => profile)
browser.goto url
But, the browser keep loading the images. In the about:config page, the 'permissions.default.image' is still set to 1.
Any ideas on what could be wrong?
I don't know why, but if I use from_name method in Selenium class init, then you code is working perfectly:
profile = Selenium::WebDriver::Firefox::Profile.from_name "default"

Firefox pop up obscures the screen paritally in selenium test

I ran my test in BrowserStack and here is an example outcome
How can I turn off this behaviour of Firefox in a selenium test via DesiredCapabilities?
I want to be able to drive this behaviour with settings instead of adding code for a specific browser.
This prompt is related to firefox health report, you can disable it in as: (in java)
FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("datareporting.healthreport.uploadEnabled", false);
profile.setPreference("datareporting.healthreport.service.enabled",
false);
profile.setPreference("datareporting.healthreport.service.firstRun",
false);
WebDriver driver = new FirefoxDriver(profile);

selenium firefox webdriver - accessing session

I am already logged in to my googlemail account in Firefox browser with profile named: test_profile.
Using Selenium, I launch Firefox browser with profile test_profile, but I am seeing login page. Meaning, the session/cookies are not being used.
What am I doing wrong? Or what can be done so I can use my session.
ProfilesIni allProfiles = new ProfilesIni();
FirefoxProfile profile = allProfiles.getProfile("test_profile");
WebDriver driver = new FirefoxDriver(profile);
driver.get("https://www.googlemail.com");
Thanks.

Unsupported command-line flag: --ignore-certificate-errors (in Ruby)

Using Ruby 2.0.0 p481 in RubyMine and chromedriver 2.10
When Chrome starts it displays a message in a yellow popup bar: "You are using an unsupported command-line flag: --ignore-certificate-errors. Stability and security will suffer." This simple example reproduces the problem.
require "selenium-webdriver"
driver = Selenium::WebDriver.for :chrome
driver.navigate.to login_url
This question has been answered for Java and Python. I have looked everywhere for a Ruby analog. Does anyone have a suggestion or know how to translate the Python answer (Unsupported command-line flag: --ignore-certificate-errors) to Ruby? Thank you!
The Ruby selenium-webdriver API doesn't expose a separate Chrome options object like Java/Python but you can set the options via "Capabilities".
The Capabilities web page provides a Ruby example and the table of recognized capabilities that you can inject. Plugging those together with excludeSwitches:
caps = Selenium::WebDriver::Remote::Capabilities.chrome("chromeOptions" => {"excludeSwitches" => [ "--ignore-certificate-errors" ]})
driver = Selenium::WebDriver.for :chrome, desired_capabilities: caps
Take a look at Watir too, it's a front end for WebDriver.
Their examples show how you can send a :switches array which is passed straight through to the web driver so you can do the same. That makes adding other switches a bit easier rather than going through capabilities.
There is a chromedriver issue on the topic as well. There are posts detailing that you can add a --test-type argument to work around the certificate issue and ruby code examples like above.
I adjusted:
driver = Selenium::WebDriver.for :chrome
to read:
driver = Selenium::WebDriver.for :chrome, :switches => %w[--test-type]
...and the script ran successfully without the yellow flag. Clearly, other command-line switches could be added.
Thank you to Nguyen Vu Hoang and mtm.
I donot know ruby, however my approach is set mode "test-type" to ChromeDriver capabilities
Here's my sample code in Java
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities = DesiredCapabilities.chrome();
ChromeOptions options = new ChromeOptions();
options.addArguments("test-type", "start-maximized",
"no-default-browser-check");
capabilities.setCapability(ChromeOptions.CAPABILITY, options);
With Capybara:
Capybara.register_driver :chrome do |app|
Capybara::Selenium::Driver.new(app, browser: :chrome, switches: ['--test-type'])
end
This error caused my rspec tests to fail. I think it was causing Chrome to slow down so the above fixes did remove the error messages but did not resolve my problem of my tests failing.
If you are using chromedriver-helper then this should fix the problem. Run this from the command line
chromedriver-update
This is described more in chromedriver-helper, "This might be necessary on platforms on which Chrome auto-updates, which has been known to introduce incompatibilities with older versions of chromedrive"
Once I ran this I was able to remove the fixes described elsewhere and Chrome ran with out warnings.

Get Firefox Profile Name at Runtime and Set preferrence

I have a scenario to handle where I am opening Firefox browser using Selenium Webdriver and each time it opens up a new profile. Code is written below:
WebDriver driver = new FirefoxDriver();
Each time it opens up a new profile which is something like : anonymous8958670169066009851webdriver-profile and profile name changes every time WebDriver opens up a Firefox browser. My intention is to get the profile name at runtime and set some preferences on it like handling unresponsive JS alert etc. Basically flow will look like something below:
WebDriver driver = new FirefoxDriver();
<Write some code here to get Firefox profile name>
<Set profile settings like **profile.setPreference("extensions.firebug.currentVersion", "1.8.1");>
Please help me in the second step i.e. Write some code here to get Firefox profile name if anyone already achieved something similar before.
You're approaching the problem backward. The correct thing to do is to create the FirefoxProfile object yourself, and using it in the constructor to the FirefoxDriver. The code would look something like this:
FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("extensions.firebug.currentVersion", "1.8.1");
WebDriver driver = new FirefoxDriver(profile);

Resources