Can't extract url value from ahref to variable

Hi,

This is my HTML

<td><span><a href="www.myurl.com">MyText</a><br></span></td>

I can extract “MyText” using:

${mytext}    get text    xpath://div/table/tbody/tr[1]/td[7]/span/a

but I cannot extract the url from this table cell, I have tried:

${myurl}    get value    xpath://div/table/tbody/tr[1]/td[7]/span/a

and

${myurl}    get element attribute    xpath://div/table/tbody/tr[1]/td[7]/span/a

this is the full xpath to the ahref using chrome dev tools:

/html/body/app-root/body/div/div[2]/app/div/p-table/div/div/table/tbody/tr[1]/td[7]/span/a

any ideas what I am doing wrong thank you.

Maybe there’s some bit missing in this code snippet - I don’t see the attribute argument there.

https://robotframework.org/SeleniumLibrary/SeleniumLibrary.html#Get%20Element%20Attribute

Please give an example I am confused.

For example:

${attribute}=    Get Element Attribute    css=a    href
1 Like

Thank you this was what I needed, you are a genius, I wish I was better at coding and I didn’t have to waste your time.

I like helping others - I don’t see it as a waste of time. :smiley:

Coding, like all other things, takes some practice. You’ll get better at it the more you do it. Good luck!

1 Like