我正在尝试将当前url(http://example.com)in存储为变量并将其与另一个字符串进行比较,作为gotoIf命令中的条件(gotoIf extension.js的一部分):
storeLocation || url
gotoIf || ${url}=="http://example.com" || label
当我运行此seleniun ide时会抛出此错误:
[error] Unexpected Exception: message -> syntax error, fileName -> chrome://selenium-ide/content/tools.js -> file:///C:/Users/David%20Cunningham/Desktop/extensions_js/extensions.js, lineNumber -> 183, stack -> eval("http://example.com==\"http://example.com\"")@:0 ("http://example.com==\"http://example.com\"","label1")@chrome://selenium-ide/content/tools.js -> file:///C:/Users/David%20Cunningham/Desktop/extensions_js/extensions.js:183 ("http://example.com==\"http://example.com\"","label1")@chrome://selenium-ide/content/selenium/scripts/htmlutils.js:60 ([object Object],[object Object])@chrome://selenium-ide/content/selenium/scripts/selenium-commandhandlers.js:310 ()@chrome://selenium-ide/content/selenium/scripts/selenium-executionloop.js:112 (6)@chrome://selenium-ide/content/selenium/scripts/selenium-executionloop.js:78 (6)@chrome://selenium-ide/content/selenium/scripts/htmlutils.js:60 , name -> SyntaxError
storeLocation应该返回一个String,那么为什么我会收到此错误,语法有什么问题以及如何声明此命令?
答案 0 :(得分:1)
错误消息显示:
eval("http://example.com==\"http://example.com\"")
您应该将表达式更改为:
gotoIf || "${url}"=="http://example.com" || label
这样你就会得到一个有效的表达式:
eval("\"http://example.com\"==\"http://example.com\"")
答案 1 :(得分:1)
是的..这很好用
gotoIf || "${x}"=="${y}"
答案 2 :(得分:0)
try out this one
<tr>
<td>storeLocation</td>
<td>j</td>
<td></td>
</tr>
<tr>
<td>echo</td>
<td>${j}</td>
<td></td>
</tr>
<tr>
<td>store</td>
<td>http://www.google.com</td>
<td>i</td>
</tr>
<tr>
<td>echo</td>
<td>${i}</td>
<td></td>
</tr>
<tr>
<td>gotoIf</td>
<td>storedVars['i']==storedVars['j']</td>
<td>label</td>
</tr>