本文介绍了在 Browserstack Automate 上运行 Protractor 测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我正在开发一个 AngularJS 应用程序,并希望使用 Protractor 进行端到端测试.我想从 Browserstack 提供的测试浏览器套件中受益,并在 Browserstack Automate 而不是本地 Selenium 服务器上运行测试.

I'm developing an AngularJS app and want to do end-2-end testing with Protractor. I would like to benefit from the suite of test browsers available at Browserstack and run the tests on Browserstack Automate instead of a local Selenium server.

如何设置系统来运行这些测试?

How do I set up a system to run these tests?

推荐答案

Protractor from 版本 3.0.0 之后为 BrowserStack 添加了内置支持.

Protractor from version 3.0.0 onwards has added inbuilt support for BrowserStack.

您只需在 conf.js 中添加以下两个参数即可在 BrowserStack 上启动测试:

You simply need to add the following two parameters in your conf.js to launch the test on BrowserStack:

browserstackUser: '<username>'
browserstackKey: '<automate-key>'

在您登录帐户后,可以在此处找到您的用户名和自动密钥.

Your username and automate key can be found here, after you have logged in to your account.

因此,假设您希望在 Chrome 50/OS X Yosemite 上运行您的测试,您的 conf.js 应如下所示:

Hence, lets say you wish to run your test on Chrome 50 / OS X Yosemite, your conf.js should look something like this:

exports.config = {
  specs: ['spec.js'],

  browserstackUser: '<username>',
  browserstackKey: '<automate-key>',

  capabilities: {
    browserName: 'Chrome',
    browser_version: '50.0',
    os: 'OS X',
    os_version: 'Yosemite'
  },
};

如果您希望在不同的浏览器和操作系统组合上并行运行测试,您可以使用multiCapabilities,如下所示:

If you wish to run tests in parallel on different browser and OS combinations, you can use the multiCapabilities as given below:

exports.config = {
  specs: ['spec.js'],

  browserstackUser: '<username>',
  browserstackKey: '<automate-key>',

  multiCapabilities: [
    {
        browserName: 'Safari',
        browser_version: '8.0',
        os: 'OS X',
        os_version: 'Yosemite'
    },
    {
       browserName: 'Firefox',
       browser_version: '30.0',
       os: 'Windows',
       os_version: '7'
    },
    {
       browserName: 'iPhone',
       platform: 'MAC',
       device: 'iPhone 5S'
    }
  ]
};

一些有用的链接:

  1. 代码生成器 - 帮助您配置能够在不同的浏览器和操作系统组合(尤其是移动设备)上进行测试.

  1. Code Generator - Helps you configure the capabilities to test on different various browser and OS combinations especially mobile devices.

Protractor-BrowserStack 示例 Github 项目 - 这应该会有所帮助你开始吧.

Sample Github project for Protractor-BrowserStack - This should help you get started.

这篇关于在 Browserstack Automate 上运行 Protractor 测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 23:06