从webtable selenium webdriver中提取文本 [英] Extracting text from webtable selenium webdriver

查看:363
本文介绍了从webtable selenium webdriver中提取文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

HTML:

<tr valign="top"> 
<td> 
  <p align="left"><font face="Arial, Helvetica, sans-serif" size="2"><b><font face="Arial, Helvetica, sans-serif" size="2"><img src="/images/printit.gif" width="57" height="69" align="right"></font><font size="+1">Your 
    itinerary has been booked!</font></b><br>

    <br>
    Please print a copy of this screen for your records. Thank you for choosing 
    Mercury Tours.<br>
    <br>
    </font></p>
</td>
</tr>

我正在尝试检索文本您的行程已被预订!请打印此屏幕的副本以供记录。感谢您选择Mercury Tours。

I am trying to retrieve the text Your itinerary has been booked! and Please print a copy of this screen for your records. Thank you for choosing Mercury Tours.

我尝试使用tagName和xpath来提取文本并对其进行排序。但是有一些独特的定位器在这里可以使用吗?

I tried with using tagName and xpath to extract the texts and sort it.But is there some unique locator here that could be used here?

推荐答案

根据提供的表行HTML,我不确定什么是唯一的定位器。可能是,在下面提供的 cssSelector 在这里是唯一的以提取文本: -

According to provided HTML of table row, I'm not sure what could be unique locator. May be, below provided cssSelector would be unique here to extract the text :-

tr[valign = 'top'] > td > p[align = 'left']

您可以使用以上 cssSelector ,如果它不是唯一的,您需要分享有关表HTML的更多详细信息。所以我可以为你提供唯一的定位器。

You can use above cssSelector , if it is not unique you need to share more details about table HTML. So I could provide you unique locator.

或者如果你想用文本找到这个元素,你可以使用 xpath 这将是唯一的: -

Or if you want to locate this element with text, you can use below xpath which would be unique :-

.//td[contains(.,'itinerary has been booked')]

这篇关于从webtable selenium webdriver中提取文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆