Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
我们如何使用Selenium Python以不同的用户身份打开Google chrome?_Python_Selenium_Selenium Webdriver - Fatal编程技术网

我们如何使用Selenium Python以不同的用户身份打开Google chrome?

我们如何使用Selenium Python以不同的用户身份打开Google chrome?,python,selenium,selenium-webdriver,Python,Selenium,Selenium Webdriver,我正在尝试使用Selenium和Python以“不同用户”的身份打开Chrome浏览器。我该怎么做?非常简单,只需将参数添加到chrome\u选项中即可: from selenium import webdriver options = webdriver.ChromeOptions() options.add_argument("user-data-dir=C:\\Path") #Path to your chrome profile w = webdriver.Chrome(execut

我正在尝试使用Selenium和Python以“不同用户”的身份打开Chrome浏览器。我该怎么做?

非常简单,只需将
参数添加到
chrome\u选项中即可:

from selenium import webdriver

options = webdriver.ChromeOptions() 
options.add_argument("user-data-dir=C:\\Path") #Path to your chrome profile
w = webdriver.Chrome(executable_path=r'C:\Users\chromedriver.exe', chrome_options=options)
请参阅:SO的期望是,用户提问时不仅要进行研究以回答自己的问题,还要分享研究、代码尝试和结果。这表明你花了时间来帮助自己,它使我们避免重复显而易见的答案,最重要的是,它帮助你得到一个更具体和相关的答案!另见: