• [Protractor] Locators and Suites in Protractor


    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
  • 相关阅读:
    pymoo: Multi-objective Optimization in Python
    读代码——NSGAII
    读论文——A Fast and Elitist Multiobjective Genetic Algorithm: NSGA-II
    神经网络入门00
    梯度下降pthon实现
    在线加解密工具
    安恒杯-一张谍报
    漏洞挖掘学习记录
    安恒杯-元数据存储
    安恒杯-babysql
  • 原文地址:https://www.cnblogs.com/Answer1215/p/5208662.html
Copyright © 2020-2023  润新知