2015-10-05 20 views
0
<div> 
<div class="dates"> 

所以,要找到上面的日期類,我使用$x("//div[@class= 'dates']//")但控制檯說這個表達式是非法表達。找不到合適的xpath目錄。需要一些建議

<div class="bx-wrapper" style="max-width: 870px; margin: 0px auto;"> 
<div class="bx-viewport" style="width: 100%; overflow: hidden; position: relative; height: 0px;"> 
<div class="bx-wrapper" style="max-width: 870px; margin: 0px auto;"> 
<div class="bx-viewport" style="width: 100%; overflow: hidden; position: relative; height: 91px;"> 
<ul id="DateList" class="bxslider clearfix" data-bx-slider="mode: 'horizontal', pager: false, controls: false, minSlides: 1, maxSlides:4, slideWidth: 290, slideMargin:0, hideControlOnEnd:true, infiniteLoop: false, moveSlides: 1" style="width: 515%; position: relative; transition-duration: 0s; transform: translate3d(0px, 0px, 0px);"> 

要找到正確的XPath上面的節點,我使用$ x( 「// UL [@ ID = 'DateList'] //」),並且仍然收到了消息表達式是非法的。

<li class="date-block slide ng-scope" data-notify-when-repeat-finished="" ng-repeat="dates in cruiseFinder.filters.sailDates" style="float: left; list-style: outside none none; position: relative; width: 290px;"> 
<h5 class="ng-binding">2015</h5> 
<ul id="months" class="months"> 

回答

0

在這兩種情況下,最後的雙斜線實在是太多了:正確的XPath是:

  • //div[@class= 'dates']
  • //ul[@id= 'DateList']

雙指「,在削減到一個XPath表達式文件的任何地方「。

+0

如果我想繼續構建更深的xpath,可以使用雙斜槓嗎? – GordonFreaman

+0

corse,但作爲簡單的斜線,雙斜線必須是_prior_到其他xpath選擇器:一個節點選擇器,一個屬性選擇器......因此,它不能位於xpath的末尾。 –