Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 元素在点处不可单击,ruby_Jquery_Ruby_Selenium_Webdriver_Element - Fatal编程技术网

Jquery 元素在点处不可单击,ruby

Jquery 元素在点处不可单击,ruby,jquery,ruby,selenium,webdriver,element,Jquery,Ruby,Selenium,Webdriver,Element,我正在使用Rspec、seleniumwebdriver、Ruby、macosx,当我为Firefox执行脚本时,一切都很顺利。当我更改到Chrome版本43.0.2357.130时,出现了错误 在生成页面中失败。选择帐户按钮。单击 但是,前面的行返回坐标 更新 我找到了解决这个问题的办法 看起来有一些ajax调用正在进行,阻止了元素被单击。同时添加等待将首先解决您的问题,考虑在您的单击方法中添加 WaITyFuxAjax 方法。< /P> 例如: def wait_for_ajax(time

我正在使用Rspec、seleniumwebdriver、Ruby、macosx,当我为Firefox执行脚本时,一切都很顺利。当我更改到Chrome版本43.0.2357.130时,出现了错误

在生成页面中失败。选择帐户按钮。单击

但是,前面的行返回坐标

更新

我找到了解决这个问题的办法


看起来有一些ajax调用正在进行,阻止了元素被单击。同时添加等待将首先解决您的问题,考虑在您的单击方法中添加<强> WaITyFuxAjax <强>方法。< /P> 例如:

def wait_for_ajax(timeout = 30)
  wait = Selenium::WebDriver::Wait.new timeout: timeout
  wait.until { @driver.execute_script("return jQuery.active == 0") == true }
end

这样做的好处是,您不会在等待中硬编码,这很糟糕。

如果您在chrome工具中使用选择器并手动请求它,它会返回您期望的结果吗?这似乎是一个时间问题,但我希望FF比ChromeI尝试增加睡眠时间更多,但没有帮助。我倾向于发现当每个do usedCan我们看到您的代码时会出现问题???您可以尝试使用findElementBySelector,然后在JS中编写driver.actions().mouseDown(element.perform()。我当时也遇到过这些麻烦,我现在在Rspec上,Ruby。正在查找语法。元素实际上会在选择所需的电话号码时盖上盖子
And(/^User select account and telephone to upgrade$/) do
  @profile = get_account("consumer.postpaid.user9")
  RubyHelper.wait_js_load_in_seconds(5)
  accounts = @driver.find_elements(:css => "p.account-number")
  accounts.each do |account|
    account.click if account.text.include? @profile.ban
    account
   # scroll the element into view, then return its location
   # build_page.choose_account_button.location_once_scrolled_into_view
    build_page.choose_account_button.click
  end
  RubyHelper.wait_js_load_in_seconds(6)
  elements = @driver.find_elements(:css => "h3.phone-number")
  elements.each do |element|
    element.click if element.text == @profile.phone
    element
  end
el = driver.find_element(:id, "some_id")
driver.action.click(el).perform
def wait_for_ajax(timeout = 30)
  wait = Selenium::WebDriver::Wait.new timeout: timeout
  wait.until { @driver.execute_script("return jQuery.active == 0") == true }
end