Note that there are some explanatory texts on larger screens.

plurals
  1. POUsing a var to complete watir agent
    primarykey
    data
    text
    <p>I am working on a way to share a Ruby program. This is my test code. </p> <pre><code>require 'rubygems' require 'watir-webdriver' require 'headless' require 'google_drive' @browsertype ="" @name ="" @champsname = "" @date = DateTime.now file = File.exists?("temp.txt") if file == true input = IO.read("temp.txt") input_hash = Hash[*input.gsub(/"/,"").split(/\s*[\n=]\s*/)] browsertype = input_hash.shift name = input_hash.shift champsname = input_hash.shift @browsertype = browsertype[1] @name = name[1] @champ = champsname[1] end if file == false f = File.new("temp.txt", "w") # processing puts "What browser will you be using? " browsertype = gets f.write("browser = :") f.write(@browsertype) puts "What is your name? " name = gets f.write("name = ") f.write(@name) puts "what is your champs name" champsname = gets f.write("champion = ") f.write(@champsname) @browsertype = browsertype @name = name @champ = champsname end puts @browsertype puts @name puts @champ puts @date #@b = "Watir::Browser.new :"+@browsertype agent = Watir::Browser.new @b = agent+@browsertype #b = @b #b.goto 'https://docs.google.com/spreadsheet/ccc?key=0AncPM9_7wL02dHVaSWg5eklfYW5jdTE3NGtJSGJPb3c' </code></pre> <p>I used this question as a reference for making var out of files, <a href="https://stackoverflow.com/questions/1577542/variables-magic-and-read-from-file">Variables magic and read from file</a>. I want my friends to be able to use the finished product by using orca <a href="https://stackoverflow.com/questions/348919/building-a-windows-executable-from-my-ruby-app">Building a Windows executable from my Ruby app?</a>. The problem I have been encountering is Watir runs Firefox by default when you use</p> <pre><code>agent = Watir::Browser.new </code></pre> <p>But not everyone uses Firefox, so this is why I created the browsertype in the file. But when I use </p> <pre><code>@b = "Watir::Browser.new :"+@browsertype </code></pre> <p>I get an error saying that the <code>+string</code> is invalid and I get the same for symbol. Does anyone have any suggestions on how I can have a user defined browser type?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload