Querying

What is Querying?

Querying

 

This section is all about Querying. But before this, let’s have a look at Capybara. Certainly, it provides developers to simulate a user on a web page as well as make assertions based on the content and environment of the page. In addition, it also offers an API to interact with the web page. Further, let’s check out DSL.

DSL stands for Digital Subscriber Line. Moreover, users get a high-speed bandwidth connection from a phone wall jack on an existing telephone network. Not to mention, it also works within the frequencies that the telephone doesn’t. Therefore, you can use the Internet while making phone calls. In the same vein, DSL utilizes telephone wires, which makes sense that the biggest providers are telephone companies.

Now, let’s understand this section. Full reference: Capybara::Node::Matchers

Capybara has a rich set of options for querying the page for the existence of certain elements and working with and manipulating those elements.

page.has_selector?(‘table tr’)

page.has_selector?(:xpath, ‘//table/tr’)

 

page.has_xpath?(‘//table/tr’)

page.has_css?(‘table tr.foo’)

page.has_content?(‘foo’)

 

On one hand, the negative forms like has_no_selector? are different from not has_selector?. Further, read the section on asynchronous JavaScript for an explanation.

You can use these with RSpec’s magic matchers:

 

expect(page).to have_selector(‘table tr’)

expect(page).to have_selector(:xpath, ‘//table/tr’)

 

In addition, expect(page).to have_xpath(‘//table/tr’)

expect(page).to have_css(‘table tr.foo’)

expect(page).to have_content(‘foo’)

Make your resume stand out and become a Certified Capybara Testing Professional. So, Try free practice tests here!

A great career is just a certification away. So, practice and validate your skills to become Certified Capybara Testing Professional

Interacting with forms
Finding

Get industry recognized certification – Contact us

keyboard_arrow_up