我们可以将按钮的工具提示用作selenium WebDriver 中的定位器吗?我遇到这个问题是因为 selenium webdriver 中提供的默认定位器都对我的应用程序元素没有用。
我正在测试的应用程序中的元素随机改变了它, 身份证, Xpath-位置, Xpath 相对 Id,和 CSS 每次页面刷新!发生这种情况是因为应用程序是在 ExtJs 和 HTML 5 中创建的。
最佳答案
是的,你可以。但请出示您的 HTML 代码。没有通用的答案。
例如,这里的 ExtJS 演示。 http://try.sencha.com/extjs/4.1.1/demos/Ext.Button.tooltip.1/
<button id="button-1009-btnEl" type="button" class="x-btn-center" hidefocus="true" role="button" autocomplete="off" data-qtip="I'm a custom tooltip" style="height: 16px;">
<span id="button-1009-btnInnerEl" class="x-btn-inner" style="">Button w/ QuickTip (qtip) tooltip</span>
<span id="button-1009-btnIconEl" class="x-btn-icon "></span>
</button>
工具提示被编码为data-qtip
属性。所以你可以使用 CSS Selector 或 XPath 来找到它。
XPath: //button[@data-qtip=\"我是自定义工具提示\"]
CSS: button[data-qtip=\"I'm a custom tooltip\"]
关于extjs - 在 Selenium Webdriver 中使用 Element 的工具提示作为定位器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19834674/