Selenium IDE - 将 URL 字符串变量传递到条件“gotoIf”中语句抛出语法错误?

发布于 2024-08-29 07:47:31 字数 1336 浏览 2 评论 0原文

我正在尝试将当前网址 (http://example.com) 存储在 变量中并将其与另一个字符串作为 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 应返回一个字符串 那么为什么我会收到此错误,语法有什么问题以及如何解决我要声明这个命令吗?

I am trying to store the current url (http://example.com)in a variable and compare it with another string as a condition in the gotoIf command (part of the gotoIf extension.js):

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

When I run this seleniun ide throws this error:

[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 should return a String so why am i getting this error, what is wrong with the syntax and how do I declare this command?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

孤独患者 2024-09-05 07:47:31

错误消息显示:

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

您应该将表达式更改为:

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

这样您将获得有效的表达式:

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

The error message shows:

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

You should probably change your expression to:

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

So that you'll get a valid expression:

eval("\"http://example.com\"==\"http://example.com\"")
乙白 2024-09-05 07:47:31

是的..这很好用

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

yeap.. this works fine

gotoIf || "${x}"=="${y}"
疏忽 2024-09-05 07:47:31
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>
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>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文