使用Selenium 2在页面上查找文本 [英] Finding text on page with Selenium 2
本文介绍了使用Selenium 2在页面上查找文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何检查给定的文本字符串是否存在于使用Selenium的当前页面上?
代码是这样的:
def elem = driver.findElement(By.xpath(// * [contains(。,'search_text')] ));
if(elem == null)println(在页面上找不到文本!);
How can I check whether a given text string is present on the current page using Selenium?
解决方案
The code is this:
def elem = driver.findElement(By.xpath("//*[contains(.,'search_text')]"));
if (elem == null) println("The text is not found on the page!");
这篇关于使用Selenium 2在页面上查找文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文