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

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

问题描述

是否可以从Selenium脚本(Selenium IDE中的一个普通HTML保存的脚本)中检索基本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 验证当前网址.但是 assertLocation 返回绝对网址.我想将当前URL与相对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 /...)

这是我目前正在做的事情:

This is what I currently do:

| assertLocation |*/某页||

|assertLocation | */some-page | |

这就是我想要做的:

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

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

注意:甚至可以:

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

推荐答案

尝试一下

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

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

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