我怎样才能获得文本框的位置

问题描述 投票:-2回答:1

我在硒的新尝试获得使用XPath文本框,但它不工作,因为它说找不到路径字符串。

这是我尝试:

[FindsBy(How = How.XPath,Using = ".//input[@index='0']")]
    public IWebElement SearchFlightFrom { get; set; }

这个HTML:

<div>
<div class="waypoint-container">
    <div class="float-left margin-right locationSelector" style="position: relative;z-index: 1">
        @Html.NgLabelFor(waypoint => waypoint.LocationLabel, new { @class = "block-display" })
        <input id="from{{$index}}" name="Location" index="{{$index}}" location-is-valid="locationIsValid" is-valid="locationIsValid" auto-complete-box get-validator-options="getLocations" on-selection="updateAutoCompleteSelection" get-auto-complete-options="locationSearch" class="airport-auto-complete waypoint-location-{{$index}}" ie-placeholder="true" ng-model="waypoint.Location" placeholder="Enter place or airport" required="" tabindex="{{getTabIndex($index,0)}}" type="text" ng-blur="onLocationChange($index)" ng-focus="onLocationFocus()"></input>
        <validation-message err-message="'Location is not valid'" is-show="locationIsValid!=null &&!locationIsValid && locationWasBlured" left="80px" top="24px" width="150px" flipped="'false'" />
    </div>
    <div class="float-left margin-right" ng-show="waypoint.ShowDate">
        @Html.NgLabelFor(waypoint => waypoint.DateLabel, new { @class = "block-display" })
        <input ng-keydown="onDatePickerWayPointBlur($event)" autocomplete="off" type="text" class="begin-trip-date date-input datepicker-padding" name="Date" data_index="{{$index}}" placeholder="ddMMMyy" ng-model="waypoint.Date" tabindex="{{getTabIndex($index,2)}}" ie_placehoder="true" ui-date="waypoint.datePickerOptions" ui-date-time-format="{{DateFormat.datepicker}}" ng-required="waypoint.ShowDate" />
    </div>
    <div class="float-left margin-right" ng-show="waypoint.ShowDate">
        <label>&nbsp;</label>
        <select ng-model="waypoint.SelectedDateType" ng-options="dateType as dateType.Text for dateType in waypoint.DateTypes"
                chosen="{width:'105px'}" disable-search="true" tabindex="100">
            <option value=""></option>
        </select>
    </div>

我想这个位置添加了一些文本

c# selenium xpath
1个回答
0
投票

试试这个XPath://input[@placeholder='Enter place or airport'] 然后先点击它使用click方法,然后你可以发送输入字段的值。

© www.soinside.com 2019 - 2024. All rights reserved.