2012-03-29 135 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

相關問題