当用户界面不断变化时,如何调整selenium中的测试脚本?
我们最近遇到了一个问题。我们的团队使用 selenium 进行了自动化测试脚本。现在我们在用户界面中收到了更改请求,因此我们修改了 css。
问题是自动化测试脚本不起作用。我们知道这是由于 CSS 更改造成的。
我的问题是:
有效处理这些情况的最佳方法是什么?
We recently ran in to a problem.Our team has automated test scripts with selenium. Now we got change request in User Interface, So we have modified the css.
The issue is automated test scripts are not working. we know this is due to css change.
My question is :
What is the best approach to handle those scenarios effectively?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是测试最大的不便......当某些东西发生变化时,你必须重写你的测试脚本。
您可以选择最适合您的元素本地化方式。但 xPath(以及 CSS 或任何其他类型的定位器)始终存在被更改的风险。事实上,您无法为所有可能性编写脚本。当应用程序发生任何更改时,您只需手动更改脚本即可。
这是你无法回避的事实。
It is the biggest inconvenience of testing... When something is changed, you have to rewrite your test script.
You can choose the best way of elements localisation for you. But there is always risk that xPath (and CSS or locators of any other type) will be changed. In fact, you can't write script for all possibilities. You just have to change manually your script when there are any changes in app.
This is a fact which you are not able to avoid.
有一些方法可以减少这种不便。一种非常流行的解决方案是使用页面对象模式。
这个想法是通过在中间插入一层来将测试逻辑与被测应用程序解耦。这样,如果应用程序发生更改,您不需要更改测试逻辑,只需更新受影响的页面对象。
为了简化此更新过程,使用可以生成页面对象类的工具(或创建您自己的工具)也是一个很好的做法。
There are ways to to reduce this inconvenience. One very popular solution is to use Page Object pattern.
The idea is to decouple test logic from application under test by inserting one layer in between. That way if application changes you don't need to change test logic, you just need to update affected Page Objects.
To simplify this update process, it is also a good practice to use a tool (or create your own) that can generate Page Object classes.