编写代码时在量角器中用作css选择器的用途

时间:2017-05-09 19:24:32

标签: selenium protractor

在元素中使用什么(by.css(&#34;&#34;)用于在量角器中编写测试,如果该类指的是<a class="button button-large button-secondary has-shield download-btn"

  var HomePage = function() {
this.centerStageButtons = element(by.css(".text-center"));

this.tryTheAngular = this.centerStageButtons.all(by.css(".button.button-large.button-primary.has-shield.has-shadow")).get(0);
this.downloadButton = this.centerStageButtons.element(by.css("..button.button-large.button-secondary.has-shield.download-btn"));

describe('angularjs.org', function() {
  var homePage = new HomePage();

  beforeEach(function() {
    browser.get('https://angularjs.org/');
    });
    it('should have two buttons', function() {
      //expect(homePage.tryTheAngular.isDisplayed()).toBe(true);
      expect(homePage.downloadButton.isDisplayed()).toBe(false);

  });
});

};

当测试通过时,它给了我一个误报

1 个答案:

答案 0 :(得分:0)

这有效

this.downloadButton = element(by.css(".button.button-large.button-secondary.has-shield.download-btn"));