在Browserstack运行自动化测试量角器 [英] Running Protractor tests on Browserstack Automate

查看:536
本文介绍了在Browserstack运行自动化测试量角器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开发一个应用程序AngularJS并希望做终端2终端的测试用量角器。我想从该套件在Browserstack可用的测试浏览器,而不是受益,并运行本地硒服务器上Browserstack自动化测试。

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?

推荐答案

您需要有节点 NPM 安装。请与节点您的节点版本--version ,以确保它比v0.10.0更大。

Prerequisites

You will need to have node and npm installed. Check your node version with node --version to ensure it is greater than v0.10.0.

准备好了吗?

使用NPM来在全球安装量角器:

Use npm to install Protractor globally with:

npm install -g protractor

如果你的错误,你可能需要运行上面的命令sudo的。

If you get errors, you might need to run the above command as sudo.

下面是安装和使用量角器更详细的教程。

Here's a more detailed tutorial for installing and using Protractor.

修改 @elgalu在这一步是没有必要的评论中指出。显然,BrowserStackLocal隧道(在步骤4中设置)就足够了。

@elgalu pointed out in the comments this step is not necessary. Apparently the BrowserStackLocal tunnel (set up in step 4) is enough.

Browserstack的指示设立node.js的的,安装seleniun网络驱动程序:

Following Browserstack's instructions for setting up node.js, install the seleniun web driver:

npm install -g browserstack-webdriver

3。设置量角器配置

创建的 protractor.conf.js 的文件(见 BrowserStack的支持能力)

exports.config = {
  capabilities: {
    'browserstack.user' : 'my_user_name',
    'browserstack.key' : 'my_secret_key',

    // Needed for testing localhost
    'browserstack.local' : 'true',

    // Settings for the browser you want to test
    // (check docs for difference between `browser` and `browserName`
    'browser' : 'Chrome',
    'browser_version' : '36.0',
    'os' : 'OS X',
    'os_version' : 'Mavericks',
    'resolution' : '1024x768'
  },

  // Browserstack's selenium server address
  seleniumAddress: 'http://hub.browserstack.com/wd/hub',

  // Pattern for finding test spec files
  specs: ['test/**/*.spec.js']
}

更改用户名和密钥到Browserstack自动化页面上给出的那些。如果你到Browserstack记录,设立node.js的指示将你的用户和替代各例中键,你可以从那里复制粘贴的JavaScript。

Change your user name and secret key to the ones given on the Browserstack Automate page. If you're logged in to Browserstack, the instructions for setting up node.js will have you user and key substituted in the examples, and you can just copy-paste the javascript from there.

在同一页也有产生code不同的测试浏览器设置的工具。

The same page also has a tool for generating the code for different test browser settings.

从href=\"http://www.browserstack.com/automate/node#setting-local-tunnel\"> Node.js的说明页 BrowserStackLocal 的二进制>。

Download the BrowserStackLocal binary from the node.js instructions page.

请以下更改下面的命令,运行的二进制打开测试所需的Browserstack隧道。

Make the following changes to the command below, and run the binary to open the Browserstack tunnel required for testing.


  • 更改密钥的命令。同样, your_secret_key 的将在Node.js的引导自动替换,如果你到Browserstack登录。

  • 更改端口号,以匹配你在本地主机上托管你的AngularJS文件中的端口。该示例使用3000端口。

  • Change your secret key in the command. Again, your_secret_key will be automatically substituted in the node.js guide, if you're logged in to Browserstack.
  • Change the port number to match the port you're hosting your AngularJS files at on localhost. The example uses port 3000.

./BrowserStackLocal your_secret_key localhost,3000,0


准备停当后进行测试,运行测试:

With everything ready for testing, run your tests:

protractor protractor.conf.js

您可以观看 Browserstack自动化,甚至可以看到测试浏览器的更新直播截图。

You can watch the test run on Browserstack Automate and even see an updating live screenshot of the test browser.

这篇关于在Browserstack运行自动化测试量角器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆