1

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>
asked May 7, 2015 at 3:42

1 Answer 1

1

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);
answered May 7, 2015 at 3:46

3 Comments

Tried this earlier, @Saifur , but no luck. Still it's not clicking.
What error you are getting? Can you provide the stacktrace?
No error, @Saifur , it just doesn't click. No error on the console. Am running out of options now.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.