如何在Selenium中使用EXTJS生成的ext-gen ID? [英] How to use ext-gen ID generated by EXTJS in Selenium?
问题描述
在测试自动化Web应用程序时,我得到了动态生成的外部ID.我尝试使用xpath,但是测试用例失败.我浏览了不同的网站,但没有发现任何运气.有人可以帮我吗?
While test automating a web application, I get dynamically generated ext-gen IDs. I tried using xpath but the test cases are failing. I went through different websites but did not find any luck. Can somebody help me?
谢谢你,斯里尼瓦斯·玛蒂
Thank you, Srinivas Marthi
推荐答案
对于自动测试,最好完全避免使用ExtJS自动生成的ID.您可以将自己的静态ID分配给组件,但是现在基本上是用全局变量来填充代码,这也不是一件好事.使用一些ID可能会有所帮助,但是您不想为每个小按钮分配一个ID.
For automated testing, the auto-generated ID-s of ExtJS are best avoided altogether. You can assign your own static ID-s to components, but now you are basically littering your code with global variables, not good either. Using some ID-s might be a helpful compromise, but you don't want to assign an ID to every single little button.
对于ExtJS 4,我建议使用 ComponentQuery :
For ExtJS 4 I suggest using the ComponentQuery:
Ext.ComponentQuery.query("panel[title='Orders'] button[text='Save']")
这篇关于如何在Selenium中使用EXTJS生成的ext-gen ID?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!