in ,

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…

What do you think?

0 points
Upvote Downvote

Total votes: 0

Upvotes: 0

Upvotes percentage: 0.000000%

Downvotes: 0

Downvotes percentage: 0.000000%

Written by Admin

I work for a Telecom company writing and testing software. My passion for writing code is expressed through this blog. It's my hope that it gives hope to any and all who are self-taught.

Comments

Leave a Reply

Loading…

Python: Removing a Value from a List

Python: While