-1

I started to learn ruby (rspec , rubymine). I want to do simple click action but I have a problem. Id and name does not exist so, I should use xpath or css.

I tried #click on contact link:

driver.find_element(:css, 'html>body>footer>div>div>section:nth-child(3)>a:nth-child(1)').click + ' :: absolute path'

xpath showed me:

 /x:html/x:body/x:footer/x:div/x:div/x:section[3]/x:a[1]

link is:

<a href="/k/k.aspx?action=custserv&amp;topic=contact" title="Contakt ">Contact</a>

and this is FIRST link in:

section class="link-block link-collection col-xs-12 col-sm-4 col-md-2"

and section class is placed in div: class="row"

and this is here: <footer class="footer" role="info">

and this is inside: <body data-touch="false" class="abc">

enter image description here

Can anybody help me?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
gadzet
  • 1
  • 1

1 Answers1

0

I used now Css but...it clicks on another links and css is the same! strange..hm css: .footer .container .row .link-block h4 + a

so, how can I do this with xpath?;/ I used @driver.find_element(:xpath, '//html/body/footer/div/div/section[3]/a[1]').click and it works:) but..what if sth will be changed on page?

Justyna J
  • 303
  • 1
  • 3
  • 8