Automate Search Result Validation

A friend of mine was testing something related to search results.  He passes in a dynamic argument to search on and then validates that this same argument is returned in the result.

I ended up doing this and it solved his problem:

a = @browser.div(:class => "gs-title").a(:class => "gs-title").text
puts a ## Did that to verify we were getting some text back in the search result
string_match = term  ## term is my argument I'm passing in.
assert_match(string_match, a)

Initially the above failed, but it was close. the failure was that the argument was coming through with double quotes… so it was looking for “Jets” in a phrase: The Jets…

I removed it, and also downsized the text we were capturing for compare:

a = @browser.div(:class => "gs-title").a(:class => "gs-title").text
puts a
string_match = term.gsub /"/, ''
assert_match(string_match.downcase, a.downcase)

I read up on http://stackoverflow.com/questions/4720401/remove-double-quotes-from-string to remove double quotes using gsub.  Then used .downcase on what we are comparing to.

The result worked now with jets being compared to: the jets…

 

Automate Search Result Validation
User Rating: 4.6 (1 votes)