Manmeet
Manmeet

Reputation: 271

Understanding the meaning of the capybara syntax

I want to understand what the following Capybara syntax means -

find(:xpath, '//*[@id="application-lines"]/div[2]/ul/li[2]/a').click

I particularly don't understand the second attribute of the find method.

It would be great if someone could help me understand the syntax!

Upvotes: 1

Views: 78

Answers (1)

Federico Nafria
Federico Nafria

Reputation: 1600

That is not something specific of Capybara, that is an XPath, is used to navigate the elements of an XML document.

In this case is looking for a node with id application-lines and inside that element retrieving the second div[2], with an ul element from which retrieves the second li and retrieves the a element inside it. All this ends up doing is a click on the a element found.

You can learn about XPaths here: XPath tutorial

Upvotes: 1

Related Questions