我想为以下选项卡构建Xpath

时间:2019-06-13 01:17:37

标签: selenium-webdriver xpath find

我要为Xpath设置出发日期下拉日期字段

https://www.southwest.com/air/booking/index.html?int=HOME-BOOKING-WIDGET-ADVANCED-AIR

我尝试了很多组合,但是没有用。

示例-

//input[@id='departureDate']/span[@class='swa-icon--icon']
//span[@class='swa-icon--icon']

<div class="flyout-trigger date-input"><div class="input input_icon input_left input_secondary"><input type="text" aria-label="Depart Date in mm/dd/yyyy format, valid dates from Jun 12 2019 to Jan 5 2020. To use a date picker press the down arrow." aria-owns="calendar-14" autocapitalize="none" autocomplete="off" autocorrect="off" id="departureDate" spellcheck="false" aria-required="true" class="input--text"><div class="input--icon-separator"><span class="swa-icon input--icon swa-icon_calendar" icon="swa-icon_calendar" size="18" role="presentation" style="font-size: 18px;"><span role="presentation" class="swa-icon--icon"></span></span></div></div></div>

\

2 个答案:

答案 0 :(得分:0)

这是您要查找的xpath。

 //span[normalize-space(.)='Return date']/following-sibling::div//span[@class='swa-icon--icon']

enter image description here

答案 1 :(得分:0)

最简单的方法是坚持aria-label attribute的值,您可以利用XPath contains() function以便根据上述aria-label的部分文本来定位元素残忍者,类似:

//input[contains(@aria-label,'Depart Date')]

演示:

enter image description here

更多信息: