简体   繁体   中英

Watir and storing code in a variable

I have stored Watir syntax in a global variable under the tag of Err_Rout . The code I have stored is accessible as I can print it out in the command prompt window, and it does work generically.

What I want to do is call the tag in the script and then script runs this code. Does anyone have any ideas on how I can do this? is it even possible?

Here is my stored syntax-

if browser.text.include?("Error") 
  then print "\n\nFail\t" 
  else print "\n\nPass\t" 
end

Anyone who wants to know its -

def errorSearch(obj,rgn)
  if obj.text.include?("Error") then
     obj.screenshot.save ("#{rgn}_Error.png")
     print  "\n\nI have Found an Error...Dont Panic!!!\t" 
 else
     print "\n\nNo Error Found\t" 
 end  
end

And to call the method -

errorSearch(browser,region)

Cheers

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM