带有Python浏览器的Selenium-Python(Windows) [英] Selenium-Python with chromium browser (windows)

查看:109
本文介绍了带有Python浏览器的Selenium-Python(Windows)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在Windows 8上使用Selenium python启动Chrome浏览器。

I am trying to launch chromium browser with selenium python on windows 8.

添加了 binary_location 作为铬二进制文件位置是appdata。
,但chromedriver仍会启动google chrome而不是铬。

Added binary_location as chromium binary location which is appdata. But still chromedriver starts google chrome instead of chromium.

如果我卸载google chrome,则chromedriver默认会启动chrome。但是,无论安装了chrome,它总是会启动chrome。

If I uninstall google chrome, then chromedriver by default launches chromium. But with chrome installed it always launches chrome regardless.

有没有人知道如何在安装chrome时使用硒来启动铬?

Does anyone have an idea on how to start chromium with selenium while chrome installed?

请不要将其标记为重复。另一个是关于unix和提供给selenium java的解决方案,而另一个是关于Windows和python的。

Please do not mark it as duplicate. The other one was about unix and solution provided to selenium java while this one is about windows and python.

推荐答案

请尝试以下操作:

from selenium.webdriver.chrome.options import Options

options = Options()
options.binary_location = r"D:\.....\chrome.exe"
# This line defines your Chromium exe file location.

driver = webdriver.Chrome(chrome_options=options)
driver.get('https://www.google.com/')

为我工作。
我同时安装了Chrome和Chromium。
它将启动指定的exe。

Worked for me. I installed both Chrome and Chromium. It starts the specified exe.

这篇关于带有Python浏览器的Selenium-Python(Windows)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆