javascript - Selenium IDE - 将 URL 字符串变量传递到条件 'gotoIf' 语句会引发语法错误?

标签 javascript selenium core selenium-ide

我正在尝试存储当前 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 应该返回一个字符串,那么为什么我会收到此错误,语法有什么问题以及如何声明此命令?

最佳答案

错误消息显示:

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

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

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

这样你就会得到一个有效的表达式:

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

关于javascript - Selenium IDE - 将 URL 字符串变量传递到条件 'gotoIf' 语句会引发语法错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2653815/

相关文章:

android - java.net.SocketException : recvfrom failed: ECONNRESET (Connection reset by peer) 异常

javascript - 从 Quora - Python 中使用 Selenium 提取 "(more)"文本

java - 无法通过使用 selenium 和 Java 来单击动态更改的 div

multithreading - 我如何知道/查看线程在哪个内核上运行? (在Win XP中)

Grails 内部 : Auto mapping and Domain object creation

python - 网页包含在一个动态页面中,无法使用与 Selenium (Python) 的驱动程序交互

Javascript - 收到警报消息后停止继续

javascript - Nodejs for 循环并等待循环完成

javascript - 使用 jquery 创建 Html 元素

javascript - $( ) 是 JavaScript 还是 jQuery 表示法?