robot framework clicking on javascript link

2,960 views
Skip to first unread message

Abhijit

unread,
Jan 24, 2015, 12:50:47 PM1/24/15
to robotframe...@googlegroups.com
Hi Robotics,

I am trying to click on java script link but didnt get success, tried with css , sizzle and xpath

following is the snippet -

<li>
<span>
<a href="javascript:void('menuItemWidgetsabaFn_Collaboration_Admin')" onclick="sabaFn_Collaboration_Admin();return false;" title="Social">Social</a>
</span>
</li>

Can you please help me to resolve this

Thanks
Abhijit

Tatu Aalto

unread,
Jan 26, 2015, 11:06:40 AM1/26/15
to abhijit....@gmail.com, robotframework-users

Ugh

Is your problem that you did not find selector for the element or clicking the element did not fire up the JavaScript or something else (please specify what the else is)?

For the first problem one could example use this:
| Click Element | xpath=//a[@title="Social "] |

For the second problem there are numerous reasons, why in some web applications the the JavaScript is not getting executed. Most of them are timing issue which can be handled by polling something on the page. Also your selector may not be unique and you may be clicking wrong element. Also it might be bad implementation in the app side. Consulting your developer is usually the best source of information in these kinds of situations.

-Tatu
Send from my mobile

--
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-u...@googlegroups.com.
To post to this group, send email to robotframe...@googlegroups.com.
Visit this group at http://groups.google.com/group/robotframework-users.
For more options, visit https://groups.google.com/d/optout.

Abhijit Valvekar

unread,
Jan 27, 2015, 12:35:38 PM1/27/15
to Tatu Aalto, robotframework-users
Thanks Tatu,

I found the solution , All link are resides under Frames.worked Select Frame for me.

But now facing one more issue -

When the button is clicked, the popup window appears. When the link from that popup window is clicked, the popup window is closed automatically and go back to the main page.

The problem I have here is that I cannot go back to the main page.

I tried everything gettitle, getidentifier , getwindow but doesn't worked.

Can you please help to resolve this.

getting the below error -

Keyword 'Capture Page Screenshot' could not be run on failure: NoSuchWindowException: Message: Window not found. The browser window may have been closed. Stacktrace:

Thanks,
Abhijit 

Tatu Aalto

unread,
Jan 27, 2015, 4:09:24 PM1/27/15
to Abhijit Valvekar, robotframework-users
Ugh

I do not recall exactly how I did resolve similar problem, few years ago, but far as I recall, I did use the Select Window or Switch Browser keywords. I would first try the Select Window without any arguments.

-Tatu
[1] http://rtomac.github.io/robotframework-selenium2library/doc/Selenium2Library.html#Select%20Window
[2] http://rtomac.github.io/robotframework-selenium2library/doc/Selenium2Library.html#Switch%20Browser

Uri Shatalov

unread,
Jan 28, 2015, 1:17:04 AM1/28/15
to robotframe...@googlegroups.com
Hi Abhijit,

try closing the popup through the following js:

Execute Javascript window.close() -->Closed second window(popup)
Wait Until Keyword Succeeds 30s 1s Select Window ${currentTitle}

where ${currentTitle} is the title of the main page.

Balaji D

unread,
Jul 11, 2020, 7:51:57 PM7/11/20
to robotframework-users
Use below code to click using javascript with XPath in robot framework
 
   ${ele}    Get WebElement    //*[text()='Logout']
   Execute Javascript    arguments[0].click();     ARGUMENTS    ${ele} 
Reply all
Reply to author
Forward
0 new messages