I'm trying to write test the value of alt text + src of an image using capybara and the css selectors.
any idea s to test both in single xpath ?
A slightly simpler way will be to use an id for that image:
page.find('#profile-avatar')['src'].should have_content 'default.png'
Updated for rspec 3:
expect(page.find('#profile-avatar')['src']).to have_content 'default.png'
expect(page.find('#profile-avatar')['alt']).to match(/some-value/)
variable=find(:xpath, "//img[@class='class_name']")
variable['src'].should == "url"
variable['alt'].should == "text"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With