简体   繁体   English

如何通过使用xpath检查div元素内的文本

[英]how to check the text inside div element by using xpath

I am completely new to java and I want to check if the text inside div element equals to a specific value by giving the xpath. 我是java的新手,我想通过给xpath检查div元素内的文本是否等于特定值。 For example if the text equals to "value 1" the test passes other wise it shows a message. 例如,如果文本等于“值1”,则测试以其他方式通过,它将显示一条消息。 I am not sure how to use assertEquals with xpath. 我不确定如何在xpath中使用assertEquals。 can you give me some hints? 你能给我一些提示吗?

<div id="indicator">value 1 </div>

thanks 谢谢

Are you using javascript or jsp? 您使用的是javascript还是jsp?

Any Case is easy, this will return your value: 任何情况都很简单,这将返回您的价值:

$("#MyId").val();

In your case it would be: 您的情况是:

$("#indicator").val(); 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM