如何在量角器中使用非角色登录页面测试angularjs应用程序

时间:2018-04-29 19:50:22

标签: angularjs protractor e2e-testing angularjs-e2e

我正在努力寻找一种方法来测试我的angularjs应用程序,该应用程序具有非角度登录页面。

所有应用程序的页面都受登录保护,因此无论我测试哪个页面,我都需要先登录。 我在互联网上查看了各种各样的想法,似乎没有任何工作 - 它只是在用量角器登录后不会将我重定向到应用程序,而当我手动操作时,一切都很好。

这就是我现在所拥有的:

onPrepare: function() {
            browser.driver.get('http://localhost:9000/app);
            browser.driver.findElement(by.id('userName')).sendKeys('admin');
            browser.driver.findElement(by.id('password')).sendKeys('pass123');
            browser.driver.findElement(by.id('loginBtn')).click();

            return browser.driver.wait(function() {
                return browser.driver.getCurrentUrl().then(function(url) {
                    return /home/.test(url);
                });
            }, 10000);

我也试过设置browser.ignoreSynchronization = true;,但仍然无处可去。

有人知道我还能尝试什么吗?

1 个答案:

答案 0 :(得分:1)

found face at... BoundingBox: (0.49861112236976624%) BoundingBox: (0.2796874940395355%) BoundingBox: (0.43611112236976624%) BoundingBox: (0.27656251192092896%) found face at... BoundingBox: (0.49861112236976624%) BoundingBox: (0.2796874940395355%) BoundingBox: (0.43611112236976624%) BoundingBox: (0.27656251192092896%) 之前设置ignoreSynchronization=true,然后在点击登录按钮后重置为browser.get()

false

如果上面的代码没有解决您的问题,请尝试移动上面的代码以登录到函数中,不要在onPrepare: function() { browser.ignoreSynchronization = true; browser.driver.get('http://localhost:9000/app); browser.driver.findElement(by.id('userName')).sendKeys('admin'); browser.driver.findElement(by.id('password')).sendKeys('pass123'); browser.driver.findElement(by.id('loginBtn')).click(); browser.ignoreSynchronization = false; return browser.driver.wait(function() { return browser.driver.getCurrentUrl().then(function(url) { return /home/.test(url); }); }, 10000); 中调用该函数,调用onPrepare中的函数。我有一些失败经验开始与beforeAll

内的浏览器进行交互
相关问题