次の2 div
要素のテキスト内容を取得しようとしています。私は相対XPathを使用してテキストを取得しようとしています深みのあるdivタグ内のテキストをSeleniumで取得する方法
45 Se Selenium
が、それは常に失敗します。
はelement = driver.findElement(By.xpath(".//*[@id='page-wrapper']/section/section/div/div[2]/section/div/div/div/div[45]"));
data = element.getText();
System.out.println(data);
私が取得しようとしていますテキストがある:それは絶対パスを使用して動作します。
私はこの組み合わせの使用をしようとしています:
element = driver.findElement(By.xpath("//div[contains(@class,'elemBox noclaim noclaim-tt') and contains(text(),'45')]"));
または
element = driver.findElement(By.xpath("//div[contains(@class,'elemBox noclaim noclaim-tt')]/div[contains(text(),'45')]"));
が、それでも失敗しました。
私はこのようなHTMLコードを持っている:
<div class="elemBox noclaim noclaim-tt text-right m-t-lg animated-add pulse-add animated pulse animated-add-active pulse-add-active" >
<div class="" ng-show="(filterTool(elementName.name)) || (name === '')">
<div class="text-right ng-binding">45</div>
<div class="text-left ng-binding">
<span class="elemSym ng-binding">Se</span>
<br/>
Selenium
</div>
</div>
私は何をすべきか?
私は// div [contains(@ class、 'elemBox noclaim noclaim-tt')を含み、(。、 '45')] を含んでいます。どうもありがとうございました :) – Mala