我有以下功能。它总是说文字不匹配。这是在测试完成之内。我在两个项目上都放了一块手表,两个都没有任何空白区域。我是新手,但想知道是否有任何明显的我做错了?
function VerifyComboBox(/*formcontrolname, value*/)
{
var formcontrolname = "CassetteTypeFilter";
var value = "Filter By Cassette Type";
try{
/*Boolean condition is declare either to execute code or not*/
if (formcontrolname && value !== null)
{
/*convert String to object */
var name = ConvertToObject(formcontrolname);
object=Sys.Browser("*").Page("*").FindChildByXPath("//*[@formcontrolname='" + name + "' and contains(., '" + value + "')]");
/*Waits until object appears*/
waitUntilObjectIsVisible("//*[@formcontrolname='" + name + "']");
/*scrolll to the invisble element*/
object.ScrollIntoView();
var visibleText = object.innerText.replace(/▼/g,'')
/*Boolean conditions to check the value of the element*/
if (visibleText == value) {
Log.Checkpoint("Text matches");
}
else {
Log.Error("Text does not match");
}
}
}
catch (e)
{
// Posts an exception message to the test log`enter code here`
Log["Error"]("EXCEPTION OCCURED: " + e["description"]);
}
}
答案 0 :(得分:0)
TestComplete为您提供aqString
以避免此类事情。使用aqString.Compare
来正确比较字符串。