-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
  • 145
  • 3
  • 11
  • 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. – Mateusz Ostaszewski 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
  • 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,607
  • 2
  • 15
  • 36