使用Selenium IDE解析查询字符串值的URL [英] Parsing URL for querystring values with Selenium IDE

查看:116
本文介绍了使用Selenium IDE解析查询字符串值的URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是集成测试的新手,但是到目前为止,使用Se:IDE建立了一套测试套件,并取得了巨大的成功.在进行测试时,我发现自己正在生成大量数据,我想自己清理一下.

I'm new to integration testing, but have had great success so far buiding up a suite of tests using Se:IDE. As I've been running my tests, it has occurred to me that I'm generating a substantial amount of data and I'd like to clean up after myself.

我的大多数测试都涉及创建一个新的页面",并且id在查询字符串中可用.我想让Se:IDE存储一个查询字符串值,并将其传递到另一个页面,该页面在运行验证后会调用delete方法进行整理.

Most of my tests involve creating a new 'page', and the id is available in the querystring. I'd like to have Se:IDE store a querystring value and pass it to another page that calls a delete method to tidy up after I have run my verifications.

我看到我可以使用命令storeLocation,但是我不确定如何解析查询字符串中id的值,然后使用Open将其传递到另一个页面.

I see that I can use the command storeLocation, but I'm not sure how I would go about parsing that value for the id in the querystring, and then pass it to another page using Open.

我是否已经到达需要将测试迁移到c#的地步,或者可以使用IDE做到这一点?

Have I reached the point where I need to migrate my tests to c#, or is this possible using the IDE?

推荐答案

如果将所有测试用例都放在同一个测试套件中.他们可以在执行之间共享变量而不会出现问题. 因此,您要做的就是存储所需的值:

If you keep all your test cases inside the same test suite. They can share variables between executions without problems. So, all you have to do is to store the desired value:

storeLocation | variable | |

,在以后的测试中,您必须使用以下变量:

and in a future test, you have to use the variable as the following:

open | ${variable} | |

注意:有关测试套件的更多信息,请查看: http://seleniumhq.org/docs/03_selenium_ide.html#writing-测试套件

Note: for more info on test suites, take a look at: http://seleniumhq.org/docs/03_selenium_ide.html#writing-a-test-suite

更新:

您现在可以使用javascript正则表达式从变量中获取子字符串:

You can now use javascript regular expressions to get a substring from a variable:

storeEval | reg = /substring pattern/;reg.exec(${variable}) | substring
open | ${substring} | |

示例:

store | "012la4la" | a
storeEval | re = /[0-3]*la/;re.exec(${a}) | new
echo | ${new} | 

输出:

[info] echo: 012la 

这篇关于使用Selenium IDE解析查询字符串值的URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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