2017-02-06 16 views
0

リンクをテストするために異なるメニュー項目を取得しようとしていますが、ドロップダウンでこれを行う方法を理解しましたが、一般的なナビゲーションバーで問題が発生しています。ここに使用しようとしている分度器コードは、分度器 - メニュー要素を取得する際に問題が発生する

// globals for second menu 
var mainMenu = element.all(by.id('mainMenu')); 

// Second menu 
this.dashboard = function() { 
    mainMenu.get(0).element(by.linkText('Dashboard')).click(); 
    browser.waitForAngular(); 
} 

this.content = function() { 
    mainMenu.get(1).element(by.linkText('Content')).click(); 
    browser.waitForAngular(); 
} 


describe('Should Test main Navbar functions', function() { 

    it('Dashboard should direct to dashboard page', function() { 
     navbar.dashboard(); 
     expect(browser.getCurrentUrl()).toContain(dashboardUrl); 
    }); 

    it('Content should direct to course page', function() { 
     navbar.content(); 
     expect(browser.getCurrentUrl()).toContain(contentUrl); 
    }) 
}); 

Htmlコンポーネントです。

enter image description here

答えて

1

この試してください:あなたは

this.mainMenu.click(); this.element(by.linkText('Content')).click();

を使用することができ、他のメニューについても同様に

this.mainMenu = element(by.id('mainMenu')); this.mainMenu.click(); this.element(by.linkText('Dashboard')).click();

関連する問題