A
A
A_Modestov2016-06-27 16:31:56
css
A_Modestov, 2016-06-27 16:31:56

How to check if an element exists in Capybara + selenium page?

Welcome all. Such a problem:
there is a call to the capybara method: How to make it so that in the absence of an element on the page not to run into an error
shares = session.find("a.UFIShareLink")

Capybara::ElementNotFound: Unable to find css "a.UFIShareLink"

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Evgeniy _, 2016-06-27
@A_Modestov

begin  
  shares = session.find("a.UFIShareLink")
rescue Exception => e  
  puts e.message   
end

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question