Search code examples
rubyseleniumcapybara

How do I store a value from an Element in Capybara/Ruby?


How do I store the '23 results' in a variable?

<span dir="auto">23 results</span>

Solution

  • You can try the below code :

    element = browser.find_element(:css,"span[dir='auto']").text
    

    if you print element you should get 23 results