Replace all hard-coded instance of the the URLs with a variable or a constant. 
Store that different URLs in a hash in a file. Something like this:
URLS = {  dev: 'https://url1.com',  prod: 'https://url2.com'}
Then, in whatever you're using to run the script, add an option to specify the 
environment when running. one way to do it would be to use ARGV. Then run the 
script for the environment, let's say you want "dev":
myscript.rb dev
In the script, assuming that you have access to the URLS constant defined 
above, then you could then get the URL associated with the environment you 
specified at the command line by doing something like this:
TARGET_URL = URLS[ARGV[0].to_sym] 
And then use TARGET_URL wherever you need to call goto in place of the 
hard-coded URL.
There are better ways of doing this but it sounds like you're just looking for 
ideas to start organizing, HTH.
John
    On Thursday, March 24, 2022, 08:22:34 AM PDT, perg...@gmail.com 
<pergeg...@gmail.com> wrote:  
 
 Hi,
I'm using watir ruby for my testing I have quite lot f script written for a 
website and sometimes I have test in different environment like UAT or DEV 
site. At the moment my setup method below are in the same file as my test 
scripts. @browser  = Waitr::Browser.new..... @browser.goto "https...."
I want to be able to change the goto website just one time instead going to 
each file to change it everytime. I have tried move the above code to a 
different file and use the require ''...." method in the test script file but 
it doesn't work. 
Any advice on how can to call the @browser.goto from another file? 
Thanks
   

-- 
-- 
Before posting, please read 
https://github.com/watir/watir_meta/wiki/Guidelines-for-Posting-to-Watir-General-Google-Group.
 
In short: search before you ask, be nice.
 
watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com
--- 
You received this message because you are subscribed to the Google Groups 
"Watir General" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to watir-general+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/watir-general/74dc7e5e-6138-47ca-9422-9e2ee41f1e10n%40googlegroups.com.
  

-- 
-- 
Before posting, please read 
https://github.com/watir/watir_meta/wiki/Guidelines-for-Posting-to-Watir-General-Google-Group.
 
In short: search before you ask, be nice.

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com
--- 
You received this message because you are subscribed to the Google Groups 
"Watir General" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to watir-general+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/watir-general/1941191164.154348.1648180045768%40mail.yahoo.com.

Reply via email to