简体   繁体   English

Watir并将代码存储在变量中

[英]Watir and storing code in a variable

I have stored Watir syntax in a global variable under the tag of Err_Rout . 我将Watir语法存储在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 干杯

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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