2010-04-16 47 views
0

我想存储当前的URL(http://example.com)in一个变量,并用另一个字符串作为gotoIf命令gotoIf extension.js的(部分)的条件比较:当我运行这个seleniun IDESelenium IDE - 将URL字符串变量传递给条件语句“gotoIf”语句会引发语法错误?

storeLocation || url 
    gotoIf || ${url}=="http://example.com" || label 

引发此错误:

[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应该返回一个字符串那么为什么会出现这种错误,什么是错的语法以及如何我宣布这个命令

回答

1

错误消息显示:

eval("http://example.com==\"http://example.com\"")

您应该将表达可能更改为:

gotoIf || "${url}"=="http://example.com" || label

所以,你会得到一个有效的表达式:

eval("\"http://example.com\"==\"http://example.com\"")
1

叶氏..这工作得很好

gotoIf || "${x}"=="${y}" 
+1

如果你解释你的答案会更有帮助。 – JSuar 2012-12-18 03:09:33

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>