我整天都在使用Cucumber,即使我没有更改任何文件,它也停止了工作.
它给出了一个错误,内容如下:
Unable to either launch or connect to Chrome. Please check that ChromeDriver is up-to-date. Using Chrome binary at: /Applications/Google Chrome.app/Contents/MacOS/Google Chrome (Selenium::WebDriver::Error::UnknownError)
有什么想法,发生了什么事?
非常积极的你必须使用.清楚,或者可能不是因为它似乎不适合我,也许我只是执行它错了我不确定.
例:
browser.div(:id => "formLib1").clear.type("input", "hi")
Run Code Online (Sandbox Code Playgroud)
任何人都可以告诉我如何简单地清除一个字段然后输入一个新的字符串?
对于我正在处理的项目,我需要伪造一个IP地址,以显示我来自其他国家/地区.
基本上,如果检测到的IP来自英国,则显示弹出窗口A,如果检测到的IP来自英国以外,则显示弹出窗口B.
我希望能够实现自动化.目前我们所有的浏览器自动化测试都是用cucumber/watir编写的,我想得到一个使用相同框架的解决方案.
有谁知道这样做的可行方法?
谢谢!
我已经安装了Ruby 2,devkit和Watir.我收到以下错误.有谁可以帮我解决这个问题?
C:\devkit>irb
DL is deprecated, please use Fiddle
irb(main):001:0> require "watir"
=> true
irb(main):002:0> browser = Watir::Browser.new
LoadError: cannot load such file -- watir-classic
from C:/Ruby200/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'
from C:/Ruby200/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in`require'
from C:/Ruby200/lib/ruby/gems/2.0.0/gems/watir-4.0.2/lib/watir/loader.rb:48:in `load_driver'
from C:/Ruby200/lib/ruby/gems/2.0.0/gems/watir-4.0.2/lib/watir/loader.rb:40:in `load_driver_for'
from C:/Ruby200/lib/ruby/gems/2.0.0/gems/watir-4.0.2/lib/watir/loader.rb:8:in `new'
from (irb):2
from C:/Ruby200/bin/irb:12:in `<main>'
irb(main):003:0>
Run Code Online (Sandbox Code Playgroud) 我正在使用 watir gem 在我的应用程序上实现一个非常基本的刮刀。它在本地运行得很好,但是当我在 heroku 上运行它时,它会触发此错误:Webdrivers::BrowserNotFound: Failed to find Chrome binary.
我在我的应用程序中添加了 google-chrome 和 chromedriver buildpacks,以告诉 Selenium 在哪里可以找到 Heroku 上的 Chrome,但它仍然不起作用。此外,当我打印选项时,二进制文件似乎已正确设置:
#<Selenium::WebDriver::Chrome::Options:0x0000558bdf7ecc30 @args=#<Set: {"--user-data-dir=/app/tmp/chrome", "--no-sandbox", "--window-size=1200x600", "--headless", "--disable-gpu"}>, @binary="/app/.apt/usr/bin/google-chrome-stable", @prefs={}, @extensions=[], @options={}, @emulation={}, @encoded_extensions=[]>
这是我的应用程序 Buildpack URL:
1. heroku/ruby
2. heroku/google-chrome
3. heroku/chromedriver
Run Code Online (Sandbox Code Playgroud)
这是我的代码:
def new_browser(downloads: false)
options = Selenium::WebDriver::Chrome::Options.new
chrome_dir = File.join Dir.pwd, %w(tmp chrome)
FileUtils.mkdir_p chrome_dir
user_data_dir = "--user-data-dir=#{chrome_dir}"
options.add_argument user_data_dir
if chrome_bin = ENV["GOOGLE_CHROME_SHIM"]
options.add_argument "--no-sandbox"
options.binary = chrome_bin
end
options.add_argument "--window-size=1200x600"
options.add_argument "--headless" …
Run Code Online (Sandbox Code Playgroud) 我正在尝试将Ruby + WATIR安装到处于隔离环境中的Windows服务器上.通常我会运行ruby安装程序,然后执行以下两个命令:
1)gem update --system
2)gem install watir
这是根据这里的指示
我现在尝试安装的服务器没有互联网连接.这会导致上面的命令失败.
有没有办法可以下载所需的更新包并将它们复制到服务器以在本地安装?
我正在使用watir-webdriver并试图检查HTML元素的背景颜色.问题是背景颜色是在CSS中设置的,而不是在HTML标记内.
有没有办法使用watir-webdriver读取CSS值?
这是一个研究案例:
<html>
...
<embed name="foo">
<embed name="bar">
...
</html>
Run Code Online (Sandbox Code Playgroud)
我正在尝试使用Watir Ruby的API引用名为"bar"的embed元素.该元素由Chrome的DOM Inspector显示,但我无法使用Watir的任何查找方法找到它:
browser.embeds() # only <embed name="foo"> is found
browser.html.include? 'bar' # => false
Run Code Online (Sandbox Code Playgroud)
为什么会这样?为什么Watir没有显示完整的HTML?如果我有不同帧中的元素或由Javascript init函数动态插入,是否可以使用Watir访问它们?
谢谢
我试图用Ruby中的Selenium WebDriver 2.4模拟鼠标移动
如果我运行测试,我是否应该看到鼠标在屏幕上移动?我糊涂了.
我尝试了很多不同的方法示例代码:
require 'selenium-webdriver'
driver = Selenium::WebDriver.for :firefox
driver.navigate.to 'http://www.google.com'
element = driver.find_element(:id, 'gbqfba')
Run Code Online (Sandbox Code Playgroud)
然后我试过了
driver.action.move_to(element).perform
driver.mouse.move_to(element)
Run Code Online (Sandbox Code Playgroud)
还有Watir的悬停方法.
到目前为止我找到的最好的方法是Watir的fire_event'onmouseover'但仍然没有移动鼠标:)
在SO和其他地方搜索之后,我似乎无法在WebDriver中移动鼠标.
什么事情发生?是否可以在屏幕上实际移动鼠标光标(当webdriver浏览器窗口在视图中时)
因此,可能最重要的是我使用c9.它是云中的IDE,因此在尝试将Chrome或Firefox与Watir一起使用时给我带来了很多麻烦,因为我无法编写Chrome或Firefox浏览器的路径.我也尝试了我能找到的等待方法的各种变化,但它们都没有用.
def save
require 'watir'
require 'phantomjs'
@browser = Watir::Browser.new :phantomjs
@browser.goto "https://kroger.softcoin.com/programs/kroger/digital_coupons/?origin=DigitalCoupons&banner=Smiths#contentBox"
@browser.div(id: "contentBox").wait_until(&:present?).text
@products = @browser.divs
end
Run Code Online (Sandbox Code Playgroud)
错误
30秒后超时,等待#"contentBox"的真实条件,:tag_name =>"div"}>
我想解决这个无法从史密斯网站上抓取数据的问题的方法是使用Chrome浏览器,但我收到错误"无法连接到chromedriver 127.0.0.1:9515"