标签: angularjs-e2e

如何在AngularJS e2e测试中测试拖放功能

我正在尝试测试我的应用程序,我需要将一个小部件从一个位置移动到另一个位置,换句话说,我需要在端到端测试中测试拖放功能.

我该如何测试?

javascript angularjs angularjs-e2e protractor

9
推荐指数
2
解决办法
7023
查看次数

什么是中途测试?

所以我听说过单元和集成测试,但我最近听说过中途测试.似乎该术语最常用于AngularJS上下文中.谷歌查询提供的主题信息非常少.我对中途测试的问题是:

  1. 它与单元和集成测试有何不同?
  2. 它有什么用途?
  3. 它解决了其他两种方法无法解决的问题?
  4. 它是AngularJS特定的概念吗?

javascript integration-testing unit-testing angularjs angularjs-e2e

9
推荐指数
1
解决办法
1829
查看次数

如何在量角器中模拟拖放动作?

我有一个双滑块,我想测试它是否可操作并返回正确的数据.滑块有一个min和max处理程序,它还有一些"我可以挂钩的断点".

我想要模拟的是

  • 一个".handler-max"元素的touchStart
  • 用类".step-3"将拇指移动到元素上
  • 触摸".handler-max"元素的结尾

而我发现了如何触发touchStart和touchEnd事件.我对如何模拟拇指的移动毫无头绪

browser.executeScript('angular.element(arguments[0]).triggerHandler("touchstart");', filterHandler);
// <--- move event????
browser.executeScript('angular.element(arguments[0]).triggerHandler("touchend");', filterHandler);
Run Code Online (Sandbox Code Playgroud)

PS这个问题的范围是一个集成测试,它测试当用户与双滑块指令交互时应用程序发生了什么是理想的结果.

testing angularjs angularjs-e2e protractor

9
推荐指数
2
解决办法
2万
查看次数

量角器:获取没有特定类的元素

我试图让e2e测试在下一个例子上工作:

HTML:

<div ng-if="selectedItem">
  <span class-"xxx">This is line 1</span>
  <span class="xxx yyy">This is line 2</span>
</div>
Run Code Online (Sandbox Code Playgroud)

量角器:

..
element.findByCss('div[ng-if="selectedItem"] span[class!="yyy"]');
..
Run Code Online (Sandbox Code Playgroud)

给出以下错误:

失败:无效的元素状态:无法在'Document'上执行'querySelectorAll':'div [ng-if ="selectedItem"] span [class!="yyy"]'不是有效的选择器.

选择器使用jQuery虽然..我知道它不一样.但我似乎无法找到如何用量角器排除一个类

angularjs-e2e protractor

9
推荐指数
1
解决办法
3001
查看次数

获取错误:等待Protractor与页面同步时出错:{}

我的e2e.conf.coffee档案是:

exports.config =
  baseUrl: 'http://localhost:9001'
  specs: [
    'e2e/**/*.coffee'
  ]

  framework: 'jasmine'
Run Code Online (Sandbox Code Playgroud)

我让我的节点项目运行并在端口9001上侦听.

我的测试是:

describe 'Happy Path', ->
  it 'should show the login page', ->
    console.log browser

    expect(browser.getLocationAbsUrl()).toMatch("/view1");
  it 'should fail to login', ->
    setTimeout ->
      console.log "FAIL!"
    , 1200
Run Code Online (Sandbox Code Playgroud)

而我得到的错误是:

Failures:

  1) Happy Path should show the login page
   Message:
     Error: Error while waiting for Protractor to sync with the page: {}
   Stacktrace:
     Error: Error while waiting for Protractor to sync with the page: {}
    at <anonymous>
    at …
Run Code Online (Sandbox Code Playgroud)

angularjs angularjs-e2e protractor

8
推荐指数
2
解决办法
2万
查看次数

Angularjs - 在Protractor e2e测试中模拟触摸事件

我使用Protractor和Jasmine作为我的移动Angularjs应用程序.我想在特定元素上测试触摸事件(touchStart/touchEnd等...).就像是:

it('should play video', function(){
    var poster = by.css('.video-poster');
    element(poster).??? //Simulate touch event here
});
Run Code Online (Sandbox Code Playgroud)

jasmine angularjs angularjs-e2e protractor

8
推荐指数
1
解决办法
4566
查看次数

量角器addMockModule和$ httpProvider拦截器

这个问题是我的另一个问题的可能解决方案(他们建议使用addMockModule量角器):使用Protractor运行测试时调用其他api.

我有以下文件:mockedRest.js这是我要添加到量角器的模块.它应该拦截任何REST调用并替换地址(api /到apiMock /).

exports.apiMockModule = function () {

    console.log('apiMockModule executing');

    var serviceId = 'mockedApiInterceptor';
    angular.module('apiMockModule', ['myApp'])
        .config(['$httpProvider', configApiMock])
        .factory(serviceId,
        [mockedApiInterceptor]);

    function mockedApiInterceptor() {
        return {
            request: function (config) {
                console.log('apiMockModule intercepted');
                if ((config.url.indexOf('api')) > -1) {
                    config.url.replace('api/', 'apiMock/');
                }

                return config;
            },
            response: function (response) {
                return response
            }
        };
    }

    function configApiMock($httpProvider) {
        $httpProvider.interceptors.push('mockedApiInterceptor');
    }
};
Run Code Online (Sandbox Code Playgroud)

然后我在实际测试中加载模块.

describe('E2E addMockModule', function() {
    beforeEach(function() {
        var mockModule = require('./mockedRest');
        browser.addMockModule('apiMockModule', mockModule.apiMockModule);
        console.log('apiMockModule loaded');
        browser.get('#page'); …
Run Code Online (Sandbox Code Playgroud)

angularjs angularjs-e2e protractor

8
推荐指数
1
解决办法
4945
查看次数

使用npm protractor webdriver-manager在另一个端口启动selenium服务器

我正在尝试使用量角器进行角度应用的E2E测试.我使用该命令./node_modules/protractor/bin/webdriver-manager启动我的selenium服务器.但是,默认的selenium服务器位置是localhost:4444/wd/hub,但localhost:4444已经在我的机器上使用,这很难改变.如何在4444以外的端口启动selenium服务器?

angularjs selenium-webdriver angularjs-e2e protractor

8
推荐指数
1
解决办法
5900
查看次数

GitLab CI上的Selenium Grid错误:转发新会话时出错用于设置功能的VM空池

由于关于GitLab CI配置和Selenium的文档通常很差,我正在寻求帮助.

按兴趣点配置:

gitlab.ci.yml:

image: node:7

variables:
  HUB_PORT_4444_TCP_ADDR: "selenium__hub"
  HUB_PORT_4444_TCP_PORT: "4444"

services:
  - selenium/hub:latest
  - selenium/node-phantomjs:latest

stages:
  - test

test:
  stage: test
  before_script:
    - apt-get update
    - apt-get install -y default-jdk default-jre
    - npm install -s -g @angular/cli@1.0.6
    - npm install -s
    - node ./node_modules/protractor/bin/webdriver-manager update
  script:
    - ./node_modules/.bin/protractor protractor.ci.conf.js
Run Code Online (Sandbox Code Playgroud)

protractor.ci.conf.js:

/*global jasmine */
const { SpecReporter } = require('jasmine-spec-reporter');

exports.config = {
  allScriptsTimeout: 11000,
  specs: [
    './e2e/**/*.e2e-spec.ts'
  ],
  capabilities: {
    'browserName': 'phantomjs',
    'phantomjs.binary.path': './node_modules/phantomjs-prebuilt/bin/phantomjs'
  },
  directConnect: false, …
Run Code Online (Sandbox Code Playgroud)

selenium selenium-grid angularjs-e2e protractor gitlab-ci

8
推荐指数
1
解决办法
1002
查看次数

如何让量角器不等待$ timeout?

我用Protractor测试我的角度应用程序.一旦用户登录到我的应用程序,我设置$ timeout以在一小时内完成某项工作(因此,如果用户在13:00登录,则$ timeout将在14:00运行).我一直遇到这些失败:

"Timed out waiting for Protractor to synchronize with the page after 20 seconds. Please see https://github.com/angular/protractor/blob/master/docs/faq.md. The following tasks were pending: - $timeout: function onTimeoutDone(){....."
Run Code Online (Sandbox Code Playgroud)

我已经阅读了这个超时页面:https://github.com/angular/protractor/blob/master/docs/timeouts.md 所以我理解量角器等待页面完全加载,这意味着他正在等待$ timeout完成...

如何让Protractor不等待$ timeout?我不想用:

browser.ignoreSynchronization = true;
Run Code Online (Sandbox Code Playgroud)

因为那时我的测试会因其他原因而失败(其他角度组件仍然需要加载的时间......)

javascript selenium angularjs angularjs-e2e protractor

7
推荐指数
1
解决办法
1656
查看次数