ruby环境下的selenium使用方法
文档:
安装selenium
:
$ gem install selenium-webdriver
安装chromedriver
:
$ brew cask install chromedriver
撰写代码:
require "selenium-webdriver" # load in the webdriver gem to interact with Selenium
# create a driver object.
# This is what you will actually interact with to do things within the automated
# $ brew cask install chromedriver
driver = Selenium::WebDriver.for :chrome
# open CrossBrowserTesting.com inside Chrome
driver.navigate.to "http://www.python.org"
puts driver.title
driver.quit
代码在这里:
Gemfile
里面的依赖配置好了:
安装依赖:
$ bundle install
代码运行过程: