问题
After upgrading to firefox 68 my selenium python script broke, I wasn't able to open a new tab using the code that worked prior.
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
my_profile = webdriver.FirefoxProfile()
my_profile.set_preference("browser.tabs.remote.autostart", False)
my_profile.set_preference("browser.tabs.remote.autostart.1", False)
my_profile.set_preference("browser.tabs.remote.autostart.2", False)
browser = webdriver.Firefox(firefox_profile=my_profile)
browser.find_element_by_tag_name('body').send_keys(Keys.CONTROL + 't')
回答1:
Turns out Mozilla made changes to future Firefox versions starting firefox 68,
so changing "browser.tabs.remote.autostart” value to false, simply won’t disable e10s (Multi-Process)
and as a result won't open a new tab in selenium.
you can read more about it here:
https://techdows.com/2019/05/mozilla-firefox-68-doesnt-allow-turning-off-e10s.html
https://www.ghacks.net/2016/07/22/multi-process-firefox/
The solution is to delete the previous code and use this instead:
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import os
os.environ['MOZ_FORCE_DISABLE_E10S'] = '1'
browser = webdriver.Firefox()
browser.find_element_by_tag_name('body').send_keys(Keys.CONTROL + 't')
来源:https://stackoverflow.com/questions/56973213/how-to-fix-selenium-webdriver-not-opening-a-new-tab-on-firefox-68-0-and-above