我有以下脚本:
#!/usr/bin/python3
from selenium import webdriver
import time
def getProfile():
profile = webdriver.FirefoxProfile()
profile.set_preference("browser.privatebrowsing.autostart", True)
return profile
def main():
browser = webdriver.Firefox(firefox_profile=getProfile())
#browser shall call the URL
browser.get("http://www.google.com")
time.sleep(5)
browser.quit()
if __name__ == "__main__":
main()
如何管理Firefox以私有模式启动?
引用@Laas在How might I simulate a private browsing experience in Watir? (Selenium)的点:
以及"Private Browsing"的定义:
由于每次你通过selenium webdriver启动firefox,它都会创建一个全新的匿名配置文件,你实际上是在私下浏览。
如果仍要在Firefox中强制使用私有模式,请将
browser.privatebrowsing.autostart
配置选项设置为true
:另外,请参见:
相关问题 更多 >
编程相关推荐