在Mac Chrome上使用Selenium

编程入门 行业动态 更新时间:2024-10-27 08:27:34
本文介绍了在Mac Chrome上使用Selenium的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 最近得到了一个mac,并且能够无任何问题地运行Mozilla,但是无法安装chrome扩展并在selenium上运行它。有人可以指导我通过安装扩展并在Mac上运行Selenium的过程。

解决方案

如果您想使用Selenium WebDriver使用Chrome,首先下载ChromeDriver - WebDriver for Chrome。这可以通过Homebrew通过 brew install chromedriver 来安装,或者通过下载,解压,移动和设置 PATH 为手动安装如下:

$ cd $ HOME / Downloads $ wget chromedriver.storage.googleapis/ 2.22 / chromedriver_mac32.zip $ unzip chromedriver_mac32.zip $ mkdir -p $ HOME / bin $ mv chromedriver $ HOME / bin $ echoexport PATH = $ PATH: $ HOME / bin>> $ HOME / .bash_profile

来源: 在Mac或Linux上安装并设置路径到chromedriver

然后,您应该阅读入门在桌面上使用ChromeDriver ,特别是示例代码,该代码展示了如何将路径映射到可执行文件并实例化 ChromeDriver 。如果您在 PATH 变量中引用了驱动程序,则可以省略配置行。

您可以通过ChromeDriver安装打包(.crx文件)和解包(目录)扩展。请参阅代码片段,以设置此处。

如果您使用Selenium IDE代替FireFox,则没有适用于Chrome的版本。我知道的最佳选择是 iMacros for Chrome 。

Recently got a mac and was able to run Mozilla without any issues but having trouble installing chrome extensions and running it for selenium. Can someone guide me through the process of installing the extension and running selenium on Mac chrome.

解决方案

If you want to use Selenium WebDriver with Chrome, first download ChromeDriver - WebDriver for Chrome. This can be installed via Homebrew with brew install chromedriver, or manually by downloading, extracting, moving and setting the PATH as follows:

$ cd $HOME/Downloads $ wget chromedriver.storage.googleapis/2.22/chromedriver_mac32.zip $ unzip chromedriver_mac32.zip $ mkdir -p $HOME/bin $ mv chromedriver $HOME/bin $ echo "export PATH=$PATH:$HOME/bin" >> $HOME/.bash_profile

Source: install and set path to chromedriver on mac or linux

You should then read Getting started with ChromeDriver on Desktop, in particular the sample code which shows how you map the path to the executable and instantiate ChromeDriver. If you have a reference to the driver in the PATH variable, you can omit the configuration line.

You can install both packed (.crx file) and unpacked (directory) extensions via ChromeDriver. See the code snippets for setting either up here.

If you were using Selenium IDE for FireFox instead, there is no version available for Chrome. The best alternative I know of is iMacros for Chrome.

更多推荐

在Mac Chrome上使用Selenium

本文发布于:2023-10-08 02:24:08,感谢您对本站的认可!
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Mac   Chrome   Selenium

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!