ElementNotVisibleException:消息:元素在Robot Framework中不可交互 [英] ElementNotVisibleException: Message: element not interactable in Robot Framework

查看:292
本文介绍了ElementNotVisibleException:消息:元素在Robot Framework中不可交互的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

示例代码:

<div class="modal-footer">
   <button type="button" class="btn btn-primary btn-block" data-modal="AlertSubmitApproval" id="btn_close_modal">ตกลง</button>
</div>

我尝试单击按钮 id = btn_close_modal ,但似乎按钮不可见,然后机器人响应 ElementNotVisibleException:消息:元素不可交互,尽管我可以手动单击。

I try to click the button id="btn_close_modal" but it seems like the button is not visible then robot response ElementNotVisibleException: Message: element not interactable, in spite of the fact I able to click by manual.

我的机器人代码:

Request approve
Selenium2Library.Click Element   &{Landing}[reqApprove]
Sleep   2s
Selenium2Library.Click Element   &{Landing}[cofReq]
Sleep   2s
Selenium2Library.Wait Until Page Contains Element     id=btn_close_modal    timeout=20s
Sleep   3s
Selenium2Library.Click Element   id=btn_close_modal

我怎么能单击按钮 id = btn_close_modal ,请任何人帮忙。

How can I able to click the button id=btn_close_modal, please could anyone help.

推荐答案

所需元素位于模态对话框中,因此您需要诱使 WebDriverWait 使元素可见/启用,您可以使用以下两种解决方案中的一种/两种:

The desired element is within a Modal Dialog Box so you need to induce WebDriverWait for the element to be visible/enabled and you can use either/both (clubbing up) of the following solutions:


  • 等待直到Element可见为止

Request approve
Selenium2Library.Click Element   &{Landing}[reqApprove]
Sleep   2s
Selenium2Library.Click Element   &{Landing}[cofReq]
Sleep   2s
Selenium2Library.Wait Until Element Is Visible     xpath=//button[@class="btn btn-primary btn-block" and @id="btn_close_modal"]    timeout=20s
Sleep   3s
Selenium2Library.Click Element   xpath=//button[@class="btn btn-primary btn-block" and @id="btn_close_modal"]


  • 等待直到启用元素

    Request approve
    Selenium2Library.Click Element   &{Landing}[reqApprove]
    Sleep   2s
    Selenium2Library.Click Element   &{Landing}[cofReq]
    Sleep   2s
    Selenium2Library.Wait Until Element Is Enabled     xpath=//button[@class="btn btn-primary btn-block" and @id="btn_close_modal"]    timeout=20s
    Sleep   3s
    Selenium2Library.Click Element   xpath=//button[@class="btn btn-primary btn-block" and @id="btn_close_modal"]
    


  • 您可以找到有关等待直到元素可见和 机器人框架:Selenium2Lib:等到(…)关键字

    参考:< a href = http://robotframework.org/Selenium2Library/Selenium2Library.html#Shortcuts rel = nofollow noreferrer> Selenium2Library

    这篇关于ElementNotVisibleException:消息:元素在Robot Framework中不可交互的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    相关文章
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆