使用标记外部文本定位元素的Xpath

时间:2016-09-29 10:46:15

标签: xpath

如何使用" ABQ"选择输入元素。 xpath下面不起作用。

//div[contains(text(),'Pick-up')]/following::label/input[contains(text(),'ABQ')]

示例输入(为OP编辑)

<div class="col-xs-2 profile-location-panal profile-pickupLocationPanel">
    <!--Locations-->
    <div class="panel panel-default" ng-class="{'panel-invalid':isSaveProfileClicked&amp;&amp;profileInformationForm.locations.$error.required}">
        <div class="panel-heading">Pick-up Locations</div>
        <div class="panel-body">
            <div class="panalScroll">
                <div class="checkbox">
                    <label>
                        <input type="checkbox" ng-click="toggleAllLocations()" ng-checked="checkLocationsAll()">All
                    </label>
                </div>
                <!-- ngRepeat: item in pickUpLocations --><div class="checkbox ng-scope" ng-repeat="item in pickUpLocations">
                    <label class="ng-binding">
                        <input name="locations" required="required" type="checkbox" ng-required="selected.pickUpLocations.length==0" checklist-value="item.code" checklist-model="selected.pickUpLocations">
                        ABQ
                    </label>

http://i.stack.imgur.com/R3K9H.jpg

1 个答案:

答案 0 :(得分:0)

您的HTML看起来不像有效的XML(请注意,<input>的结束标记已丢失),因此XPath无法正常工作。