【问题标题】:Protractor : browser.get() doesn't function量角器:browser.get() 不起作用
【发布时间】:2016-02-11 10:23:21
【问题描述】:

我是使用量角器进行 angularjs 应用程序 e2e 测试的新手。 我有最新版本的量角器设置并使用 Visual Studio 2015 作为 IDE。

我的测试中提到的函数 browser.get() 不起作用,只会打开一个带有“Data:”的浏览器窗口。

这是我的 config.js 文件:

'use strict';
exports.config = {
        directConnect: true,
        chromeDriver: './node_modules/protractor/selenium/chromedriver.exe',

    // Capabilities to be passed to the webdriver instance.
    capabilities: {
        'browserName': 'chrome'

    },

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

    // Options to be passed to Jasmine-node.
    jasmineNodeOpts: {
        showColors: true,
        defaultTimeoutInterval: 30000
    },

    onPrepare: function () {
        browser.driver.manage().window().maximize();
    }
};

这是我的 spec.js 文件:

describe('angularjs homepage', function () {
    it('should have a title', function () {
      browser.get('http://angularjs.org/');

        expect(browser.getTitle()).toContain('AngularJS');
    });
});

我错过了什么吗?请帮忙!我从 3 天以来一直在尝试解决此问题。

【问题讨论】:

  • 你用的是什么版本的chromedriver?
  • 我正在使用 Chromedriver 2.21 @TesterPhi,不,我没有使用 karma Riyaj!
  • 如果您使用 protractor 3.0+,请将您的框架设置为 'jasmine2'
  • 用 jasmine2 试过了,还是不行 :( @martin770
  • 请告诉我你的节点和量角器版本。

标签: javascript angularjs protractor protractor-net


【解决方案1】:

第一件事,

chromeDriver: './node_modules/protractor/selenium/chromedriver.exe'

不需要。您的网络驱动程序管理器管理它。

If your protractor version is >3.0  then install node > 4.0.

更新:

请触发以下命令:

webdriver-manager update

【讨论】:

  • 节点 >4.0 ?你的意思是我需要升级我的 npm 包? @RIYAJ 汗
  • 请告诉我节点和量角器版本
  • Node.js 版本为 4.2.2,量角器版本为 3.1.1
  • 我没有收到任何错误,我直接从 Visual Studio 运行测试,浏览器使用数据启动;在其中并且 browser.get() 没有被命中。跨度>
  • 解决了这个问题!我不得不将我的 node.js 版本从 4.6.2 更新到 5.4.0。感谢大家的支持!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-08-16
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多