在 Selenium IDE 中,如何获取基本 url 的值 [英] In Selenium IDE, how to get the value of the base url

查看:19
本文介绍了在 Selenium IDE 中,如何获取基本 url 的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以从 Selenium 脚本(Selenium IDE 中的纯 HTML 保存脚本)中检索 base url 的值?

Is it possible to retrieve the value of the base url from inside a Selenium script (a plain HTML-saved script from Selenium IDE)?

我正在尝试使用 assertLocation 验证当前 url.但是 assertLocation 返回的是 absolute url.我想将当前 url 与 relative url 进行比较,而不必在 url 的开头使用 *.

What I'm trying to do is verify the current url using assertLocation. But assertLocation returns the absolute url. I would like to compare the current url to a relative url without having to use an * at the start of the url.

我想访问基本字符串,因为我希望能够在不同的站点(各种开发站点 + 生产站点)上运行测试,但是如果我使用 * 我无法检查根页面(*/ 对于以 /...结尾的每个页面都是正确的)

I'd like to have access to the base string because I want to be able to run the tests on different sites (various dev sites + production site), but if I use the * I can not check for the root page (*/ would be true for each page that ends with a /...)

这是我目前所做的:

|断言位置 |*/一些页面 ||

|assertLocation | */some-page | |

这是我想做的:

|断言位置 |基本网址 +/一些页面" ||

|assertLocation | baseURL + "/some-page" | |

注意:是否有可能:

  1. 在目标中使用变量;
  2. 连接一个变量和一个字符串?

推荐答案

试试这个

storeEval|window.document.domain|host
assertLocation|http://${host}/some-page|

这篇关于在 Selenium IDE 中,如何获取基本 url 的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆