2012-03-29 70 views

回答

22

Selenium-IDE documentation是在这种情况下有所帮助。

您正在查找的命令是assertText,定位器将是id=fred,文本例如*bcd*

+1

即使我稍微明白了你的意思,我会给你答案的。 – 2012-03-29 12:01:34

+0

@Slanec是否有任何东西,我可以搜索文本并点击它? – 2015-05-08 09:59:11

+0

文档的关键点在[匹配文本模式](http://docs.seleniumhq.org/docs/02_selenium_ide.jsp#matching-text-patterns)中进一步讨论了通配符。 – icc97 2016-03-07 09:05:06

1

您能够使用jQuery,如果因此要尽量喜欢的东西

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

怎么会变成这样有可能与硒IDE? – 2012-03-29 09:00:00

+0

有一个阅读这应该帮助。 http://www.vcskicks.com/selenium-jquery.php – 2012-03-29 09:05:45

1

似乎正则表达式可能的工作:

"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". " 

(从网站:http://www.grymoire.com/Unix/Regular.html

如果您正在使用visual studio,则可以使用regula评估字符串r表达式(不仅仅包含):

using System.Text.RegularExpressions; 

Regex.IsMatch("YourInnerText", @"^[a-zA-Z]+$"); 

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

然后,您的正则表达式将根据我的链接是“bcd”或您在运行时构建的某个字符串。或者:

Regex.IsMatch("YourInnerText", @"bcd"); 

(像反正东西)

希望它帮助。

0

您可以使用命令assertTextPresentverifyText

+0

是的,但我试图得到一个部分匹配,而不是满的。此外,这不仅仅是可以使用的命令。 – 2012-03-29 09:35:50

4

它可以用一个简单的通配符来实现:

verifyText 
id="fred" 
*bcd* 

selenium IDE Doc

+1

哦。就在同一时刻。 – 2012-03-29 09:35:54

+1

是的。不到一分钟太慢了。嘿嘿 – 2012-03-29 10:30:25

3

您还可以使用:

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

谢谢,这就是我所需要的:'css = p:contains('foo')'。不过,我被告知它已被弃用。 – LarsH 2012-09-13 20:49:55

相关问题