如何在 Mac OS 上安装 Selenium WebDriver

如何在支持 Chrome、 Firefox 和 safari 的 Mac OS X 10.7.5上安装 Selenium WebDriver?我要设置什么,在哪里安装。

222913 次浏览

First up you need to download Selenium jar files from http://www.seleniumhq.org/download/. Then you'd need an IDE, something like IntelliJ or Eclipse. Then you'll have to map your jar files to those IDEs. Then depending on which language/framework you choose, you'll have to download the relevant library files, for example, if you're using JUnit you'll have to download Junit 4.11 jar file. Finally don't forget to download the drivers for Chrome and Safari (firefox driver comes standard with selenium). Once done, you can start coding and testing your code with the browser of your choice.

Mac already has Python and a package manager called easy_install, so open Terminal and type

sudo easy_install selenium

Install

If you use homebrew (which I recommend), you can install selenium using:

brew install selenium-server

Running

updated -port port_number

To run selenium, do: selenium-server -port 4444

For more options: selenium-server -help

To use the java -jar selenium-server-standalone-2.45.0.jar command-line tool you need to install a JDK. You need to download and install the JDK and the standalone selenium server.

I installed Selenium web driver (for Chrome) by first:

  • downloading the appropriate web driver from here.
  • then navigated to mac's folder /usr/local/bin and pasted the downloaded web driver there.
  • Afterwards just ran the file there by double clicking it.

The file was installed there so that we do not have to specify the WebDriver path when instantiating the browser. For more detailed walkthrough, you can reference from here.