在 HTTP 和 HTTPS 中运行自动化 Selenium 测试的良好模式?
我有一组通过 HTTP 运行的 Selenium 测试 - 我想在 HTTPS 和 HTTP 下运行相同的测试,并尽可能减少重复。 我想其他人一定已经这样做了? 我使用 Java Selenium Remote Control - 但我可能可以翻译另一种语言的方法。
I have a set of Selenium tests which run via HTTP - I'd like to run the same tests under HTTPS aswell as HTTP with as little duplication as possible. I guess other people must already be doing this? I use the Java Selenium Remote Control - but I can probably translate a method from another language.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以将被测应用程序的 URL 作为参数传递给测试框架,或将其存储在属性文件中。 我这样做是为了在测试环境之间切换。
下面是一个从属性文件读取的简单示例:
以及使用参数的示例(我使用 TestNG 来实现此目的):
在 TestNG 套件 XML 文件中添加参数:
创建 Selenium 实例时使用该参数:
You could pass the URL of the application under test to your test framework as a parameter, or store it in a properties file. I do this to switch between test environments.
Below is a simple example of reading from a properties file:
And an example of using a parameter (I use TestNG for this):
Add parameters in the TestNG suite XML file:
Use the parameter when you create a Selenium instance: