angularjs e2e - Struggling with Protractor menu clicks -


so protractor select looks this:

element(by.css('#themenu > ul > li.rmitem.rmfirst > span')).gettext().then(function(txt){         console.log('**** have menu !!!! ****');     }); 

and dom structure looks :

<div id="themenu">  <ul class="rmrootgroup rmhorizontal">      <li class="rmitem rmfirst" style="z-index: 0;">          <span class="rmlink rmrootlink rmexpand rmexpanddown" tabindex="0">my reports</span><div class="rmslide">              <ul class="rmvertical rmgroup rmlevel1">                  <li class="rmitem rmfirst">                      <span class="rmlink rmexpand rmexpandright" tabindex="0">                          <span class="rmtext">first dropdown menu</span>                      </span><div class="rmslide">                          <ul class="rmvertical rmgroup rmlevel2">                              <li class="rmitem rmfirst"><span class="rmlink" tabindex="0"><span class="rmtext">first menu item</span></span></li>                              <li class="rmitem rmlast"><span class="rmlink" tabindex="0"><span class="rmtext">second menu item</span></span></li>                          </ul>                      </div>                  </li>                  <li class="rmitem ">                      <span class="rmlink rmexpand rmexpandright" tabindex="0" style="width: 105px;"><img alt="" src="images/foldericon.gif" class="rmleftimage"><span class="rmtext">second dropdown menu</span></span><div class="rmslide">                          <ul class="rmvertical rmgroup rmlevel2">                              <li class="rmitem rmfirst"><span class="rmlink" tabindex="0"><span class="rmtext"> first item of second </span></span></li>                          </ul>                      </div>                  </li>                  <li class="rmitem rmlast">                      <span class="rmlink" tabindex="0" style="width: 105px;">                          <span class="rmtext">last menu item</span>                      </span>                  </li>              </ul>          </div>      </li>  </ul>  </div>

and i'm using protractor try , click in order :

1) reports

2) first dropdown menu

3) first menu item

however, i'm getting cmd prompt error when running protract test:

    stack: nosuchelementerror: no element found using locator: by(css selector,   #themenu > ul > li.rmitem.rmfirst > span) 

using chrome console tools, using jquery selector below :

 $('#themenu > ul > li.rmitem.rmfirst > span')[0] 

does return this:

my reports

so i'm running issue correct protractor selection. element.all() giving me issue. not sure why.

help appreciated...

bob

---- update ----

for benefit of using protractor, clicking menus, , dealing multiple browser windows, etc.

nb: still not crazy how i'm handing getallwindowhandles().then. i'm thining of doing handles.foreach() read thru them...

var submitelement = element(by.id('bthlogin'));            submitelement.click().then(function () {          browser.sleep(200);          browser.waitforangular();          console.log("login sucessfully");                  browser.waitforangular();            //browser.wait(ec.presenceof(elem), 2000);  // still testing line...            browser.getallwindowhandles().then(function (handles) {              console.log('---->win 0: ' + handles[0]);               console.log('---->win 1: ' +  handles[1]);                                                                   browser.driver.getcurrenturl().then(function(curr){                  console.log('curr url: ' + curr);                  if (curr.indexof('loginmsg.aspx') >= 0){                      // close login successful browser window !!                      browser.driver.close();                  }              });                            browser.driver.switchto().window(handles[1]);              browser.driver.getcurrenturl().then(function(curr){                  if (curr.indexof('default.aspx') >= 0){  			console.log('this our main application window !!!');                                      }                 });                                  });                    var sel = '#themenu > ul > li:first-child';            elem = element(by.css(sel));          elem.click().then(function(){            });            browser.pause();                             });

here guess - timing issue , need wait visibility of element:

var ec = protractor.expectedconditions; var elm = $('#themenu > ul > li.rmitem.rmfirst > span');  browser.wait(ec.visibilityof(elm), 5000); elm.gettext().then(console.log); 

also, relevant link close window you've got:


Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -