2017-08-11 381 views
0

我有HTML页面,它有重复的元素ID LoginAccount。我想在ID中输入帐户名称,但使用机器人框架,我总是收到异常错误。有没有人有想法如何选择特定的元素ID,然后在文本框中输入文本?如何处理RobotFramework中的重复元素?

代码:

<form-group _ngcontent-c10="" autofocus="true" id="LoginAccount" inputtype="text" labelname="Account" _nghost-c11=""><div _ngcontent-c11="" class="form-group row"> 
    <!----> 
    <!----><!----> 
    <label _ngcontent-c11="" class="col-12 col-sm-6">Account</label> 
    <!----><input _ngcontent-c11="" class="col-12 col-sm-6 ng-pristine ng-valid ng-touched" type="text" id="LoginAccount"> 

    <!----> 
</div> 
</form-group> 

错误:

InvalidElementStateException: Message: invalid element state: Element must be user-editable in order to clear it. 

回答

0

XPath定位:

for up element: //from-group[@id='LoginAccount'] 
for inside element: //from-group[@id='LoginAccount']//input[@id="Account"] 

使用driver.findElementByXpath() function

更多的XPath定位器信息