【发布时间】:2017-04-17 12:31:41
【问题描述】:
当我使用 Selenium WebDriver 运行用 Ruby Cucumber 编写的自动化测试时,我遇到了 IE 浏览器链接闪烁的问题。
Scenario: Navigating to Reporting home page.
Given I see menu Reporting available.
When I navigate to "Annual Reporting".
Then I see the correct header on Annual Reporting page.
home_page.rb(方法一:使用page_object)
link(:annual_reporting_link, :id => 'annualReportingLinkId')
def go_to_reporting
mouse_over_home
wait_until(5) do
annual_reporting_link
end
end
结果:由于链接闪烁,无法点击链接。
然后我尝试了以下(方法2:使用send_keys)
@browser.find_element(:id, 'annualReportingLinkId').send_keys :return
and
@browser.find_element(:id, 'annualReportingLinkId').send_keys(KEYS.ENTER)
但它也没有工作。运行测试时出现此错误:
Selenium::WebDriver::Error::ElementNotVisibleError: Cannot click on element
HTML:
<div id="homeMenu">
<ul>
<li class="has-sub"><a class="homeButton" href="/report-web"></a>
<ul id="homeLinks">
<li id="report1LiId"><a href="/report-web/openItems?subApp=report1&rptid=15" id="report1LinkId" class="disabledLinks"><span id="report1LinkName" class="disabledLinksText">Report 1</span></a></li>
<li id="report2Id"><a href="/report-web/realms?subApp=report2&rptid=16" id="report2LinkId" class="disabledLinks"><span id="report2LinkName" class="disabledLinksText">Report 2</span></a></li>
<li id="annualLiId"><a href="/report-web?subApp=annual" id="annualReportingLinkId"><span id="annualReportingLinkName">Annual Reporting</span></a></li>
<li id="administrationLiId"><a href="/report-web/administration?subApp=ADMIN" id="administrationLinkId" class="disabledLinks"><span id="administrationLinkName" class="disabledLinksText">Manage Users</span></a></li>
</ul>
</li>
</ul>
</div>
测试自动化能够扩展主菜单,其中包含子菜单 - 超链接。但是在 mouse_over_home(主菜单)之后,子菜单开始闪烁。我需要点击“annual_reporting_link”才能进入这个报告页面,但是因为闪烁,测试自动化根本无法点击。
有人有适合您的解决方案吗?请分享您的解决方案。
环境:
Ruby: 1.9.3
Cucumber: 2.1.0
Selenium Webdriver: 2.53.4
page-object: 1.2.0
IE: 11
【问题讨论】:
-
请发布重现此问题所需的(最少的)
selenium-webdriver代码。 -
我刚刚用一些代码编辑了我的问题。谢谢!
-
“链接闪烁”是什么意思?这是一个导航菜单,您需要将鼠标悬停在上面才能单击子菜单链接?如果是这样,您如何扩展菜单 - 即
mouse_over_home做什么? -
嗨贾斯汀,我刚刚用你的问题更新了我的问题。是的,我需要将鼠标悬停在点击子菜单链接。请让我知道您的想法。谢谢!
-
嗨,贾斯汀,听起来您可能在使用 Selenium WebDriver 的 IE 浏览器中遇到了同样的问题。你知道是否有任何解决方法吗?谢谢!
标签: ruby internet-explorer selenium-webdriver cucumber page-object-gem