【问题标题】:Run test using Protractor and Appium on multiple devices在多个设备上使用 Protractor 和 Appium 运行测试
【发布时间】:2016-10-21 20:28:54
【问题描述】:

我正在尝试在多台设备上运行量角器测试。

  1. 多个桌面浏览器
  2. 使用 Appium 的多个移动浏览器

使用 Appium 的桌面浏览器和移动浏览器的配置不同。 有没有办法混合使用这两种配置?

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

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

是否有任何适当的方法来配置量角器和 appium 以在多个设备上运行测试?

【问题讨论】:

    标签: javascript selenium protractor appium


    【解决方案1】:

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

    我相信,除非您从自动化角度涵盖原生/混合应用程序,否则它是相同的。在少数例外情况下(定位器更改)可以在页面对象内单独处理。

    【讨论】:

    • 正如您在第一个配置中看到的那样,我正在使用浏览器调整窗口大小进行测试。但是我想在真实设备上运行测试,因为原生移动浏览器不等于桌面浏览器。我想创建一个真正的环境。感谢您的解决方案,但我想使用 appium。
    猜你喜欢
    • 2017-02-22
    • 2018-10-18
    • 1970-01-01
    • 1970-01-01
    • 2021-05-25
    • 1970-01-01
    • 2015-10-07
    • 2016-05-31
    • 1970-01-01
    相关资源
    最近更新 更多