2

What i'm trying to do is to get an element out of a list. I want to take the text in a link and click on the link if it contains the right text. this is the html-code:

<table>
     <tr>
        <td><a href='...'>I need help</a></td>
        <td><a href='...'>Oh hello</a></td>
        <td><a href='...'>Lorem ipsum</a></td>
     </tr>
</table>

I tried this:

.click('table > tr > td > a:contains("I need help")')

But for some reason it doesn't work.

I can't use this:

.click('table > tr > td:nth-child(1) > a)

because there will be added more tr tags as the site gets bigger.

Any ideas ?

Sten Pelzer
  • 499
  • 2
  • 19

2 Answers2

1

First of all, your HTML code is a bit twisted; a has to be a child of an element, not the way around. I suggest to read the MDN Docs regarding elements.

Regarding your problem with Dalek; Dalek uses the CSS selector engine of the browser that it executes. This will change in the future (Replaced by Sizzle as a unified selector engine), but I have no estimation when this future exactly will be.

Regarding the :contains() pseudo selector - As far as I know, this is gone. The current CSS3 spec has removed it & therefor you can't use that in your Dalek selectors.

jordy korsten
  • 170
  • 14
0

I cannot find a way to check link text, but if you know href, try to use it instead

.click('a[href="uniqueURL"]')
dmpost
  • 76
  • 5
  • i tried that too but the problem is that my site creates the href itself, all starting the same, and ending with something like /231983nkjdasbdin2983u1ndsaknn1 , and everytime i patch it there will be a new link for every href. – Sten Pelzer May 15 '14 at 12:57
  • I faced the same problem, but it seems (https://github.com/dalekjs/dalek/issues/3) we are limited to standard CSS selectors - http://www.w3.org/TR/css3-selectors/#selectors – dmpost May 15 '14 at 14:08
  • thank you for the help, i now see that there really is no way doing this. Hope it will be added soon, would be really helpful! – Sten Pelzer May 15 '14 at 14:14