E2E量角器测试需要OAuth认证 [英] e2e protractor test requiring oauth authentication

查看:230
本文介绍了E2E量角器测试需要OAuth认证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个角度的应用程序,要求与谷歌认证,一些示波器等发放,而我试图设置自动端到端测试它。我有量角器一般工作对我来说很好,但是当我们到了谷歌AUTH页面,登录名和重定向,量角器测试失败,因为文件在等待结果卸载。

I've got an Angular app that requires authentication with Google, granting of some scopes, etc, and I'm trying to set up automatic e2e tests for it. I have protractor working well for me in general, but when we get to the google auth page, login, and get redirected, protractor fails the test because "document unloaded while waiting for result."

是否有工具或技术,我可以用它来验证到谷歌发展帐户beforeEach测试?

Is there a tool or technique I can use to authenticate to a development google account beforeEach test?

如果我刚才得到的框架来举行的第二次,而普通老式硬盘的webdriver登录,只有真正激活角的东西后,我去我的目标网页,这将是完美的!

If I could just get the framework to hold on for a second while plain-old webdriver drives the login, and only really activate the angular stuff after I get to my target page, that would be perfect!

推荐答案

的关键是使用 browser.driver.get 而不是的浏览器。获得,并使用 browser.driver.sleep(someMilliseconds)让角负荷您的最终目的地使用角特定的命令之前。

The key is to use browser.driver.get instead of browser.get, and to use browser.driver.sleep(someMilliseconds) to let angular load at your final destination before using the angular-specific commands.

这是我的工作量角器规范,首先授权谷歌和然后计算在一个中继器中​​的项目:

Here's my working protractor spec that first authorizes to Google and then counts the items in a repeater:

it('allows the user to add new slides', function () {
    browser.driver.get('http://localhost:3000/editor/?state=%7B"action":"create"%7D');

    // at this point my server redirects to google's auth page, so let's log in
    var emailInput = browser.driver.findElement(by.id('Email'));
    emailInput.sendKeys('user@googleappsdomain.com');

    var passwordInput = browser.driver.findElement(by.id('Passwd'));
    passwordInput.sendKeys('pa$sWo2d');  //you should not commit this to VCS

    var signInButton = browser.driver.findElement(by.id('signIn'));
    signInButton.click();

    // we're about to authorize some permissions, but the button isn't enabled for a second
    browser.driver.sleep(1500);

    var submitApproveAccess = browser.driver.findElement(by.id('submit_approve_access'));
    submitApproveAccess.click();

    // this nap is necessary to let angular load.
    browser.driver.sleep(10000);

    // at this point the protractor functions have something to hook into and 
    // will work as normal!
    element(by.id('new-slide-dropdown-trigger')).click();
    element(by.id('new-text-slide-trigger')).click();

    var slideList = element.all(by.repeater('slide in deck.getSlides()'));
    slideList.then(function(slideElements) {
        expect(slideElements.length).toEqual(1);
    });

});

这篇关于E2E量角器测试需要OAuth认证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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