我正在 Ubuntu 上使用 Watir-WebDriver 和 Ruby 1.9.2 为网络编写自动测试。我有一些带有几个元素的 iframe。我需要单击项目并检查会发生什么。 <iframe>
看起来像:
<iframe id="iframe" align="top" some_attribute="some_attribute">
<html>
<head>
<title> Some title </title>
</head>
<body>
<div>
<button id="id_button" type="button" class="some_class"/>
</div>
</body>
</html>
</iframe>
当我点击按钮时,它应该创建菜单。但是当我点击带有 watir-webdriver 的按钮时,没有任何反应,就好像他没有按下一样。 Watir 不打印任何异常,但不按下按钮。
此问题仅存在于 Internet Explorer 中。对于 Firefox 和 Chrome,没有问题。我的代码如下所示:
browser = Watir :: Browser.new (: remote,: url => "http://some_ip:4444/wd/hub",: desired_capabilities =>: internet_explorer)
browser.goto ("http://some_http.com")
browser.iframe.button (: id, "id_button"). click
如果我写
browser.iframe.button(: id, "id_button").attribute_value("class")
它正在返回 "some_class"
.这表明该项目已被识别,但仍然没有任何反应。
最佳答案
请试试这段代码
browser.iframe(:id, "iframe").button (: id, "id_button").click
如果您需要更多信息,请查看此链接
关于html - Watir/Selenium2 在 Internet Explorer 9 中单击 iframe 内的元素后没有任何反应,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12306297/