【问题标题】:how to get protractor running with firefox?如何让量角器与Firefox一起运行?
【发布时间】:2015-08-05 22:18:38
【问题描述】:

尝试使用 Firefox 浏览器运行量角器测试。这是我的配置文件:

// An example configuration file.
exports.config = {
  //directConnect: true,

  // Capabilities to be passed to the webdriver instance.
  capabilities: {
    'browserName': 'firefox'
  },

  //chromeOnly:false,

  // Framework to use. Jasmine 2 is recommended.
  framework: 'jasmine2',

  // Spec patterns are relative to the current working directly when
  // protractor is called.
  specs: ['example_spec_backup.js'],

  seleniumServerJar: 'C:/Users/myname/protractor/protractor-master/chromedriver_win_26.0.1383.0/selenium-server-standalone-2.46.0.jar',

  baseUrl: 'http://localhost:9000/',

  // Options to be passed to Jasmine.
  jasmineNodeOpts: {
    defaultTimeoutInterval: 30000
  }
};

失败:在页面 http://www.angularjs.org/ 上找不到 Angular:重试寻找超出的角度。

这是其中一项测试:

  it('should greet the named user', function() {
    browser.get('http://www.angularjs.org');

    element(by.model('yourName')).sendKeys('Julie');

    var greeting = element(by.binding('yourName'));

    expect(greeting.getText()).toEqual('Hello Julie!');
  });

当我开始测试时,firefox 转到 angularjs.org 但不知何故测试返回错误?

【问题讨论】:

    标签: angularjs protractor


    【解决方案1】:

    可以阅读量角器referenceConfig.js

    直接连接到驱动程序 布尔值。如果为真,Protractor 将直接连接到浏览器驱动程序 在 chromeDriver 和 firefoxPath 指定的位置。只有铬 和 Firefox 支持直接连接。

     directConnect: false,
    

    Firefox 应用程序二进制文件的路径。如果为空,将尝试查找 Firefox 在默认位置。

     firefoxPath: null,
    

    在页面上找不到 Angular

    1.这可能是因为您使用的是旧版本的 Angular。不支持量角器。 2.您需要一些方法来等待,直到不仅元素存在,而且 Angular 被加载到页面上。您可以做的一件事是手动等待 Angular 存在:

    browser.wait(function() {
    return browser.executeScript('return !!window.angular');
    });
    

    【讨论】:

      【解决方案2】:

      您没有启动 selenium 服务器以供 firefox 浏览器调用。在 capabilities -

      之前的配置文件中添加以下行
      seleniumAddress: 'http://localhost:4444/wd/hub',
      

      希望这会有所帮助。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-01-28
        • 1970-01-01
        • 2015-11-06
        • 2021-06-27
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多