![](/img/trans.png)
[英]Get text from XPath located Element using Selenium WebDriver with JavaScript
[英]select text of element using xpath with selenium
我有這樣的結構:
<div class="content">
<h3 class="faq">Joocey</h3>
Locked Bag 4005
<br>
6/78 William Street
<br>
Sydney NSW 2000
<br> Customer Care: <a href="tel:1300886534">1300886534</a><br>
or<br> help@joocey.com.au<br> <br>
<div class="greenbar">
<a href="/Stores">See All Stores <i class="icon-chevron-right icon-white pull-right"> </i</a>
</div>
<!--greenbar-->
<!--main_footer-->
</div>
如何在div[@class="content"]
選擇每個文本行?
例如,我要選擇:“ Joocey”,“ Locked Bag 4005”,“ 6/78 William Street”,“ SydneyNSW 2000”,“ Customer Care:”,“ 1300886534”。
我嘗試使用"//div[@class='content'][text()[2]]"
選擇“ Locked Bag 4005”,但它始終選擇所有文本。 任何幫助都會很棒。
通過DOM選擇器之一選擇文本時,沒有“線”的概念。
您將必須獲取div[@class="content"]
所有文本,然后將其作為字符串進行處理。 將其分解為換行符,然后訪問結果數組。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.