1

HTML Code:

<button onclick="root.handleOnClick( document, this );" id="Edit_edit::0" 
title="Edit" name="Edit_edit::0" class="navbar-btn btn btn-default btn-sm cs-btn" 
type="button">Edit</button>

XPath which I used:

driver.findElement(By.xpath("//button[@title='Edit']")).click();

Please help me to run this code.

  • use javascriptexecutor to click the button – Vel Guru Oct 17 '18 at 6:23
  • You say you have the frames. Tell us what is the frame structure that holds your button? Is there just a frame that holds your button or frame that contains another frame that holds your button? Also show us frame html elements. – Alexey R. Oct 17 '18 at 9:25
  • Your question is not clear and lacks essential details necessary to provide an good answer sqa.stackexchange.com/help/how-to-ask – Martin Spamer Oct 17 '18 at 14:41
1

Try the below code to click button.

WebElement element=driver.findElement(By.xpath("//button[@title='Edit']"));
JavascriptExecutor js = (JavascriptExecutor)driver;
js.executeScript("arguments[0].click();", element);
| improve this answer | |
  • Thanks for your code.I tried it,but its not working.There is frames,forms in my working site.Whether we have to first write code for frames,forms. – Sathiya Priya Oct 17 '18 at 9:15
1

If there is a frame in the page you need to switch into the frame first and then you can access the button by using your xpath.

To switch into the frame use below command

driver.switchTo().Frame(id or class); 
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.