selenium - How do i extract extract all 'a' tags with attribute 'title' from li -


how extract tags title value. following xml structure. ultopmenu hover dropdown. using protractor.

<ul id="ultopmenu"> <li> <li> <li>     <ul class="submenu">         <li>             <a href="" title = "test2"></a></li>         <li>             <a href ="" title = "test1" ></a></li>     </ul>  </li> </ul> 

following tried

var menus = element.all(by.css('#ultopmenu > li'));     var submenu = element.all(by.css('#ultopmenu > li .submenu li')).all(by.tagname('a'));     browser.actions().mousemove(menus.get(3)).perform().then(function () {         submenu.filter(function (elem, index) {             return elem.getattribute('title').then(function (val) {                 return val === 'test1'             })         }).first().click(); 

it return me error saying element not visible

it difficult debug without executing code , seeing happening, here educated guess - should not first open dropdown itself:

var dropdown = element(by.id("ultopmenu")); var submenu = dropdown.$("ul.submenu"); var desiredmenuitem = submenu.$('li > a[title=test1]');  browser.actions()     .mousemove(dropdown)     .mousemove(submenu)     .click(desiredmenuitem)     .perform() 

note how i'm locating link title css selector.

and, note assumptions made when applying actions - see if need change way dropdowns open - via mouse move or click.

you may need add delays between actions - we've been using custom sleep() browser action in similar cases.


if need extract link texts attribute title:

$$("#ultopmenu ul.submenu li > a[title]").gettext().then(console.log); 

Comments

Popular posts from this blog

What is happening when Matlab is starting a "parallel pool"? -

angular - DownloadURL return null in below code -

php - Cannot override Laravel Spark authentication with own implementation -