How would one locate following object [ul, li] in selenium webdriver? -
could me in figuring out how proceed locating "new" using selenium webdriver in java.
code snippet:
<ul class="ms-crm-commandbar-menu"> <li tabindex="-1" class="ms-crm-commandbaritem ms-crm-commandbar-menu ms-crm-commandbar-button" title="new create new account record." id="account|norelationship|homepagegrid|mscrm.homepagegrid.account.newrecord" command="account|norelationship|homepagegrid|mscrm.newrecordfromgrid" style="white-space: pre-line; display: inline-block;"><span tabindex="-1" class="ms-crm-commandbar-button ms-crm-menu-label" style="max-width:200px"><a tabindex="0" class="ms-crm-menu-label" onclick="return false"><img tabindex="-1" class="ms-crm-imagestrip-new_16 ms-crm-commandbar-image16by16" src="/_imgs/imagestrips/transparent_spacer.gif" style="vertical-align:top" alt="new"> <span tabindex="-1" class="ms-crm-commandbar-menu" style="max-width:150px" command="account|norelationship|homepagegrid|mscrm.newrecordfromgrid"> new </span> </a> </span> </li>
disclaimer: i'm using c# shouldn't make difference.
the easiest using cssselector
. it's bit verbose in case, doesn't matter:
driver.findelement(by.cssselector("span[command=\"account|norelationship|homepagegrid|mscrm.newrecordfromgrid\"]"));
this find span
element contains nothing text want. assuming command unique on page, otherwise you'll need refine.
alternatively can use xpath achieve same:
driver.findelement(by.xpath("//span[@command='account|norelationship|homepagegrid|mscrm.newrecordfromgrid']");