无法在Android模拟器上运行量角器脚本

时间:2016-03-11 16:42:13

标签: android jasmine protractor appium end-to-end

我想使用Appium在Android模拟器上执行protractor脚本,但是当我点击终端上的“protractor conf.js”时问题模拟器没有启动。测试在Windows的chrome浏览器中传递,而不是在模拟器中的浏览器中传递。我可以添加其他功能吗?或者我应该更改基本网址?

// An example configuration file.
exports.config = {
  seleniumAddress: 'http://localhost:4733/wd/hub',
    specs: ['todo-spec.js'],
    directConnect: true,

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

  'browserName': 'chrome',
      'device': 'android',
      'deviceName' : '5554:AndroidDevice',
       device: 'android',
    'appium-version': "1.4.16.1",
    deviceName : '5554:AndroidDevice',
  },

  // Framework to use. Jasmine is recommended.
  framework: 'jasmine',
 baseUrl: 'http://127.0.0.1:5858',
  // Spec patterns are relative to the current working directly when
  // protractor is called.


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

//------------------todo-spec.js----------------------------------------
describe('angularjs homepage todo list', function() {
    it('should add a todo', function() {
        browser.get('https://angularjs.org');

        element(by.model('todoList.todoText')).sendKeys('write first protractor test');
        element(by.css('[value="add"]')).click();

        var todoList = element.all(by.repeater('todo in todoList.todos'));
        expect(todoList.count()).toEqual(3);
        expect(todoList.get(2).getText()).toEqual('write first protractor test');

        // You wrote your first test, cross it off the list
        todoList.get(2).element(by.css('input')).click();
        var completedAmount = element.all(by.css('.done-true'));
        expect(completedAmount.count()).toEqual(2);
    });
});

1 个答案:

答案 0 :(得分:1)

删除directConnect以允许它使用selenium服务器:

// An example configuration file.
exports.config = {
  seleniumAddress: 'http://localhost:4733/wd/hub',
  specs: ['todo-spec.js'],
  directConnect: true,  <-- remove this line

  ...
} 

应该有助于清理的相关主题: