获取角内容加载中量角器测试 [英] Getting the Angular Content to load in protractor tests

查看:243
本文介绍了获取角内容加载中量角器测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我写的E2E测试用量角器角的应用程序。

I have an angular application that I am writing e2e test for using protractor.

以下是我conf.js文件设置

Following is my conf.js file setup

var project = require('./package.json');
var HtmlReporter = require('protractor-jasmine2-screenshot-reporter');

var multiCapabilities = [{
    'browserName': 'chrome'
}];

multiCapabilities = [{
    'browserName': 'chrome',
    "platform": "Windows 7",
    'build': 'Testing',
    'name': project.name + ' tests'
}]

exports.config = {
    framework: 'jasmine2',
    sauceUser: 'blahblhablah',
    sauceKey: 'xyzabcdxyzabac',
    multiCapabilities: multiCapabilities,
    specs: ['e2e/main.spec.js'],
    jasmineNodeOpts: {
        showColors: true,
        defaultTimeoutInterval: 30000
    },
    onPrepare: function() {
        jasmine.getEnv().addReporter(new HtmlReporter({
            dest: 'reports/e2e'
        }));
    }
};

以下是我的测试规范文件

Following is my test spec file

'use strict';

var mainPage = require('./page.js');
describe('Demo', function() {

    //Check if title pages are consistent
    it('Test 1', function() {

        browser.get('http://localhost:3000/'); 
        expect(browser.getTitle()).toEqual('NBA LIVE');
    });
});

我正在我的测试上saucelabs当我运行本地他们我没有问题。所以以后我跑这个测试,我得到了以下错误消息。

I am running my test on saucelabs when I run them locally I have no issues. So after I ran this test I got the following error message.

   消息:

        失败:角不能在页面上的http://本地主机:3000 / :重找

        角超过

   Message:
      Failed: Angular could not be found on the page http://localhost:3000/ : retries looking for
      angular exceeded

所以,我做了一些更多的研究和实现我可以设置 browser.ignoreSynchronization = TRUE; 在我的测试规范文件。

So i did a little more research and realized I can set browser.ignoreSynchronization = true; in my test spec file.

这样算下来,我得到了以下错误消息后:

So after doing that I get the following error message:

   消息:

        预计的http://本地主机:3000 / '平等' NBA LIVE。

   Message:
      Expected 'http://localhost:3000/' to equal 'NBA LIVE'.

所以我想也许是角度还是因为我的内容没有加载设置忽略同步到真实的,但如果我不那么我得到其他错误。运行时,我的本地测试我的笔记本电脑,但只有在saucelab做时再没有这是一个问题。很显然,我需要补充的东西,使角内容的负载。请咨询我该怎么做。

So I think maybe the angular or the content is not loading because of me setting ignoring synchronization to true but if i do not then I get the other error. Again none of this is an issue when running my test locally on my laptop but only when doing on saucelab. It is clear I need to add something to make angular content load. Please advice me on what to do.

推荐答案

什么可能发生的是,它的检查页面加载之前的预期,所以你可以尝试让它等到标题说NBA,你希望它通过LIVE前使用 protractor.until statments

what might be happening is that it's checking the expect before the page loads so you could try to make it wait till the title says NBA LIVE before you expect it by using the protractor.until statments

    browser.wait(protractor.until.titleIs("NBA LIVE"), 5000, "✗ Failed to wait for the NBA LIVE page to load");
    expect(browser.getTitle()).toEqual("NBA LIVE");

编辑:

由于您使用的是本地应用程序,并使用saucelabs,那么你将需要设置酱连接

Since you are using a local app and using saucelabs then you will need to setup sauce connect

这篇关于获取角内容加载中量角器测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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