本文介绍了ElementNotVisibleException:消息:元素在Robot Framework中不可交互的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 示例代码:<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 approveSelenium2Library.Click Element &{Landing}[reqApprove]Sleep 2sSelenium2Library.Click Element &{Landing}[cofReq]Sleep 2sSelenium2Library.Wait Until Page Contains Element id=btn_close_modal timeout=20sSleep 3sSelenium2Library.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 approveSelenium2Library.Click Element &{Landing}[reqApprove]Sleep 2sSelenium2Library.Click Element &{Landing}[cofReq]Sleep 2sSelenium2Library.Wait Until Element Is Visible xpath=//button[@class="btn btn-primary btn-block" and @id="btn_close_modal"] timeout=20sSleep 3sSelenium2Library.Click Element xpath=//button[@class="btn btn-primary btn-block" and @id="btn_close_modal"] 等待直到启用元素:Request approveSelenium2Library.Click Element &{Landing}[reqApprove]Sleep 2sSelenium2Library.Click Element &{Landing}[cofReq]Sleep 2sSelenium2Library.Wait Until Element Is Enabled xpath=//button[@class="btn btn-primary btn-block" and @id="btn_close_modal"] timeout=20sSleep 3sSelenium2Library.Click Element xpath=//button[@class="btn btn-primary btn-block" and @id="btn_close_modal"] 您可以找到有关等待直到元素可见和 机器人框架:Selenium2Lib:等到(…)关键字参考: Selenium2Library 这篇关于ElementNotVisibleException:消息:元素在Robot Framework中不可交互的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 06-27 07:33