【问题标题】:Couldn't run protractor scripts on Android emulator无法在 Android 模拟器上运行量角器脚本
【发布时间】:2016-06-27 00:15:29
【问题描述】:

我想使用 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);
    });
});

【问题讨论】:

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


    【解决方案1】:

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

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

    一个有助于理清问题的相关主题:

    【讨论】:

    • 当我删除这一行:“directConnect: true”时,我在启动 appium 时得到了模拟器。但问题是模拟器并不总是响应
    猜你喜欢
    • 1970-01-01
    • 2018-01-04
    • 1970-01-01
    • 2017-08-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-09-07
    • 2018-10-24
    相关资源
    最近更新 更多