From: Paul Rogers Date: 2007-11-16T07:15:00+09:00 Subject: Re: Adding Post Data to IE.navigate method with Ruby On Nov 15, 11:40 am, Bach Le wrote: > Hi all, > > I'm automating IE with Watir and Ruby and I have a slight problem that > I can't seem to solve. I'd like to pass post data to IE's navigate > method (http://msdn2.microsoft.com/en-us/library/aa752093.aspx) > > Seems like the postdata parameter is a byte array so here's what I've > done in ruby to try to pass this data > > bytearray = [] > postdata.each_byte{ |c| bytearray.push(c) } > @ie.navigate(url, nil, nil, bytearray, "Content-Type: > application/x-www-form-urlencoded\r\n") > > Fiddler seems to always say that the content length is 16 times longer > than the actual length and I'm not sure why. Does anyone know how make > this call work? TIA. > > -Bach post data is usually hash like, so maybe this is what you need ( untested ) data = {} data["name"]=>'paul' data["url"]=> 'www.google.com' post_data = [] data.each_pair do |k,v| post_data << "#{k}=#{v}" end @ie.navigate(url, nil, nil, post_data.join("&"), "Content-Type: application/x-www-form-urlencoded\r\n") You'll probably have to url encode the data too though Paul