Click on href

1,672 views
Skip to first unread message

jloyzaga

unread,
May 30, 2016, 12:33:08 AM5/30/16
to robotframework-users
I have retrieved the actual href value for a link I want to click - its coming from a list
I know its there as I do the log to console and I get the href I am expecting yet when I ytr to link it does not likw trhe command
ValueError: Element locator with prefix 'href' is not supported
log to console  "gonna link "${LinkItems[${INDEX}]}
"gonna link "http://www.sit.edptest.info/edphome/home.aspx
\   click element   href=${LinkItems[${INDEX}]}

How can I click on that href???
python 2.7

Thanks
Joe

Kevin O.

unread,
May 31, 2016, 10:11:24 AM5/31/16
to robotframework-users
Try:
Click Link    ${LinkItems[${INDEX}]}
For Click Link, the value of href is one of the key attributes so the page will be searched for an element with a matching href value.

Michał Robaszewski

unread,
May 31, 2016, 11:04:37 AM5/31/16
to robotframework-users
Element locator strategy not define href but link.

So you need change href to link
log to console  "gonna link "${LinkItems[${INDEX}]}
"gonna link "http://www.sit.edptest.info/edphome/home.aspx
\   click element   link=${LinkItems[${INDEX}]}

but then many of this you will get :)
Element locator 'link=http://www.example.com/example' did not match any elements

so you need to check is it visible
${flag}    Run Keyword And Return Status    Wait Until Element Is Visible    //a[@href="${LinkItems[${INDEX}]}"]
Run Keyword If    ${flag}    Click Element    //a[@href="${LinkItems[${INDEX}]}"]


Supported locator strategies you can find in : C:\Python27\Lib\site-packages\Selenium2Library\locators\elementfinder.py

peace out

Ergo Saar

unread,
Jun 3, 2016, 4:01:24 AM6/3/16
to robotframework-users
just FYI... be sure that link element is the real indication og " clicking link". Have faced cases where <a> element is not used as click element ,its parent element was the click element <p>.  But first create Michal "if visible" element poller and then depending its status do next actions :) Insted of using xpath use css locator .try to force developers to put normal "id" to element - make application testable :)
Reply all
Reply to author
Forward
0 new messages