2017-08-11 41 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定位器信息