【问题标题】:protractor get url after click()点击()后量角器获取网址
【发布时间】:2015-06-25 08:04:01
【问题描述】:

我是量角器的新手..我需要你的帮助.. 我的代码是这样的..

describe('Protractor Demo Charts', function () {
           var url = 'https://angularjs.org/';


it('should get the value of attribute d', function () {
    browser.get(url);
    element(by.css('.btn-warning')).click().then(function(text){

        expect(browser.getCurrentUrl()).toContain('0BxgtL8yFJbacQmpCc1NMV3d5dnM');
        }

    );

});

});

我的问题是 browser.getCurrentUrl() 仍然返回基本 URL(我来自 'https://angularjs.org/' 的页面)

我怎样才能获得新的 URL(URL AFTER 点击)?

【问题讨论】:

    标签: angularjs protractor


    【解决方案1】:

    您应该等到页面加载完毕。 试试这个方法:

    describe('Protractor Demo Charts', function () {
         var url = 'https://angularjs.org/';
    
         it('should get the value of attribute d', function () {
             browser.get(url);
             browser.sleep(2000);
             $('.btn-warning').click();
             expect(browser.getCurrentUrl()).toContain('0BxgtL8yFJbacQmpCc1NMV3d5dnM');
         });
    });
    

    来自doc

    Protractor 将确保命令将自动同步运行。比如下面的代码中 element(by.model(...)).click() 会在 browser2.$('.css').click() 之前运行:

    browser.get('http://www.angularjs.org');
    browser2.get('http://localhost:1234');
    
    browser.sleep(5000);
    element(by.model(...)).click();
    browser2.$('.css').click();
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-05-09
      • 2017-12-21
      • 1970-01-01
      • 2015-12-08
      • 1970-01-01
      • 2020-05-06
      相关资源
      最近更新 更多