Capybara: is it possible to get an attribute value from a css string?

后端 未结 3 1226
悲哀的现实
悲哀的现实 2020-12-14 16:17

If I\'ve got some HTML like:

I\'ve seen that I

相关标签:
3条回答
  • 2020-12-14 16:32

    The only way I have been able to do this is with jQuery.

    href = page.evaluate_script("$('a.link_class').attr('href');")
    
    0 讨论(0)
  • 2020-12-14 16:41

    If you are looking for an HTML element with a given value for a given attribute, you could do:

    expect(page).to have_css('a[href="www"]')
    
    0 讨论(0)
  • 2020-12-14 16:53

    Probably too late. But I also had the same problem and found the solution. It might help someone else.

    page.find('div#drawer a')[:href]
    
    0 讨论(0)
提交回复
热议问题