2017-02-06 3 views
0

링크를 테스트하기 위해 다른 메뉴 항목을 얻으려고합니다. 드롭 다운을 사용하여이를 수행하는 방법을 알아 냈습니다. 그러나 일반적인 navbar가 문제를 일으키고 있습니다. 다음은 사용하려고하는 각도기 코드입니다.각도기 - 메뉴 요소를 가져 오는 데 문제가 있음

// 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 = element(by.id('mainMenu')); this.mainMenu.click(); this.element(by.linkText('Dashboard')).click();

유사하게 다른 메뉴를 위해 사용할 수있는

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

관련 문제