如何设置Selenium WebDriver使用selenium-webdriver gem
问题描述:
令人惊讶的是,我找不到关于如何设置Selenium WebDriver通过谷歌大学使用selenium-webdriver gem的第一步指南。我想这个宝石需要知道我在哪里存储所有这些jar文件来开始。我该如何配置?如何设置Selenium WebDriver使用selenium-webdriver gem
答
首先,你必须安装宝石硒的webdriver:
创业板安装硒的webdriver
然后你就可以开始你的Ruby程序:
#You need to require the gem "selenium-driver"
require "selenium-webdriver"
#... see webdriver ruby api docs here: http://selenium.googlecode.com/svn/trunk/docs/api/rb/_index.html
#... Most usefull classes are Driver and Element, check them out for a good start
driver = Selenium::WebDriver.for :firefox
driver.navigate.to "http://www.google.com"
element = driver.find_element(:name, 'q')
element.send_keys "Hello WebDriver!"
element.submit
puts driver.title
driver.quit
你可以找到更多信息:
about webdriver and ruby (all said above was an attempt to summarize it)
正如你所看到的一样,Webdriver API本身具有不同的“样式”的普通硒-ruby程序......如果你想使用webdriver并仍然继续用Selenium-API编程,您应该切开Selenium2.0远程服务器,因为它似乎将以透明的方式使用Webdriver,同时仍然维持着相同的已知Selenium红宝石API
如果我对部分信息有误,请纠正我,我们将一起使其更清晰:)
PD:最好找到关于Selenium和Webdriver之间的关系的信息是this博客文章
没关系,事实证明我不需要做任何事情! – yiwen 2010-05-09 05:56:07