2017-03-05 56 views
0

我未能通過硒分配下列元素(我需要找到並使用文本(ID填充):硒 - 發現並填補元素

    <tr> 
        <th class="col-md-3 basicPropertiesName">Id</th> 
        <td class="col-md-9"> 
         <input class="form-control ng-pristine ng-valid ng-     touched" ng-keypress="keypressHandler($event, 2)" ng-model="newInsight.id" placeholder="ID"> 
        </td> 
       </tr> 

回答

0

也許你需要像這樣

By(xpath("//input[@ng-model='newInsight.id'])) 
0

或者,也許這?

$("input[ng-model='newInsight.id']").setValue(value); 
0
$(By.xPath("//tr[./th[text()='Id']]")).find("input").setValue("some text) 

或無需額外的查找()

$(By.xPath("//tr[./th[text()='Id']]//input")).setValue("some text) 
0

您也可以使用以下選項使用css選擇器。

String str="th[class*='basicPropertiesName']"; 
SelenideElement element =$(str); 

String str="th:contains('Id')"; 
SelenideElement element =$(str);