Reputation: 27
Need to click on New button. How do I proceed with it, as it's not displayed/visible? This is the concerned code-
<li tabindex="-1" class="ms-crm-CommandBarItem ms-crm-CommandBar-Menu ms-crm-CommandBar-Button" title="NewCreate a 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-Menu-Label ms-crm-CommandBar-Button" 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>
Upvotes: 1
Views: 577
Reputation: 16201
Since, it is hidden the only way to click the element is to execute the javascript
and perform click with javascript executor.
I assumed you are using Selenium java binding since you have not mentioned that.
//Find the element to click on.
//Selenium will find the element without any issue
//since it is present in the DOM
//I assumed you want to click on the <code>span</code> with text New
//since there is no actual button
WebElement element = driver.findElement(By.cssSelector("[title='NewCreate a new Account record.']>span>a>span"));
JavascriptExecutor jsExecutor = (JavascriptExecutor)driver;
jsExecutor.executeScript("arguments[0].click();", element);
Upvotes: 1