2010-04-16 48 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>