代码之家  ›  专栏  ›  技术社区  ›  Muthukumar Marichamy

登录屏幕角度6中的量角器测试

  •  0
  • Muthukumar Marichamy  · 技术社区  · 7 年前

    describe('Protractor Login checing ', function() {
        it('should add one and two', function() {
            browser.get('http://localhost:4041/login');
            element(by.model('username')).sendKeys('admin');
            element(by.model('password')).sendKeys('admin');
    
            element(by.id('login')).click();
    
            // Here, What should I check whether authentication has been done or not..
            // expect().toEqual('');
        });
    });
    

    实际上,在我的应用程序中,一旦逻辑成功,我将在snackBar(角度材质)中显示一条成功消息,并重定向到仪表板页面。

    // Angular 6 application    
    this.snackBar.open(res.message, '', {
                    duration: 6000,
                  });
    

    这里,我应该如何检查量角器?

    1 回复  |  直到 7 年前
        1
  •  1
  •   Alex Choroshin    7 年前

    你应该检查一下房间 url 有没有变化-

    describe('Protractor Login checing ', function() {
        it('should add one and two', function() {
        browser.get('http://localhost:4041/login');
        element(by.model('username')).sendKeys('admin');
        element(by.model('password')).sendKeys('admin');
    
        element(by.id('login')).click();
    
        browser.wait(waitForUrlChange("http://localhost:4041/dashboard"), 8000, function(){
          browser.getCurrentUrl().then(function (currentUrl) {
              expect(currentUrl.toEqual("http://localhost:4041/dashboard"));
          });
      }));
     });
    
    function waitForUrlChange(url) {
        return function () {
            return browser.getCurrentUrl().then(function (currentUrl) {
                console.log(currentUrl);
                return url === currentUrl;
            });
        }
    }
    
    推荐文章