Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/70.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html Selenium:测试元素是否包含一些文本_Html_Selenium_Selenium Ide - Fatal编程技术网

Html Selenium:测试元素是否包含一些文本

Html Selenium:测试元素是否包含一些文本,html,selenium,selenium-ide,Html,Selenium,Selenium Ide,使用Selenium IDE,如何测试元素的内部文本是否包含特定字符串?例如: <p id="fred">abcde</p> 'id=fred' contains "bcd" = true) abcde “id=fred”包含“bcd”=true) 如果可以的话,您能使用jQuery吗 $("p#fred:contains('bcd')").css("text-decoration", "underline"); 正则表达式似乎可以工作: "The simplest

使用Selenium IDE,如何测试元素的内部文本是否包含特定字符串?例如:

<p id="fred">abcde</p>
'id=fred' contains "bcd" = true)

abcde

“id=fred”包含“bcd”=true)
如果可以的话,您能使用jQuery吗

$("p#fred:contains('bcd')").css("text-decoration", "underline");

正则表达式似乎可以工作:

"The simplest character set is a character. The regular expression "the" contains three
character sets: "t," "h" and "e". It will match any line with the string "the" inside it.
This would also match the word "other". "
(来自网站:)

如果您使用的是visual studio,则可以使用各种正则表达式(不只是包含)计算字符串:

我发布的表达式将检查字符串是否只包含字母

根据我的链接,正则表达式将是“bcd”或运行时构造的字符串。或:

Regex.IsMatch("YourInnerText", @"bcd");
(反正是这样的)


希望对您有所帮助。

您可以使用命令
assertTextPresent
verifyText
只需一个简单的通配符即可:

verifyText
id="fred"
*bcd*
请参见

在这种情况下,此选项非常有用

您正在查找的命令是
assertText
,定位器是
id=fred
,例如
*bcd*
,您还可以使用:

assertElementPresent
css=p#fred:contains('bcd')

使用selenium IDE如何实现这一点?是的,但我试图获得部分匹配,而不是完全匹配。而且不仅仅是这个命令可以使用。就在同一时刻,是的。慢了不到一分钟。Heheeven虽然我比你稍早就知道了,但我会给你答案。@Slanec有什么东西,我可以搜索文本并点击它吗?文档的关键部分在下面,其中谈到了通配符。谢谢,这就是我需要的:
css=p:contains('foo')
。然而,有人告诉我,它已经被弃用了。
assertElementPresent
css=p#fred:contains('bcd')