integration testing - Rails test with Capybara check if attribute of an element present or not -
i need find weather no-follow link exists in external email , should not in internal email.
test "should have nofollow in external links , not in internal links in comment" visit @game_path fill_in('comment_comment', :with => 'please click link <a href='http://www.internallink.com/soccer'> internal link <a/> , click external link <a href='http://www.google.com'> external link <a/> click_button('submit_comment') assert page.has_no_css?('div.error'), "error div found on page after posting comment" assert page.has_content?('please click link '), "comment not found on page after posting" ext = find(:xpath, "//a[@href='http://www.google.com']") assert_equal(ext['rel'], "nofollow") internal = find(:xpath, "//a[@href='http://www.internallink.com/soccer']") assert_equal(internal.try(:rel), nil) end
it giving error in assert_equal(int.try(:rel), nil)
. can anybuddy guide me solution?
my final goal test in user comment, external link should have rel='nofollow' attribute present or not?
why not check presence of link without rel='nofollow'?
find(:xpath, "//a[@href='http://www.internallink.com/soccer' , @rel != 'nofollow']")
Comments
Post a Comment