2016-07-12 5 views
0

"はい"をテキストとして次の(兄弟)要素を取得する必要があります。テキスト「はい」、css、およびIDの一部を使用できますが、数字(例:106)は残念ながら除外されています。また、その排除のために、私は直接その兄弟を得ることができません。ここではHTMLコードの一部です:次の要素を取得する

<a style="right: auto;" class="x-btn x-box-item x-toolbar-item" id="button-106"> 
    <span id="button-106-btnWrap" role="presentation" class="x-btn-wrap" unselectable="on"> 
    <span id="button-106-btnEl" class="x-btn-button" role="presentation"> 
     <span id="button-106-btnInnerEl" class="x-btn-inner x-btn-inner-center">Yes 
     </span> 
     <span role="presentation" id="button-106-btnIconEl" class="x-btn-icon-el"> 
     </span> 
    </span> 
    </span> 
</a> 

私はこのクエリを思い付いたが、動作していないよう:

By.XPath(".//*[text() = 'Yes' and contains(id(), '-btnInnerEl')/following-sibling::*]") 

私が得ることができるので、どのように私はこのクエリを変更することができます次の要素? ID button-106-btnIconElとのスパンを選択するには

答えて

2

:ここ

//span[contains(@id,'-btnInnerEl')][normalize-space(text())='Yes']/following-sibling::span 
+0

キーは、コンテンツが「はい」のホワイトスペースの束が続いているということです。 "FirePath"はあなたの友人で、この種のものを追跡しています! –

関連する問題