option = webdriver.ChromeOptions() #设置自己的数据目录【路径只到User Data。不是User Data\Default】 #加载配置 option.add_argument('--user-data-dir=C:\\Users\\13553\AppData\\Local\\Google\\Chrome\\User Data') #启动浏览器配置 driver
option.add_argument(user_data_dir)#启动浏览器配置driver = webdriver.Chrome(chrome_options=option, executable_path=r'D:\coship\Test_Framework\drivers\chromedriver.exe') driver.get(r'https://www.cnblogs.com/') 二、Firefox浏览器 1、打开Firefox浏览器,进入右上角的帮助>故障排除信息,查看浏览器配置...
options.addArguments("--user-data-dir=C:\\Users\\XX\\AppData\\Local\\Google\\Chrome\\User Data"); //设置语言 options.addArguments("--lang=zh_CN.UTF-8"); //模拟手机模式 options.addArguments("--user-agent=iphone 7"); WebDriver driver = new ChromeDriver(options); driver.get("http:...
#方式2:chrome的profile,浏览器里输入chrome://version/,查看自己的“个人资料路径” profile_chrome = '--user-data-dir=自己chrome profile的全路径' option=webdriver.ChromeOptions() option.add_argument(profile_chrome) driver=webdriver.Chrome(chrome_options=option) 1. 2. 3. 4. 5. 6. 7. 8. 9....
—user-data-dir 指定运行浏览器的运行数据,新建一个干净目录,不影响系统原来的数据 代码语言:javascript 代码运行次数:0 运行 AI代码解释 >chrome.exe--remote-debugging-port=9222--user-data-dir="D:\selenium_chrome" 执行后会启动chrome浏览器 selenium运行已打开浏览器 ...
--disable-web-securityEN如何使用python上的selenium在Firefox或Chrome上打开网页,其中浏览器将具有以下...
-user-data-dir:指定创建新Chrome配置文件的目录;它是为了确保在单独的配置文件中启动chrome,不会污染你的默认配置文件。 然后在代码中加入下面的配置即可使用刚刚打开的浏览器了 chrome_options.add_experimental_option("debuggerAddress", "127.0.0.1:9222") ...
options.addArguments(format("user-data-dir=%s", drCustomProfileDir)); origin: webrtc/KITE WebDriverFactory.createCapabilities(...) firefoxOptions.setProfile(firefoxProfile); if (browser.isHeadless()) { firefoxOptions.addArguments("-headless"); firefoxOptions.addArguments(flag); org...
但Selenium 用的时候有个麻烦事,就是环境的相关配置,得安装好相关浏览器,比如 Chrome、Firefox 等等,然后还要到官方网站去下载对应的驱动,最重要的还需要安装对应的 Python Selenium 库,确实是不是很方便,另外如果要做大规模部署的话,环境配置的一些问题也是个头疼的事情。
--user-data-dir=DIR # (Set the Chrome user data directory to use.) --protocol=PROTOCOL # (The Selenium Grid protocol: http|https.) --server=SERVER # (The Selenium Grid server/IP used for tests.) --port=PORT # (The Selenium Grid port used by the test server.) --cap-file=FILE ...