AngularJs Protractor: Element in slide out menu not visible

前端 未结 2 1185
北荒
北荒 2021-01-06 18:40

I\'m back with more Protractor Q&A. So, I am coming across an issue when trying for find an element that is inside a slide out menu.

Snippet of html:

         


        
相关标签:
2条回答
  • 2021-01-06 19:07

    You can also use a promise to wait for the action to complete

    element(by.id('menu')).click().then(function(){
        element(by.id('link')).click();
    });
    
    0 讨论(0)
  • 2021-01-06 19:08

    You need to open up the menu before locating and clicking the submenu:

    element(by.css('nav.menu > md-content')).click();
    element(by.css('nav.menu > md-content > button[ng-click="logoff()"]')).click();
    

    You may also need to use a elementToBeClickable expected condition to wait for the submenu to become clickable (needs protractor 1.7 or above):

    var EC = protractor.ExpectedConditions;
    var logoff = element(by.css('nav.menu > md-content > button[ng-click="logoff()"]'));
    
    browser.wait(EC.elementToBeClickable(logoff), 10000);
    logoff.click();
    
    0 讨论(0)
提交回复
热议问题