I have a class which checks to see if a page title exists. I need to execute it several times. In every case I operate in different levels of ie – ie1, ie2. In my code I check $ie, how can I generalize this for $ie1 and so on?
class Text_neg
def initialize(text, object)
@text=text
@object=object
if $ie.contains_text(@text)
puts("Test for " + @object + " failed")
puts ($ie.link(:text => /Exception:/))
h= $ie.link(:text => /Exception:/)
$r.addtoReport($testReport, "check " + @object, "FAILED", h.text)
else
puts("Test for " + @object + " passed")
$r.addtoReport($testReport, "check " + @object, "PASSED", "Test for " + @object + " passed" )
end
end
end
When you initialize your Text_neg class, you should pass in the ie object you want to use. Then the Text_neg can store it in a variable that it knows about and does not have to be incremented for each ie object.
It would look something like:
Then to run this for each IE object, you would do: