首页 > 解决方案 > 如何使用机器人框架单击表单中的元素

问题描述

我尝试单击表单中的元素,但机器人不喜欢我提供的元素。我尝试了 3 种方法,但仍然找不到定位器

 Wait Until Element Is Visible  &{FinishCall}[endCall]  timeout=60s
 Click Element   &{FinishCall}[endCall]

 Submit Form   &{FinishCall}[endCall]

 Execute Javascript   document.getElementById("j_id0:currentCallLogForm:currentCallLogPB:j_id7:j_id9").addEventListener('click', function (){console.log('execute on click')});

元素位于 iframe 下的示例 HTML

<input class="btn" id="j_id0:currentCallLogForm:currentCallLogPB:j_id7:j_id9" name="j_id0:currentCallLogForm:currentCallLogPB:j_id7:j_id9" onclick=";A4J.AJAX.Submit('j_id0:currentCallLogForm',event,{'similarityGroupingId':'j_id0:currentCallLogForm:currentCallLogPB:j_id7:j_id9','oncomplete':function(request,event,data){goToCustPage();},'parameters':{'j_id0:currentCallLogForm:currentCallLogPB:j_id7:j_id9':'j_id0:currentCallLogForm:currentCallLogPB:j_id7:j_id9'} ,'status':'sfStatus'} );return false;" value="Finish Not On Call" type="button">

任何人请帮助我。

标签: robotframework

解决方案


您操作的元素很可能在 iframe 内,检查页面上的 iframe 并首先选择它 - 使用以下关键字

Select Frame    name or id of iframe
Click Element    element locator or name or id

推荐阅读