gpt4 book ai didi

python - 元素不可见异常 : Message: element not interactable in Robot Framework

转载 作者:行者123 更新时间:2023-12-01 08:51:22 25 4
gpt4 key购买 nike

示例代码:

<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:消息:元素不可交互,尽管如此事实上我可以手动点击。

我的机器人代码:

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,请有人帮忙。

最佳答案

所需的元素位于模态对话框中,因此您需要引发WebDriverWait以使元素可见/启用,并且您可以使用以下解决方案中的一个/两个(组合):

  • 等待元素可见:

    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"]
  • 您可以在 Robotframework: Selenium2Lib: Wait Until (…) Keywords 中找到有关 Wait Until Element Is VisibleWait Until Element Is Enabled 的详细讨论。

  • 引用:Selenium2Library

关于python - 元素不可见异常 : Message: element not interactable in Robot Framework,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53097684/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com