不一致检测元件硒的webdriver [英] Inconsistency in detecting elements Selenium Webdriver

查看:194
本文介绍了不一致检测元件硒的webdriver的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图运行自动化测试脚本(硒Webdriver2 +红宝石),但后期面临的一个奇怪的问题了。
这工作完全正常,直到昨天该脚本抛出没有这样的元素异常'了。
然而,在萤火检查,那里有在应用程序什么那么没有改变它的路径确实存在。
该脚本无法在低于code检测iframe2: -

I am trying to run automated test scripts (Selenium Webdriver2 + ruby) but facing a weird problem off late. The scripts that worked perfectly fine till yesterday is throwing 'No such element exception' now. However, the path certainly exists when checked in firebug and theres no change in the application what so ever. The script fails in detecting iframe2 in below code: -

browser.manage.timeouts.implicit_wait = 20#秒

browser.manage.timeouts.implicit_wait = 20 # seconds

                                                        ############ GO TO OVERVIEW TAB ################

#Adding wait until quote is created and page is ready for content tab click.
wait = Selenium::WebDriver::Wait.new(:timeout => 5)
wait.until { browser.find_element(:id => "j_id0:tabDetailedContent_lbl") }

browser.find_element(:id => "j_id0:tabDetailedContent_lbl").click



iframe = browser.find_element(:id =>'CPQFrame')
browser.manage.timeouts.implicit_wait = 10
browser.switch_to.frame(iframe) 

browser.find_element(:css,".processBarElement.noSelected").click


#frame.browser.find_element(:css,".processBarElement.noSelected").click

#browser.manage.timeouts.implicit_wait = 30 # seconds

iframe2 = browser.find_element(:xpath,'html/body/div[3]/div[2]/div[2]/div[3]/iframe')

#browser.manage.timeouts.implicit_wait = 10
browser.switch_to.frame(iframe2)

我GOOGLE这样的不一致的行为,但找不到任何合理的解决方案。一个职位被追溯至2009年这归咎于不稳定的硒的webdriver。

I googled for such inconsistent behavior but could not find any reasonable solution. One post was dated back to 2009 which blames unstable Selenium Webdriver.

有其他人经历过这个吗?任何解决方法/解决方案?

Has anybody else experienced this too? Any workaround / solutions?

帮助了你们!

感谢。

阿布舍克

推荐答案

这是不太可能与的webdriver变得不稳定,但与执行定时行为不同于前一个问题。我建议采取看看使用明确的等待的一段,您有元素很难找到。您可以硒文档中读到这里他们。

This is less likely to be an issue with Webdriver being unstable but with the execution timing behaving differently than before. I would suggest taking a look at using explicit waits for some of the elements that you are having a hard time finding. You can read about them here in the selenium documentation.

这是seleniumhq例如:

This is the seleniumhq example:

require 'rubygems' # not required for ruby 1.9 or if you installed without gem
require 'selenium-webdriver'

driver = Selenium::WebDriver.for :firefox
driver.get "http://somedomain/url_that_delays_loading"

wait = Selenium::WebDriver::Wait.new(:timeout => 10) # seconds
begin
  element = wait.until { driver.find_element(:id => "some-dynamic-element") }
ensure
  driver.quit
end

这篇关于不一致检测元件硒的webdriver的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆