如何在Selenium Webdriver Python 3中使用Chrome Profile
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了如何在Selenium Webdriver Python 3中使用Chrome Profile,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含1550字,纯文字阅读大概需要3分钟。
内容图文
![如何在Selenium Webdriver Python 3中使用Chrome Profile](/upload/InfoBanner/zyjiaocheng/714/96a7ca808e094bd3bd29849952dea110.jpg)
因此,每当我尝试使用我的Chrome设置(我在默认浏览器中使用的设置)时,都会添加
options = webdriver.ChromeOptions()
options.add_argument("user-data-dir=C:\Users\... (my webdriver path)")
driver = webdriver.Chrome(executable_path="myPath", options=options)
它显示了错误代码
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes n 16-17: truncated \UXXXXXXXX escape
在我的bash中.我不知道这意味着什么,我会很高兴能得到任何帮助.提前致谢!
解决方法:
根据您的问题和代码试用,如果您想在此处打开Chrome浏览会话,请选择以下选项:
>要使用默认的Chrome个人资料:
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
options = webdriver.ChromeOptions()
options.add_argument("user-data-dir=C:\\Users\\AtechM_03\\AppData\\Local\\Google\\Chrome\\User Data\\Default")
driver = webdriver.Chrome(executable_path=r'C:\path\to\chromedriver.exe', chrome_options=options)
driver.get("https://www.google.co.in")
>注意:您的默认chrome配置文件将包含大量书签,扩展程序,主题,Cookie等.Selenium可能无法加载它.因此,根据最佳实践,为@Test创建新的chrome配置文件,并在配置文件中存储/保存/配置所需的数据.
>要使用自定义的Chrome个人资料:
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
options = Options()
options.add_argument("user-data-dir=C:\\Users\\AtechM_03\\AppData\\Local\\Google\\Chrome\\User Data\\Profile 2")
driver = webdriver.Chrome(executable_path=r'C:\path\to\chromedriver.exe', chrome_options=options)
driver.get("https://www.google.co.in")
>在这里,您将找到有关How to open a Chrome Profile through Python的详细讨论
内容总结
以上是互联网集市为您收集整理的如何在Selenium Webdriver Python 3中使用Chrome Profile全部内容,希望文章能够帮你解决如何在Selenium Webdriver Python 3中使用Chrome Profile所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。