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

代码运行过程:

My Github Page: https://github.com/liweinan

Powered by Jekyll and Theme by solid

If you have any question want to ask or find bugs regarding with my blog posts, please report it here:
https://github.com/liweinan/liweinan.github.io/issues