如何使用 xpath 在 <br/> 之间提取文本标签 [英] How to use xpath for extracting text between <br/> tag

查看:63
本文介绍了如何使用 xpath 在 <br/> 之间提取文本标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下是我的应用程序中按钮的代码.

Following is the code of a button in my application.

<span class="ms-cui-ctl-largelabel" unselectable="on">
New
<br>
Map
</span>
</a>
</span>

我想点击那个按钮并使用 Selenium Webdriver.我尝试了多种组合,但对我不起作用.以下是我尝试过的不同 xpath

I want to click on that button and using Selenium Webdriver for it. I tried multiple combinations but it's not working for me. Following are the different xpaths which I tried

1. By.xpath("//span[contains(@class, 'ms-cui-ctl-largelabel') and text() = 'New/nMap']"));
2. By.xpath("//span[contains(@class, 'ms-cui-ctl-largelabel') and text() = 'New/r/nMap']")); 
3. By.xpath("//span[contains(@class, 'ms-cui-ctl-largelabel') and text() = 'New Map']"));

有人可以帮忙吗?

谢谢

推荐答案

Alternative solution using normalize-space()

Alternative solution using normalize-space()

//span[@class="ms-cui-ctl-largelabel" and normalize-space()="New Map"]

这篇关于如何使用 xpath 在 &lt;br/&gt; 之间提取文本标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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