首页 文章

在多个设备上使用Protractor和Appium运行测试

提问于
浏览
2

我正在尝试在多个设备上运行量角器测试 .

  • 多个桌面浏览器

  • 使用Appium的多个移动浏览器

使用Appium的桌面浏览器和移动浏览器的配置是不同的 . Are there any way to mix both configurations?

这是我的配置文件的内容:

1.用于“1-多个桌面浏览器”的主要配置

// conf.js
exports.config = {
framework: 'custom',

frameworkPath: require.resolve('protractor-cucumber-framework'),

cucumberOpts: {
    require: 'features/step_definitions/*.step.js',
    format: "summary"
},

seleniumAddress: 'http://localhost:4444/wd/hub',
specs: ['features/*.feature'],
multiCapabilities: [
    {
        browserName: 'firefox'
    },
    /* TODO Safari is randomly failing (necessary restart safari and selenium server)
     {
     browserName: 'safari'
     },*/
    {
        browserName: 'chrome'
    },
    {
        browserName: 'chrome',
        // List of devices https://cs.chromium.org/chromium/src/chrome/test/chromedriver/chrome/mobile_device_list.cc
        'deviceName': 'Google Nexus 5'
    },
    {
        browserName: 'chrome',
        'deviceName': 'Apple iPhone 6'
    },
    {
        browserName: 'chrome',
        'deviceName': 'Apple iPad'
    },
    {
        browserName: 'chrome',
        'deviceName': 'Samsung Galaxy S4'
    }
]
};

https://github.com/aluzardo/protractor-cucumber-tests/blob/master/conf.js

2.第一移动设备Appium的配置

// conf-appium.js
exports.config = {
framework: 'custom',

frameworkPath: require.resolve('protractor-cucumber-framework'),

cucumberOpts: {
    require: 'features/step_definitions/*.step.js',
    format: "pretty"
},

seleniumAddress: 'http://localhost:4723/wd/hub',
specs: ['features/*.feature'],
capabilities: {
    browserName: 'chrome',
    'appium-version': '1.5.3',
    platformName: 'Android',
    platformVersion: '5.0.2',
    deviceName: '33005bd56ac6c223'
}
};

https://github.com/aluzardo/protractor-cucumber-tests/blob/master/conf-appium.js

3.配置第二移动设备Appium

// conf-appium-1.js
exports.config = {
framework: 'custom',

frameworkPath: require.resolve('protractor-cucumber-framework'),

cucumberOpts: {
    require: 'features/step_definitions/*.step.js',
    format: "pretty"
},

seleniumAddress: 'http://localhost:4747/wd/hub',
specs: ['features/*.feature'],
capabilities: {
    browserName: 'chrome',
    'appium-version': '1.5.3',
    platformName: 'Android',
    platformVersion: '4.2.2',
    deviceName: '30048664b980c100'
}
};

https://github.com/aluzardo/protractor-cucumber-tests/blob/master/conf-appium-1.js

目前我的测试正在运行,但使用不同的conf.js文件并运行appium服务器的各种实例 .

我需要在端口4444上运行selenium服务器,在端口4723上运行一个appium服务器,在端口4747上运行其他appium服务器 . 使用此命令同时运行三个脚本:

protractor conf.js & protractor conf-appium.js & protractor conf-appium-1.js

通常测试通过成功但有时我得到这个错误:

WebDriverError: An unknown server-side error occurred while processing the command. Original error: Could not proxy. Proxy error: Could not proxy command to remote server. Original error: Error: socket hang up

Are there any proper way to config protractor and appium to run tests in multiple devices?

1 回答

  • 0

    据我了解,您只在网络和移动设备中运行浏览器测试,那么为什么要使用appium呢?您只需调整窗口大小即可运行相同的测试 .

    我相信除非您从自动化角度覆盖Native / Hybrid应用程序,否则它是相同的 . 在少数特殊情况下(定位器更改)可以在页面对象内单独处理 .

相关问题