2017-03-09 6 views
0

私はWebDriverを "Breaking Things"というテキストをクリックして、xpath/cssセレクターを使用しないようにしようとしています。ここではHTMLセレンのドライバー:クリックしてxpathのために働いていない

<div class="org-option" ng-repeat="Org in Organizations" aria-label="Select Breaking Things Organization" ng-click="Org.SelectOrg()" role="button" tabindex="0"> 
    <div class="data"> 
    <div class="data-relative"> 
     <!----> 
     <div class="image-wrapper" ng-show="Org.HasImage" ng-if="Org.HasImage" aria-hidden="false"> 
     <img class="onboard-logo" ng-src="/apiimage/organizations/f1544944fac34442998a05890c400338-0" src="/apiimage/organizations/f1544944fac34442998a05890c400338-0"> 
     </div> 
     <!----> 
     <div class="image-wrapper ng-hide" ng-show="!Org.HasImage" aria-hidden="true"> 
     <div class="image-placeholder"> 
      <div class="center-icon gicon-panorama"></div> 
     </div> 
     </div> 
     <div class="name-wrapper"> 
     <div>Breaking Things</div> 

は、ここで私はドライバでやっているものですされています

chromeDriver.findElement(By.xpath("//div[@class='name wrapper']//[text()='Breaking Things']")).click(); 

それは私が何をしないのです、クリックしたことはありませんが?私は暗黙の待ちなどを試みましたが、結果はありません。

答えて

0

あなた "すべてのノード" の正確なノード名divまたはワイルドカード指定する必要があります - この部分で*

//[text()='Breaking Things'] 

以下のように:

"//div[@class='name-wrapper']//div[text()='Breaking Things']" 

または

"//div[@class='name-wrapper']//*[text()='Breaking Things']" 
0

クラス名はname-wrapperです。 -は、あなたが実際にクラス、namewrapperWebElementを探すためにdriverを言っている@class='name wrapper'

chromeDriver.findElement(By.xpath("//div[@class='name-wrapper']//[text()='Breaking Things']")).click(); 

重要です。

+0

Oooを、そうだね、それは私が手動で入力するためのものだ。構文は正しいのですか?私はそれが無効な式のエラーをスローするといくつかの異なるタイプでそれを試してみました: – potatocode

関連する問題