我正在尝试为Web应用程序自动化一些测试,并且许多测试需要在<iframe>
内拖放。我将一个锚从一个jspContainer拖到另一个<iframe>
内的另一个。在尝试执行拖放操作时,我不断获得Selenium::WebDriver::Error::MoveTargetOutOfBoundsError:
。尝试使用hover
方法时,我也遇到了同样的错误。但是,当我使用click
方法单击锚点时,它可以正常工作,我可以看到链接突出显示,就好像它已被点击一样。下面是我的一些代码和输出通过irb。
irb(main):048:0> a = b.frame(:id => "Iframe").link(:text => "anchor")
=> #<Watir::Anchor:0x..f02685d6 located=false selector={:text=>"anchor", :tag_name=>"a"}>
irb(main):049:0> c = b.frame(:id => "Iframe").div(:id => "drop")
=> #<Watir::Div:0x5ed628c6 located=false selector={:id=>"drop", :tag_name=>"div"}>
irb(main):050:0> a.wd.location
=> #<struct Selenium::WebDriver::Point x=295, y=339>
irb(main):051:0> c.wd.location
=> #<struct Selenium::WebDriver::Point x=30, y=329>
irb(main):052:0> c.style
=> "width: 250px; height: 100px;"
irb(main):053:0> b.frame(:id => "Iframe").locate
=> #<Watir::FramedDriver:0x24f3738 @element=#<Selenium::WebDriver::Element:0x..fc6af7d56 id="{11f61368-a4ea-4d
a9-9084-6307abcda2aa}">, @driver=#<Selenium::WebDriver::Driver:0x..f97d59986 browser=:firefox>>
irb(main):054:0> a.drag_and_drop_on c
Selenium::WebDriver::Error::MoveTargetOutOfBoundsError: Given coordinates (432, 542) are outside the document.
Error: MoveTargetOutOfBoundsError: The target location (432, 544) is not on the webpage.
irb(main):056:0* a.hover
Selenium::WebDriver::Error::MoveTargetOutOfBoundsError: Given coordinates (432, 542) are outside the document.
Error: MoveTargetOutOfBoundsError: The target location (432, 544) is not on the webpage.
irb(main):059:0* a.click
=> []
我注意到的一件事是设置变量a
时c和irb的输出说located=false
。但我可以使用exists?
,click
和flash
方法来显示watir-webdriver确实知道这些元素的位置。任何帮助或建议将不胜感激。
我正在使用watir-webdriver 0.6.2,Firefox 18.0.2,Windows 7 64位