问题
How to disable this "first run" page once and for all for FF?
When FF driver is created, it opens tab with - https://www.mozilla.org/en-US/firefox/42.0/firstrun/learnmore/ and additional tab with target page.
回答1:
To turn off this annoying start page:
in C# with Selenium 2.48 I found the following solution:
FirefoxProfile prof = new FirefoxProfile();
prof.SetPreference("browser.startup.homepage_override.mstone", "ignore");
prof.SetPreference("startup.homepage_welcome_url.additional", "about:blank");
Driver = new FirefoxDriver(prof);
...and it will never bother you again.
Note: One of these settings alone will also work. I use them together to make it bullet-proof.
回答2:
Ifound a solution, works fine
FirefoxProfile fp = new FirefoxProfile();
fp.setPreference("browser.startup.homepage", "about:blank");
fp.setPreference("startup.homepage_welcome_url", "about:blank");
fp.setPreference("startup.homepage_welcome_url.additional", "about:blank");
回答3:
I have faced the same problem. I have just changed the Selenium version to 2.48 and the problem solved.
回答4:
This is caused by incompatibility between Selenium and Firefox versions, but not by any one specific version number.
You should be 1-2 Firefox versions behind the newest, if your WebDriver is on the latest version. Otherwise, roll the Firefox version back even further if your WebDriver is older, or upgrade Webdriver.
To get an older Firefox, try https://ftp.mozilla.org/pub/firefox/releases/ or http://www.oldapps.com/
or on Linux, depending on your distro
yum list --showduplicates firefox
sudo yum install firefox-<version>
or
apt-cache show firefox | grep Version
sudo apt-get install firefox=<version>
回答5:
C# solution, upgraded Selenium WebDriver to 2.49.0 solved the issue for me.
回答6:
The above solutions do not work, I've tried them. What did work for me, and probably will for you (if using firefox 43 or less) is:
prof.setPreference("xpinstall.signatures.required", false);
prof.setPreference("toolkit.telemetry.reportingpolicy.firstRun", false);
The problems with 43 and selenium are twofold, the default signed extensions setting (to true) and the first run page. These lines solve both. These must be set programatically. If you try to set them in about:config (or directly in prefs.js) it will not affect the new browsers you open with selenium. It should be noted that they say firefox 44 will not allow you to set the signed extensions variable (so this will not work on 44).
I include the codeblock from my now working code showing the correct use:
FirefoxProfile prof = new FirefoxProfile();
//FirefoxProfile prof = profile.getProfile("default");
//prof.setPreference("browser.startup.homepage", proteinPageUrl);
//prof.setPreference("startup.homepage_welcome_url", proteinPageUrl);
//prof.setPreference("startup.homepage_welcome_url.additional", proteinPageUrl);
prof.setPreference("xpinstall.signatures.required", false);
prof.setPreference("toolkit.telemetry.reportingpolicy.firstRun", false);
//Object socketLock = new Object();
//synchronized(socketLock){
//driver = new FirefoxDriver();
driver = new FirefoxDriver(prof);
//driver = forceInit();
//driver.open();
//}//end synch block
//get protein page
boolean done = true;
do{
driver.get(proteinPageUrl);
final Wait<WebDriver> waitDriver = new FluentWait<WebDriver>(driver)
.withTimeout(30, java.util.concurrent.TimeUnit.SECONDS)
.pollingEvery(5, java.util.concurrent.TimeUnit.SECONDS);
try{
inputTextFeildElement = waitDriver.until(new Function<WebDriver,WebElement>(){
public WebElement apply(WebDriver diver){
return driver.findElement(By.name("term"));
}});
}
catch(NoSuchElementException nsee){
//if not find by name try find by id
if(driver.findElements(By.id("term")).size() != 0){
try{
inputTextFeildElement = driver.findElement(By.id("term"));
done = true;
} catch(NoSuchElementException nsee2){
synchronized(threadLogFile){
try {
threadLogWriter = new PrintWriter(new FileWriter(threadLogFile.getAbsoluteFile(), true));
} catch (IOException ioe) {
System.out.println("error opening file for append: " + ioe.getMessage());
ioe.printStackTrace();
}//catch
threadLogWriter.println("Thread Id: " + threadId + " with thread name: " + threadName + " fails to find input element by name or id to put accession: " + accession);
threadLogWriter.flush();
threadLogWriter.close();
}//synchronized
done = false;
}//catch nsee2
}//catch nsee
}
catch(ElementNotVisibleException enve){
done = false;
}
}while(!done);
回答7:
If you using selenium webdriver from Capybara/Cucumber, then you can change the default url when you register your driver using startup.homepage_welcome_url.additional
:
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
回答8:
I faced the same problem. My solution:
- I downgraded Firefox to 36.0.
- It worked fine with Selenium 2.53.1.
I hope this help. :)
来源:https://stackoverflow.com/questions/33937067/firefox-webdriver-opens-first-run-page-all-the-time