我正在尝试使用 Selenium (2.32) 方法“isTextPresent”在某个站点上搜索字符串。我为了有效地做到这一点,我需要按照 regexpi 的建议搜索它不区分大小写,但我收到如下错误(HTML 包含字符串“你说什么”):
宣言:
private Selenium selenium;
driver = new FirefoxDriver();
String baseUrl = "http://openurl.ebscohost.com";
selenium = new WebDriverBackedSelenium(driver, baseUrl);
选项 1(“'SAY' 大写”):
if(selenium.isTextPresent("WHAT YOU SAY")) {
return ("PASS");
}
else{ return "FAIL";}
输出:“通过”
选项 2(“'SAy' 小写字母”):
if(selenium.isTextPresent("WHAT YOU SAy")) {
return ("PASS");
}
else{ return "FAIL";}
输出:“失败”
选项 3(“'SAy' 使用小写字母但使用正则表达式”):
if(selenium.isTextPresent("regexp:WHAT YOU SAy")) {
return ("PASS");
}
else{ return "FAIL";}
输出:“失败”
选项 4(“‘说’小写字母但正则表达式”):
if(selenium.isTextPresent("regexpi:WHAT YOU SAy")) {
return ("PASS");
}
else{ return "FAIL";}
输出:错误
错误:
> ERROR:com.thoughtworks.selenium.SeleniumException: TypeError: RegExp(...).text is not a function
Command duration or timeout: 1.97 seconds
Build info: version: '2.32.0', revision: '6c40c18', time: '2013-04-09 17:23:22'
System info: os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.6.0_32'
Session ID: 195d399d-c745-42c5-be6d-7d47811c9c26
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities [{platform=XP, acceptSslCerts=true, javascriptEnabled=true, browserName=firefox, rotatable=false, locationContextEnabled=true, version=20.0.1, cssSelectorsEnabled=true, databaseEnabled=true, handlesAlerts=true, browserConnectionEnabled=true, nativeEvents=true, webStorageEnabled=true, applicationCacheEnabled=true, takesScreenshot=true}]
我错过了什么吗?
谢谢我提前!