【问题标题】:Elements able to find in IRB, but not in webdriver run能够在 IRB 中找到但不能在 webdriver 运行中找到的元素
【发布时间】:2014-12-08 22:56:19
【问题描述】:

我在应用程序中有一个锚定覆盖,我需要在其中执行 3 个操作:输入文本,选择一个复选框,然后单击确定。我可以找到元素并在 IRB 中遍历这些元素。但是相同的行代码在 webdriver 运行时失败。我使用 rspec。我收到 Selenium::WebDriver::Error::ElementNotVisibleError 的错误: 元素当前不可见,因此可能无法与之交互

HTML 看起来像:

<div id="xwt_widget_form_AnchoredOverlay_0_Popover" class="xwtPopover xwtAnchoredOverlayPopover dijitTooltipDialog xwt_BasePickerPopover disablePointer xwtAnchoredOverlayPopoverBelow dijitTooltipABLeft dijitTooltipBelow" wairole="presentation" widgetid="xwt_widget_form_AnchoredOverlay_0_Popover" style="top: 0px; visibility: visible;">

在此之下,是一个文本框表格:

 <td class="gridxCell " style="width:100px;;min-width:100px;;" aria-grabbed="false">
<div class="quickFilterItem forHeader-ipaddress">
<div id="widget_dijit_form_TextBox_22" class="dijit dijitReset dijitInline dijitLeft dijitTextBox" role="presentation" widgetid="dijit_form_TextBox_22" style="width: 100px;">
<div class="dijitReset dijitInputField dijitInputContainer">
<input id="dijit_form_TextBox_22" class="dijitReset dijitInputInner" type="text" autocomplete="off" data-dojo-attach-point="textbox,focusNode" tabindex="0" value="">
</div>

这是我的代码:

 def overlay_method(text)
      @browser.div(:class => 'xwt_BasePickerButton dijitDownArrowButton').click
      sleep 3
      @browser.div(:class => 'quickFilterItem forHeader-ipaddress').wait_until_present(10)
      @browser.div(:class => 'quickFilterItem forHeader-ipaddress').text_field.set text
      sleep 1
      @browser.span(:class => 'gridxIndirectSelectionCheckBox dijitReset dijitInline dijitCheckBox', :index => 0).click
      sleep 3
      @browser.div(:class => 'xwtAnchoredOverlayPopoverBelow').span(:text => 'OK').wait_until_present(10)
      @browser.div(:class => 'xwtAnchoredOverlayPopoverBelow').span(:text => 'OK').click


  end

在运行中,看起来覆盖在尝试输入文本或执行任何操作时折叠。 请求提供一些我可以尝试的指示。令人困惑的是,在 irb 它可以工作,但不能在脚本运行中工作。我尝试过使用焦点、悬停、send_keys 等。

更新:发现将任何窗口保持在浏览器顶部运行,使其工作。我在浏览器运行的顶部保持小终端窗口处于活动状态(焦点),并且我看到它正在工作。所以现在在这种行为中如何在运行中处理。

寻找一些输入。非常感谢。

谢谢

【问题讨论】:

  • 你试过什么代码?
  • 请分享您的代码。
  • 如果您能提供一个重现问题的示例 HTML,将会有所帮助。
  • 更新了更多细节。谢谢。
  • 在这里寻求帮助!!那么我们如何访问另一个焦点窗口使其工作的元素。

标签: rspec selenium-webdriver anchor overlay watir-webdriver


【解决方案1】:

我找到了答案。

触发锚定覆盖的点击动作并没有被 webdriver 真正识别出来。因此,尽管显示了叠加层,但 webdriver 抱怨元素不可见以进行交互。 我使用 .send_keys :enter 而不是 .click。这使得 webdriver 能够理解叠加层的显示,并且可以轻松地与叠加层上的元素进行交互。

翡翠

【讨论】:

    猜你喜欢
    • 2019-10-06
    • 2011-07-05
    • 1970-01-01
    • 2023-04-09
    • 1970-01-01
    • 1970-01-01
    • 2013-07-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多