I used to test a Java app and as part of that I'd read in the app's properties
because I used a few of them. It's not too hard to write something once you get
comfortable with all of the string parsing methods. I just wrote this:
def read_properties(path)
arr = File.read(path).split("\n")
arr.each do |line|
unless line.strip.index('#') == 0
line.match(/(\S+)\s*=\s*(\S+)/)
if $1 and $2
Object.const_set($1.upcase, $2)
end
end
end
end
But there are plenty of things you can grab off the web. This is a common
problem. Just google ruby read properties for more, probably better solutions.
There are probably areas where the one above will fail.
________________________________
From: Jim Bailey <[email protected]>
To: [email protected]
Sent: Wednesday, June 5, 2013 8:52 AM
Subject: Re: [wtr-general] Can't use = sign in URL.
For now, can I forget about the properties file, and have the Watir script put
the url directly in the address bar?
If that is possible I'll need the commands to do so.
I got nowhere with the links you sent.
When I add p properties.getUrl to my script the output is there minus anything
to the right of the left most equal sign.
Turns from this:
http://FooBar.com/AP/quote?source=club&aaaclubcode212&state=CA&zipcode=90210
To:
http://FooBar.com/AP/quote?source
So it is ignoring all the the right of the equals sign as I expected.
On Tue, Jun 4, 2013 at 4:19 PM, Željko Filipin <[email protected]> wrote:
On Tue, Jun 4, 2013 at 8:26 PM, Jim Bailey <[email protected]> wrote:
>
>b.goto(properties.getUrl)
>Add this before above line:
>
>
>p properties.getUrl
>
>That will display the contents of the variable. That is always helpful when
>debugging.
>
>
>The magic word is probably URL encoding[1].
>
>Something like this should fix the problem:
>
>b.goto(URI.escape(properties.getUrl))
>
>More information:
>http://www.ruby-doc.org/stdlib-1.9.3/libdoc/uri/rdoc/URI/Escape.html#method-i-escape
>
>Željko
>--
>1: http://en.wikipedia.org/wiki/Percent-encoding
> --
>--
>Before posting, please read http://watir.com/support. In short: search before
>you ask, be nice.
>
>[email protected]
>http://groups.google.com/group/watir-general
>[email protected]
>
>---
>You received this message because you are subscribed to a topic in the Google
>Groups "Watir General" group.
>To unsubscribe from this topic, visit
>https://groups.google.com/d/topic/watir-general/u5fJr43D74Y/unsubscribe?hl=en.
>To unsubscribe from this group and all its topics, send an email to
>[email protected].
>For more options, visit https://groups.google.com/groups/opt_out.
>
>
>
--
--
Before posting, please read http://watir.com/support. In short: search before
you ask, be nice.
[email protected]
http://groups.google.com/group/watir-general
[email protected]
---
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 [email protected].
For more options, visit https://groups.google.com/groups/opt_out.
--
--
Before posting, please read http://watir.com/support. In short: search before
you ask, be nice.
[email protected]
http://groups.google.com/group/watir-general
[email protected]
---
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 [email protected].
For more options, visit https://groups.google.com/groups/opt_out.