-2

I am new to selenium. Trying to Automate form filling using selenium. I need to click a button with following tag.

<a class="urLink urT" id="mq120h" ct="LN" lsdata="{0:'Move\x20Left',1:'Back',4:true,7:'ESCAPE'}" lsevents="{Activate:[{ResponseData:'delta',ClientAction:'submit'},{}]}" tabindex="0" ti="0" title="Move Left (Escape)" href="javascript:void(0);" ondragstart="var e=window.event;e.cancelBubble=true;e.returnValue=false;return false;" style="white-space:nowrap;"><img border="0" align="absmiddle" src="/sap/return.gif" alt="Move Left" ondrag="return false">&nbsp;Return</a>    

I am unable to understand what are these attributes "lsdata" and "lsevents" in the above .../ tag doing. Whether they are creating any dynamic link? How I can execute the same thing using script executor functions in Selenium.

I don't want to click using the FindElement() method as the element (button) is deeply nested in a table. Thanks

indra
  • 135
  • 3
  • 10
  • You can click a button by using javascript `driver.execute_script('your script here')` but please post whole source code because maybe there is a better way to do it. – mostaszewski Sep 25 '17 at 15:54
  • My understanding is this tag is calling some function to create link. How can I do it through selenium? – indra Sep 25 '17 at 16:37
  • See: [How do I do X?](https://meta.stackoverflow.com/questions/253069/whats-the-appropriate-new-current-close-reason-for-how-do-i-do-x) The expectation on SO is that the user asking a question not only does research to answer their own question but also shares that research, code attempts, and results. This demonstrates that you’ve taken the time to try to help yourself, it saves us from reiterating obvious answers, and most of all it helps you get a more specific and relevant answer! See also: [ask] – JeffC Sep 25 '17 at 17:46
  • Possible duplicate of [How to click an element in Selenium WebDriver using JavaScript](https://stackoverflow.com/questions/11947832/how-to-click-an-element-in-selenium-webdriver-using-javascript) – JeffC Sep 25 '17 at 17:46
  • I suspect this is a SAP interface and the element does not respond to selenium clicks. Have you found a solution? – Ronan Paixão Nov 13 '19 at 17:57

1 Answers1

0

Use like this

 WebDriver driver = new FirefoxDriver();
 JavascriptExecutor jse = (JavascriptExecutor)driver;
     jse.executeScript("document.getElementById('link name or Id').click();");
iamsankalp89
  • 4,363
  • 2
  • 13
  • 35