本文介绍了量角器 - 如何通过自定义(非 HTML)标签定位元素?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近我使用量角器来自动化使用 HTML 5、angular 2、java-script 开发的应用程序.我能够毫无问题地自动化它.但是最近开发人员将控件更改为 DevExtreme HTML JS.之后标签被更改(例如 dx-text boxdx-tool-tip 非 HTML).所以我现在无法使用量角器进行自动化.我已经尝试了所有可能的组合,但它不起作用.那么任何人都可以帮助我,量角器是否支持 DevExtreme 控件或者是否有任何替代方法?

Recently I was using protractor to automate the Application developed using HTML 5 , angular 2 , java-script. I was able to automate it without any issues. But recently developers have changed the controls to DevExtreme HTML JS. After that the tags are changed (For example dx-text box , dx-tool-tip which are non HTML). So I am not able to automate now using protractor. I have tried all the possible combinations but it is not working.So can anyone please help me out, whether protractor supports DevExtreme controls or is there is any alternative for that?

以下是新代码的 HTML :-

Below is the HTML for the new code :-

HTML 代码

以前我用 id = inputUserName 定位它,它工作正常,但现在它抛出错误.我已经尝试了所有可能的方法来找到它,但没有运气.谁能告诉我之前是否有人使用过量角器来自动化使用 DevExtreme HTML JS 控件的应用程序?

Previously I was locating it with the id = inputUserName it was working fine but now it is throwing error. I have tried all the possible ways to locate it but no luck.Can anyone please let me know whether anyone has used protractor before to automate the application that is using DevExtreme HTML JS controls ?

推荐答案

从技术上讲,它仍然是 HTML.您的问题是您使用的 id 不再附加到输入元素.您现在可以使用 element(by.css('#inputUserName input.dx-texteditor-input')); 注释中的 xpath 解决方案可能有效,但如果密码字段也具有相同的类,您将有多个元素,包括来自父元素的 id 为您提供一些安全性.

Technically it is still HTML. Your issue is the id you were using is no longer attached to the input element. You can now use element(by.css('#inputUserName input.dx-texteditor-input')); The xpath solution in the comment might work but if the password field also has the same class you will have multiple elements including the id from the parent element gives you some security.

这篇关于量角器 - 如何通过自定义(非 HTML)标签定位元素?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-30 08:32