Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/22.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
选定的_选项从iframe返回空白_Iframe_Watir_Watir Webdriver - Fatal编程技术网

选定的_选项从iframe返回空白

选定的_选项从iframe返回空白,iframe,watir,watir-webdriver,Iframe,Watir,Watir Webdriver,我正在尝试使用watir webdriver从选择列表返回所选值的文本。以下内容正常工作(使用Watir示例页面的示例) 但是,如果你把同样的代码贴在一个框架上,我什么也得不到 browser = Watir::Browser.new :ie browser.goto "test_iframe.html" browser.frame(:id => "test").select_list(:id => "entry_6").option(:index, 2).select puts b

我正在尝试使用watir webdriver从选择列表返回所选值的文本。以下内容正常工作(使用Watir示例页面的示例)

但是,如果你把同样的代码贴在一个框架上,我什么也得不到

browser = Watir::Browser.new :ie
browser.goto "test_iframe.html"
browser.frame(:id => "test").select_list(:id => "entry_6").option(:index, 2).select
puts browser.frame(:id => "test").select_list(:id => "entry_6").select_list(:id => "entry_6").selected_options

=>Nothing returned
iframe示例:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>

<body>
<p>TEST IFRAME ISSUES</p>

<iframe src="http://bit.ly/watir-example" id="test" width="100%" height="1400px">

</iframe>

</body>
</html>

测试IFRAME问题


我是否错过了什么,或者是否有其他方法可以做到这一点?

当选择列表位于Windows上的iFrame中时,选择选项中似乎有一个bug。尝试改用.value

b = Watir::Browser.start 'http://dl.dropbox.com/u/18859962/iframe.html', :ie
b.frame.exist? #=> true
b.frame.text_fields.count #=> 2
b.frame(:id => "test").select_list(:id => "entry_6").option(:index, 2).select
puts b.frame(:id => "test").select_list(:id => "entry_6").selected_options #=> nil
puts b.frame(:id => "test").select_list(:id => "entry_6").value
 # Internet Explorer
b.goto "bit.ly/watir-example"
b.select_list(:id => "entry_6").option(:index, 2).select
puts b.select_list(:id => "entry_6").selected_options #Internet Explorer
puts b.select_list(:id => "entry_6").value #Internet Explorer
我将此作为Watir WebDriver错误提出:

更新

同时,您可以循环浏览选项,找到所选选项,然后吐出html文本:

require 'nokogiri'
b.frame(:id => "test").select_list(:id => "entry_6").options.each do |option|
  puts Nokogiri::HTML(option.html).text if option.selected?
end
更新


这一问题已在watir webdriver 0.3.3中得到解决。当选择列表位于Windows上的iFrame中时,选择选项中的错误看起来很像。尝试改用.value

b = Watir::Browser.start 'http://dl.dropbox.com/u/18859962/iframe.html', :ie
b.frame.exist? #=> true
b.frame.text_fields.count #=> 2
b.frame(:id => "test").select_list(:id => "entry_6").option(:index, 2).select
puts b.frame(:id => "test").select_list(:id => "entry_6").selected_options #=> nil
puts b.frame(:id => "test").select_list(:id => "entry_6").value
 # Internet Explorer
b.goto "bit.ly/watir-example"
b.select_list(:id => "entry_6").option(:index, 2).select
puts b.select_list(:id => "entry_6").selected_options #Internet Explorer
puts b.select_list(:id => "entry_6").value #Internet Explorer
我将此作为Watir WebDriver错误提出:

更新

同时,您可以循环浏览选项,找到所选选项,然后吐出html文本:

require 'nokogiri'
b.frame(:id => "test").select_list(:id => "entry_6").options.each do |option|
  puts Nokogiri::HTML(option.html).text if option.selected?
end
更新


这一问题已在watir webdriver 0.3.3中解决

IE中存在此问题。FF似乎工作正常。目前我无法检查Chrome。IE中存在此问题。FF似乎工作正常。我现在无法检查Chrome。谢谢Alister。不幸的是,在我测试的代码中,该值不能代表文本元素,因此它对我不起作用。”修复评估“我会关注bug的进展。谢谢Alister。不幸的是,在我测试的代码中,该值不能代表文本元素,因此它对我不起作用。”“修复估算”我将密切关注bug的进展。