[Protractor] Locators and Suites in Protractor
in and
2023-09-14 09:00:54 时间
HTML:
<ul class="list"> <li ng-repeat="item in itmes" ng-click="selectItem(item)" ng-class="{selected: item.isSelected}">{{ item.name }}</li> </ul>
// Get by binding expect(element.all(by.binding('item.name')).first().getText()).toBe('Ben'); // Get by tagName expect(element(by.css('.list')).all(by.tagName('li')).get(2).getText()).toBe('Sophi'); // Get by repeater expect(element(by.repeater('item in items').row(4).column('{{ item.name }}')).getText()).toBe('Herny');
Notice, when you use repeater, '{{ item.name }}' should be prefect match with what you have in html. Speace between {} also matters.
var listItems = element(by.css('.list')).all(by.tagName('li')); var ben = listItems.first(); var sophi = listItems.get(2); sophi.cliick(); expect(sophi.getAttribute('class')).toMatch('selected'); expect(ben.getAttribute('class')).not.toMatch('selected');
--------------------------
In conf.js:
var config = { suites: { basics: './e2etest/index.spec.js', locators: './e2etest/locators.spec.js' } };
What we write into the suites is what we gonne run in the test, if we want to skip 'basics' tests, we can do in scripts:
protractor conf.js --chrome --suite=locators
相关文章
- 解决jar包乱码 in 创新实训 智能自然语言交流系统
- Apache2.4.6添加虚拟主机提示:NameVirtualHost has no effect and will be removed in the next release /usr/local/apache/conf/extra/httpd-vhosts.conf
- 出现net.sf.json.JSONException: There is a cycle in the hierarchy异常的解决办法
- Flex and Bison in vscode
- [Javascirpt] What’s new in JavaScript (Google I/O ’19)
- [Tools] Unlock TypeScript's Features in Vanilla JS with @ts-check and JSDoc
- [Bash] Chain Commands with Pipes and Redirect Output in Bash
- [Typescript Kaop-ts] Use AOP in Vue Components with TypeScript and Kaop-ts
- [Nuxt] Add Arrays of Data to the Vuex Store and Display Them in Vue.js Templates
- Compare assert exception in should(JavaScript) and unittest(Python)
- coroutine in Python Tornado and NodeJs
- 解决python多版本环境下pip报错Fatal error in launcher: Unable to create process using问题
- Service Request Account field in CRM and C4C
- OData Console in C4C and Gateway Client in CRM Fiori
- cannot delete activity in SAP CRM WebClient UI
- Tomcat Instance in Eclipse and in local folder
- 【Codeforces Round #421 (Div. 2) B】Mister B and Angle in Polygon
- ML之PDP/ICE/PFI/GS&LS/LIME/SHAP:《Interpretability Methods in Machine Learning: A Brief Survey机器学习可解释性
- Matlab:成功解决In an assignment A(I)=B,the number of elements in B and I must be the same
- 已解决SyntaxError: invalid character in identifier
- Python使用4个空格替换Tab, TabError: inconsistent use of tabs and spaces in indentation。
- 论文笔记:An Experimental Comparison of Performance Metrics for Event Detection Algorithms in NILM(2)