findBy(xpath) with contains(@href,...) has anyone got it ever working ?

1,132 views
Skip to first unread message

Christophe Boschmans

unread,
Nov 14, 2013, 9:37:49 AM11/14/13
to seleniu...@googlegroups.com
  • finding an element with xpath=..contains(@href)... never seems to work for me tried it many times i always ended up using text().
  • is there somekind of selenium bug involved?
  • Firepath has no problem with finding the right element but selenium always returns <undefined element>,  elementnotvisibleException

Atul Mahajan

unread,
Nov 15, 2013, 5:45:44 AM11/15/13
to seleniu...@googlegroups.com
Try using Xpath Relative Path... It will works.

murali

unread,
Nov 15, 2013, 7:18:46 AM11/15/13
to seleniu...@googlegroups.com
Hi,

i am not used contains for href. i used to write xpath like //a[@href='/your href url here'] for href attribute. It always works for me.

Thanks,
Murali

Dmitry Munda

unread,
Nov 15, 2013, 7:32:28 AM11/15/13
to seleniu...@googlegroups.com
This works for me
driver.findElement(By.xpath("//a[contains(@href, 'somejsp.jsp?someID_id=" + someId + "')]"));
Message has been deleted

Christophe Boschmans

unread,
Nov 15, 2013, 8:02:31 AM11/15/13
to seleniu...@googlegroups.com
i tried the solution you suggested with the relative path // and @href= but no luck.
But if these solutions work for you guys then it must have  to do something  with the url starting with  a numeric ip address.
I do not have control over the name giving of the server so ..
  But does selenium use some kind of DNS translation? One that is adjustable like in a config file or something like that?

PS:I double posted the post today. Sorry about that, i didn't know for sure this post was actually posted

Op vrijdag 15 november 2013 13:18:46 UTC+1 schreef murali:
Reply all
Reply to author
Forward
0 new messages