如果URL包含-TestCafe,如何执行操作

forever 测试交流1 102字数 251阅读模式
摘要我希望添加一些操作,仅当页面URL为给定URL时。我正在使用TestCafe Studio。因此,我添加了一个带有以下内容的“自定义脚本”块。但这是一个包含。。。

我希望添加一些操作,仅当页面URL为给定URL时。我正在使用TestCafe Studio。因此,我添加了一个带有以下内容的“自定义脚本”块。但这是一个错误,它包含的不是一个函数。

const getURL = ClientFunction(() => window.location.href.toString());
const myurl = await getURL;
if(myurl.contains('/update')){
await t.click('#updateInfoSubmit');
}

软件测试测试分享功能文章源自玩技e族-https://www.playezu.com/202910.html 文章源自玩技e族-https://www.playezu.com/202910.html

玩技站长微信
添加好友自动发送入群邀请
weinxin
rainbow-shownow
玩技官方公众号
官方微信公众号
weinxin
PLAYEZU
 
  • 版权提示:本站仅供存储任何法律责任由作者承担▷诈骗举报◁▷新闻不符◁▷我要投稿◁
    风险通知:非原创文章均为网络投稿真实性无法判断,侵权联系2523030730
    免责声明:内容来自用户上传发布或新闻客户端自媒体,切勿!切勿!切勿!添加联系方式以免受骗。
  • 原创转载:https://www.playezu.com/202910.html
    转载说明: 点我前往阅读>>>
    • Jakez
      Jakez 9

      第一件事是你首先需要的 客户端函数 要使用的模块 客户端函数 method. Then your test should looks more or less like this /. Also remember to use await when getting the url
      import { Selector, t, 客户端函数 } from ‘testcafe’;

      fixture `RandomPage`
      .page("om/questions/73225773/how-to-do-an-action-if-the-url-contains-testcafe")

      // Function that Returns the URL of the current web page
      const getPageUrl = 客户端函数(() => window.location.href);

      test(‘Test if url has parmeter’, async t => {
      await t
      .click(Selector("a").withExactText("automated-tests"))

      // Use await to get page url
      var pageUrl = await getPageUrl();
      // Check if url has string
      if(pageUrl.includes(‘tagged’)){
      console.log("url contains string – tagged")
      // await t.click(Selector("a"))
      }
      });

    匿名

    发表评论

    匿名网友
    确定