use*_*123 14 python linux selenium google-chrome selenium-webdriver
我使用Selenium和Python Chrome webdriver.在我使用的代码中:
driver = webdriver.Chrome(executable_path = PATH_TO_WEBDRIVER)
Run Code Online (Sandbox Code Playgroud)
将webdriver指向webdriver可执行文件.有没有办法将webdriver指向Chrome浏览器二进制文件?
在https://sites.google.com/a/chromium.org/chromedriver/capabilities中,他们有以下内容(我认为它正是我正在寻找的):
ChromeOptions options = new ChromeOptions();
options.setBinary("/path/to/other/chrome/binary");
Run Code Online (Sandbox Code Playgroud)
有人有Python的例子吗?
Deb*_*anB 19
您可以通过以下方式在Chrome中将Chrome浏览器二进制文件设置为chrome webdriver:
Options班级:from selenium import webdriver
from selenium.webdriver.chrome.options import Options
options = Options()
options.binary_location = "C:/Program Files (x86)/Google/Chrome/Application/chrome.exe"
driver = webdriver.Chrome(chrome_options=options, executable_path="C:/Utility/BrowserDrivers/chromedriver.exe", )
driver.get('http://google.com/')
Run Code Online (Sandbox Code Playgroud)
DesiredCapabilities班级:from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
cap = DesiredCapabilities.CHROME
cap = {'binary_location': "C:/Program Files (x86)/Google/Chrome/Application/chrome.exe"}
driver = webdriver.Chrome(desired_capabilities=cap, executable_path="C:\\Utility\\BrowserDrivers\\chromedriver.exe")
driver.get('http://google.com/')
Run Code Online (Sandbox Code Playgroud)
Service:from selenium import webdriver
import selenium.webdriver.chrome.service as service
service = service.Service('C:\\Utility\\BrowserDrivers\\chromedriver.exe')
service.start()
capabilities = {'chrome.binary': "C:/Program Files (x86)/Google/Chrome/Application/chrome.exe"}
driver = webdriver.Remote(service.service_url, capabilities)
driver.get('http://www.google.com')
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
13627 次 |
| 最近记录: |