gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-02 20:40:00 26 4
gpt4 key购买 nike

我正在尝试存储当前 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/

26 4 0
文章推荐: php - 通过 getJSON 检索的图像的
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com