本机量角器测试示例未运行

时间:2017-09-15 07:41:48

标签: angularjs node.js selenium protractor

我是量角器的新手,在安装了所有东西之后,我尝试运行测量示例,量角器为您提供测试,确保一切正常。显然,它没有。

以下是我使用的一些版本的信息:

节点v6.11.3 | npm v3.10.10 | java 1.8 | selenium webdriver 3.5 | chrome浏览器60.0 | 量角器5.1.2

这是我试图运行的conf.js:

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

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

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

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

  // Options to be passed to Jasmine.
  jasmineNodeOpts: {

     defaultTimeoutInterval: 30000

  }
};

示例规范:

describe('angularjs homepage', function() {
  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!');
  });

  describe('todo list', function() {
    var todoList;

    beforeEach(function() {
      browser.get('http://www.angularjs.org');

      todoList = element.all(by.repeater('todo in todoList.todos'));
    });

    it('should list todos', function() {
      expect(todoList.count()).toEqual(2);
      expect(todoList.get(1).getText()).toEqual('build an AngularJS app');
    });

    it('should add a todo', function() {
      var addTodo = element(by.model('todoList.todoText'));
      var addButton = element(by.css('[value="add"]'));

      addTodo.sendKeys('write a protractor test');
      addButton.click();

      expect(todoList.count()).toEqual(3);
      expect(todoList.get(2).getText()).toEqual('write a protractor test');
    });
  });
});

这是它抛出的错误:

Failures:
1) angularjs homepage should greet the named user
  Message:
    Failed: Timed out waiting for asynchronous Angular tasks to finish after 11 seconds. This may be because the current page is not an Angular application. Please see the FAQ for more details: https://github.com/angular/protractor/blob/master/docs/timeouts.md#waiting-for-angular
    While waiting for element with locator - Locator: by.model("yourName")
  Stack:
    ScriptTimeoutError: asynchronous script timeout: result was not received in 11 seconds
      (Session info: chrome=60.0.3112.113)
      (Driver info: chromedriver=2.32.498513 (2c63aa53b2c658de596ed550eb5267ec5967b351),platform=Linux 3.16.0-4-amd64 x86_64)
        at WebDriverError (/usr/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/error.js:27:5)
        at ScriptTimeoutError (/usr/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/error.js:203:5)
        at Object.checkLegacyResponse (/usr/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/error.js:505:15)
        at parseHttpResponse (/usr/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/http.js:509:13)
        at doSend.then.response (/usr/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/http.js:440:13)
        at process._tickCallback (internal/process/next_tick.js:109:7)
    From: Task: Protractor.waitForAngular() - Locator: by.model("yourName")
        at Driver.schedule (/usr/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver.js:816:17)
        at ProtractorBrowser.executeAsyncScript_ (/usr/lib/node_modules/protractor/lib/browser.ts:609:24)
        at angularAppRoot.then (/usr/lib/node_modules/protractor/lib/browser.ts:643:23)
        at ManagedPromise.invokeCallback_ (/usr/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:1366:14)
        at TaskQueue.execute_ (/usr/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:2970:14)
        at TaskQueue.executeNext_ (/usr/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:2953:27)
        at asyncRun (/usr/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:2813:27)
        at /usr/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:676:7
        at process._tickCallback (internal/process/next_tick.js:109:7)Error
        at ElementArrayFinder.applyAction_ (/usr/lib/node_modules/protractor/lib/element.ts:482:23)
        at ElementArrayFinder.(anonymous function) [as sendKeys] (/usr/lib/node_modules/protractor/lib/element.ts:96:21)
        at ElementFinder.(anonymous function) [as sendKeys] (/usr/lib/node_modules/protractor/lib/element.ts:873:14)
        at UserContext.<anonymous> (/usr/lib/node_modules/protractor/example/example_spec.js:5:35)
        at /usr/lib/node_modules/protractor/node_modules/jasminewd2/index.js:112:25
        at new ManagedPromise (/usr/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:1067:7)
        at ControlFlow.promise (/usr/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:2396:12)
        at schedulerExecute (/usr/lib/node_modules/protractor/node_modules/jasminewd2/index.js:95:18)
        at TaskQueue.execute_ (/usr/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:2970:14)
        at TaskQueue.executeNext_ (/usr/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:2953:27)
    From: Task: Run it("should greet the named user") in control flow
        at UserContext.<anonymous> (/usr/lib/node_modules/protractor/node_modules/jasminewd2/index.js:94:19)
    From asynchronous test: 
    Error
        at Suite.<anonymous> (/usr/lib/node_modules/protractor/example/example_spec.js:2:3)
        at Object.<anonymous> (/usr/lib/node_modules/protractor/example/example_spec.js:1:63)
        at Module._compile (module.js:570:32)
        at Object.Module._extensions..js (module.js:579:10)
        at Module.load (module.js:487:32)
        at tryModuleLoad (module.js:446:12)

3 specs, 1 failure
Finished in 16.136 seconds

[09:34:24] I/launcher - 0 instance(s) of WebDriver still running
[09:34:24] I/launcher - chrome #01 failed 1 test(s)
[09:34:24] I/launcher - overall: 1 failed spec(s)
[09:34:24] E/launcher - Process exited with error code 1

显然,它声称网页不是一个Angular应用程序,因为这个测试是量角器本身的一个例子测试,看看是否所有东西都在运行。我没有写任何东西。 运行测试时,Chrome会在加载角度网页时打开。然后它显然试图做某事&#34;但是失败了,然后打开了另一个页面,它写了字符串&#34;写了一个量角器测试&#34;到该页面上的输入标签。之后浏览器关闭。

有人知道这里有什么问题吗?我开始变得非常沮丧。我现在已经尝试解决这个问题4天了。

2 个答案:

答案 0 :(得分:0)

在conf.js中添加allScriptsTimeout作为Protractor官方网站说: http://www.protractortest.org/#/timeouts

    while True:
        if self.grid.get_child_at(0,1)!= None:
            self.grid.remove_row(1)
        else:
            break

答案 1 :(得分:-1)

尝试在spec文件中添加以下步骤

      browser.IgnoreSynchronization = true;