Can't use = sign in URL.

32 views
Skip to first unread message

JimJamie

unread,
Jun 4, 2013, 11:59:34 AM6/4/13
to watir-...@googlegroups.com

It seems to stop looking at the first equal sign.
Is there a way to rewrite the equals sign and get the same result?
I have something like this in my properties file.

#url=http://FooBar.com/Portal/quote?source=club&clubcode=412&state=CA&zipcode=90210

Željko Filipin

unread,
Jun 4, 2013, 1:05:17 PM6/4/13
to watir
How is this related to Watir? I have no idea what you are talking about. Moar context, please. :)

Željko
--
https://leanpub.com/watirbook




--
--
Before posting, please read http://watir.com/support. In short: search before you ask, be nice.
 
watir-...@googlegroups.com
http://groups.google.com/group/watir-general
watir-genera...@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-genera...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Jim Bailey

unread,
Jun 4, 2013, 2:26:05 PM6/4/13
to watir-...@googlegroups.com
I'm using Watir with Ruby 1.86.

I have a properties file that I point to when I fire up a Watir script.

properties = TemplateProperties.new("../properties/template_properties.txt")

Then it uses this:

b.goto(properties.getUrl)

to pull the correct url.  I use several.

When I attempt to fire up a Watir script I do not get the website that I'm looking for when I use the url in my previous (original) post, given to me today to test with.
When I copy and paste the url into the browser address bar it works fine.
When I copy and paste the url into the browser address bar, up to the first = sign I get the same result as when I try to fire it up in Watir.
So, I'm pretty sure Watir/Ruby interprets the = as something else. (like, oh this must be a new row)
I did some research before I posted.
Someone else had a similar issue where the equals sign was replaced with something like %3D. It worked for them, not for me.


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 watir-genera...@googlegroups.com.

Dan

unread,
Jun 4, 2013, 3:08:53 PM6/4/13
to watir-...@googlegroups.com
I think you're going to want to look into using yaml instead of flat text files.  You'll want to start by looking here.

Željko Filipin

unread,
Jun 4, 2013, 4:19:14 PM6/4/13
to watir
On Tue, Jun 4, 2013 at 8:26 PM, Jim Bailey <jbail...@gmail.com> 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))

Jim Bailey

unread,
Jun 5, 2013, 11:52:56 AM6/5/13
to watir-...@googlegroups.com
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:
So it is ignoring all the the right of the equals sign as I expected.



 


--

John Fitisoff

unread,
Jun 5, 2013, 2:02:49 PM6/5/13
to watir-...@googlegroups.com
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 <jbail...@gmail.com>
To: watir-...@googlegroups.com
Sent: Wednesday, June 5, 2013 8:52 AM
Subject: Re: [wtr-general] Can't use = sign in URL.

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-genera...@googlegroups.com.

Željko Filipin

unread,
Jun 6, 2013, 6:38:31 AM6/6/13
to watir
On Wed, Jun 5, 2013 at 5:52 PM, Jim Bailey <jbail...@gmail.com> wrote:
For now, can I forget about the properties file, and have the Watir script put the url directly in the address bar?

Jim Bailey

unread,
Jun 6, 2013, 7:27:27 AM6/6/13
to watir-...@googlegroups.com
Neither of those worked. For now I am using this:

b.goto(properties.getUrl.gsub("\n",'') + 'source=' + properties.getSource.gsub("\n",'') + '&' + 'xyzclubcode=' + properties.getxyzclubcode.gsub("\n",'') + '&' + 'state=' + properties.getState.gsub("\n",'') + '&' + 'zipcode=' + properties.getZipcode.gsub("\n",''))
With some changes to my .rb file.

And a reformatting of the .txt properties file to:

url=http://Foo.Bar.com/Portal/quote?
source=club
xyzclubcode=212
state=VA
zipcode=20109


I'll try to get back to this issue for a better answer.

The links you sent earlier were somewhat helpful but I could not figure out how to transform the information into usable commands.
I learned the %3D should replace the = sign.


Super Kevy

unread,
Jun 6, 2013, 9:26:08 AM6/6/13
to Watir General
So if its breaking at the = sign then you are not encapsulating the
value as a string.
Something like this may be a low impact patch
myVar = '"' + url + '"'
puts myVar
or even
myVar = url.to_s
puts myVar




On Jun 6, 6:27 am, Jim Bailey <jbailey...@gmail.com> wrote:
> Neither of those worked. For now I am using this:
>
> b.goto(properties.getUrl.gsub("\n",'') + 'source=' +
> properties.getSource.gsub("\n",'') + '&' + 'xyzclubcode=' +
> properties.getxyzclubcode.gsub("\n",'') + '&' + 'state=' +
> properties.getState.gsub("\n",'') + '&' + 'zipcode=' +
> properties.getZipcode.gsub("\n",''))
> With some changes to my .rb file.
>
> And a reformatting of the .txt properties file to:
>
> url=http://Foo.Bar.com/Portal/quote?
> source=club
> xyzclubcode=212
> state=VA
> zipcode=20109
>
> I'll try to get back to this issue for a better answer.
>
> The links you sent earlier were somewhat helpful but I could not figure out
> how to transform the information into usable commands.
> I learned the %3D should replace the = sign.
>
> On Thu, Jun 6, 2013 at 6:38 AM, Željko Filipin <zeljko.fili...@gmail.com>wrote:
>
>
>
>
>
>
>
> > On Wed, Jun 5, 2013 at 5:52 PM, Jim Bailey <jbailey...@gmail.com> wrote:
>
> >> For now, can I forget about the properties file, and have the Watir
> >> script put the url directly in the address bar?
>
> > Sure, try this:
>
> > b.goto(URI.escape "
> >http://FooBar.com/Portal/quote?source=club&clubcode=412&state=CA&zipc...<http://foobar.com/Portal/quote?source=club&clubcode=412&state=CA&zipc...>
> > ")
>
> > or
>
> > b.goto "
> >http://FooBar.com/Portal/quote?source=club&clubcode=412&state=CA&zipc...<http://foobar.com/Portal/quote?source=club&clubcode=412&state=CA&zipc...>
> > "
>
> > Željko
>
> >  --
> > --
> > Before posting, please readhttp://watir.com/support. In short: search
> > before you ask, be nice.
>
> > watir-...@googlegroups.com
> >http://groups.google.com/group/watir-general
> > watir-genera...@googlegroups.com
>
> > ---
> > 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/unsubscri...
> > .
Reply all
Reply to author
Forward
0 new messages