【发布时间】:2018-04-22 09:12:51
【问题描述】:
我不确定如何选择下面编码的输入区域:
<input _ngcontent-c15="" class="form-control form-control-danger ng-pristine ng-invalid ng-touched" placeholder="Name of the snapshot definition " type="text" ng-reflect-form="[object Object]">
此外,在文本值更改后,上述更改如下:
<input _ngcontent-c15="" class="form-control form-control-danger ng-touched ng-dirty ng-valid" placeholder="Name of the snapshot definition " type="text" ng-reflect-form="[object Object]">
下同:
<input _ngcontent-c15="" class="form-control form-control-danger ng-pristine ng-valid ng-touched" placeholder="Description snapshot definition" type="text" ng-reflect-form="[object Object]">
更改为:
<input _ngcontent-c15="" class="form-control form-control-danger ng-valid ng-touched ng-dirty" placeholder="Description snapshot definition" type="text" ng-reflect-form="[object Object]">
我尝试了以下多种组合:
element = driver.FindElementByXPath("//input[@class='form-control form-control-danger ng-pristine ng-invalid ng-touched']");
element = driver.FindElementByXPath("//input[contains(@class,'form-control form-control-danger ng-pristine ng-invalid ng-touched')]");
element = driver.FindElementByXPath("//*[contains(@class,'form-control form-control-danger ng-pristine ng-invalid ng-touched')]");
element = driver.FindElementByXPath("//a[contains(@class,'form-control form-control-danger ng-pristine ng-invalid ng-touched')]");
element = driver.FindElementByCssSelector("placeholder='Name of the snapshot definition '");
相关区域的完整 div:
<div _ngcontent-c25="" class="form-group has-danger" ng-reflect-klass="form-group" ng-reflect-ng-class="[object Object]">
<label _ngcontent-c25="">Name</label>
<input _ngcontent-c25="" class="form-control form-control-danger ng-pristine ng-invalid ng-touched" placeholder="Name of the snapshot definition " type="text" ng-reflect-form="[object Object]">
<!--bindings={"ng-reflect-ng-if": "true"}-->
<div _ngcontent-c25="" class="alert alert-danger">Required Field</div>
<!--bindings={"ng-reflect-ng-if": "false"}-->
<!--bindings={"ng-reflect-ng-if": "false"}-->
</div>
我不需要提取任何文本。我需要将其输入该区域。
【问题讨论】:
-
你要选中的文字
-
抱歉,我想选择发送文本的区域。
-
你试试按名称查找
-
将使用什么名称?这些文本字段是动态添加的,因此在我重新加载页面后,_ngcontent-c15 现在是 _ngcontent-c19。
-
名字在哪里??
标签: c# selenium xpath css-selectors selenium-chromedriver