1st.既然它提示没有找到chromedriver,那咱们必须先下载一个(前提你得有个chrome浏览器。。。),下载地址就是http://code.google.com/p/chromium/downloads/list,好了,下载完成后将chromedriver.exe存放在C:\Documents and Settings\Administrator\Local Settings\Application Data\Google\Chrome\Application,因为你的chrome浏览器也是安装在这里的。
2nd.他说要place it somewhere on your PATH,那'PATH'是什么呢,其实就是系统环境变量里的‘path’变量,请看以下代码:
- def self.executable_path
- @executable_path ||= (
- Platform.find_binary "chromedriver" or raise Error::WebDriverError, MISSING_TEXT
- #Platform.find_binary "chrome" or raise Error::WebDriverError, MISSING_TEXT
- )
- end
def self.executable_path @executable_path ||= ( Platform.find_binary "chromedriver" or raise Error::WebDriverError, MISSING_TEXT #Platform.find_binary "chrome" or raise Error::WebDriverError, MISSING_TEXT ) end这段代码存放在chrome/service.rb,他又调用platform.find_binary函数,传入参数'chromdriver',我们再看看find_binary函数
- <FONT xmlns="http://www.w3.org/1999/xhtml">def find_binary(*binary_names)
- puts 'names:'
- puts *binary_names
- paths = ENV['PATH'].split(File::PATH_SEPARATOR)
- puts 'paths:'
- puts paths
- binary_names.map! { |n| "#{n}.exe" } if windows?
- puts 'name2:'
- puts binary_names
- binary_names.each do |binary_name|
- paths.each do |path|
- exe = File.join(path, binary_name)
- puts 'result'
- puts File.join(path, binary_name)
- return exe if File.executable?(exe)
- end
- end
- nil
- end</FONT>
PS:也许你在添加环境变量后,仍没有反应,那就把你当请的cmd窗口关闭,再重新打开一个cmd窗口再执行。