selenium2library and click link

6,222 views
Skip to first unread message

majatalo

unread,
Apr 23, 2013, 3:47:39 PM4/23/13
to robotframe...@googlegroups.com
Hi
I use selenium2library and trying to click link on webpage
 that is <a href target=_blank
page is .php
and after that it has question mark with variable passing value to next page

example <a target="_blank" href="http://test.php?SOMETHING=123456">something=123456</a>

I try do
click link    something
or
click link http://test.php?SOMETHING=123456

both give error
ValueError: Element locator with prefix 'blah blah '  is not supported

is that '=' char making things not working?

Teppo Testaaja

unread,
Apr 24, 2013, 7:09:29 AM4/24/13
to robotframe...@googlegroups.com
These should work:

ClickLink    something=123456
ClickLink    hfef=http://test.php?SOMETHING=123456
ClickElement    xpath=//a[text()[contains(.,'something')]]

Br,
Teppo

Kevin O.

unread,
Apr 24, 2013, 10:58:10 AM4/24/13
to robotframe...@googlegroups.com
I just recently logged an issue about this. Currently you cannot use the default strategy for locating elements if you have a = in your locator, so you are correct. You must use a locator prefix.
Try:
Click Link    link=something=123456    # matching link text
or
Click Link    xpath=//a[@href='http://test.php?SOMETHING=123456']

Kevin

majatalo

unread,
Apr 24, 2013, 11:42:34 AM4/24/13
to robotframe...@googlegroups.com
Thanks
    click link   link=${url}
worked

Ed Manlove

unread,
Apr 24, 2013, 1:34:53 PM4/24/13
to robotframe...@googlegroups.com
Is the error really contain 'blah blah'? Just verifying via grep I don't
see that in our code. And by putting in blah blah in the middle of the
error message your removing some real helpful information that we could
use to help you.

Ed

Kevin O.

unread,
Apr 24, 2013, 6:22:21 PM4/24/13
to robotframe...@googlegroups.com
Ed, you certainly have a valid criticism here. It is nice to post logs or text pasted from logs, but I think Teppo was describing a general problem.
On the issue I referenced earlier there is code for a public website and exact error text. The code is for Click Image, but the issue is the same.
I mentioned 3 possible solutions and would like to know what you think is the best after you are done with the chicken coop.

Kevin

Ed Manlove

unread,
Apr 25, 2013, 8:20:00 AM4/25/13
to kir...@gmail.com, timo.t...@gmail.com, korm...@gmail.com, robotframework-users
My apologies.  It was a valid question and Kevin did gracefully answer the question before I wrote my comment. What I wrote wasn't helpful nor necessary and again I apologize.

Ed

majatalo

unread,
Apr 26, 2013, 2:13:55 AM4/26/13
to robotframe...@googlegroups.com
yes, there was actual more information instead of 'blah blah', but i tought it was irrelevant.
when I got that part of script working, I noticed what possible problem was.



first my code was
  click element   ${URL}       

let assume that ${URL} is http://test.php?SOMETHING=123456 

and the error message was
ValueError: Element locator with prefix 'http://test.php?SOMETHING='  is not supported

at the beginning I did not paid any attension that everything after "=" was missing.

when I tested Kevins version
click element   link=${URL}
and it worked I figured that since URL contains "=" char robot tries to use beginning as locator like link, value, id and everything that comes after "=" is actual locator
when you add link= at beginning robot reads URL correctly.

So, Again big thanks to Kevin who helped me to fix my script and also understand robot in general little better.

Rubien Grootfaam

unread,
Jul 10, 2014, 3:05:42 AM7/10/14
to robotframe...@googlegroups.com
Hi, 

I got the same problem, when i'm trying to open a link in de mail of my mailbox.

This is my script:
Open Bevestigingsmail In Mailbox
    [Arguments]            ${SENDER}         ${SUBJECT}                
    Log                    ${SENDER}
    Log                    ${EMAIL}
Log   ${SUBJECT}
    ${LATEST}=             Wait for Mail                    fromEmail=${SENDER}     timeout=10
    #check het laatste emailtje van afzender ${SENDER}, wacht maximaal 10 seconden, anders wordt een timeout gegeven
    ${parts}=              Walk Multipart Email                 ${LATEST}
    @{fields}=             Get Multipart Field Names
${from}=   Get Multipart Field From  
${to}=   Get Multipart Field To  
${SUBJECT}=           Get Multipart Field Subject 
${Date}=           Get Multipart Field Date
    ${payload}=       Get Multipart Payload        decode=True
#De body van de email wordt in  ${payload} gezet
    @{WORDS}=              Split String                     ${payload}
#${payload} wordt omgezet naar woorden in de array @{WORDS}
        ${LINK}=           Get From list ${WORDS}      24
Click Link         ${LINK}

My question is how can i rewrite the BOLD part of my script without getting the next error:
ValueError: Element locator with prefix 'https://forexample/teamsheldon/sprint11/servicecentre/?mod' is not supported

When i look at the error, i can see a part of my link is missing, this part is changing everythime so i can not put the link hard coded in a varible.

I try to use Kevins example but it doesn't work for me or i'm doing something wrong. 

Can someone plese help me?

Regards, 
Rubiën 

Op dinsdag 23 april 2013 21:47:39 UTC+2 schreef majatalo:

Kevin O.

unread,
Jul 10, 2014, 7:53:50 AM7/10/14
to robotframe...@googlegroups.com
Try specifying a strategy instead of using the default. It looks like you are matching on the href attribute, so try:
    Click Link    xpath=//a[@href="${LINK}"]
Reply all
Reply to author
Forward
0 new messages