Re: [wtr-general] How to exit from for loop

2011-03-18 Thread Tim Koopmans

http://xkcd.com/292/

Regards,
Tim 

Sent from my mobile ...


On 19/03/2011, at 1:44 AM, Dave McNulla  wrote:

> Another Ruby question.
> 
> You could try a break: 
> http://www.wellho.net/mouth/962_Breaking-a-loop-Ruby-and-other-languages.html
> 
> My favorite is goto
> 
> for i in1..5
>  blah blah blah
>  goto funnyfarm if i.am.crazy
> end
> 
> :funnyfarm
> puts "help, I'm in a batch script and I can't get out"
> 
> Sorry, just having a little fun this morning. 
> 
> Dave
> -- 
> Before posting, please read http://watir.com/support. In short: search before 
> you ask, be nice.
>  
> watir-general@googlegroups.com
> http://groups.google.com/group/watir-general
> watir-general+unsubscr...@googlegroups.com

-- 
Before posting, please read http://watir.com/support. In short: search before 
you ask, be nice.

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com


Re: [wtr-general] Re: Firewatir .element_name is always empty

2011-03-18 Thread Trampus Richmond
Yes, but I am looking for the internal Jssh javascript var which are all stored 
in different arrays such as elements_input[], or elements_div[], this info in 
stored as an instance var for each class instance.  It is a string that is used 
internally by firewatir to access elements in Jssh.

--Trampus


On 3/18/11 6:28 AM, "Super Kevy"  wrote:

>From the watir api docs 
>http://wtr.rubyforge.org/rdoc/1.6.5/classes/Watir/Element.html#M000563

.attribute_value(attribute_name)
Get attribute value for any attribute of the element. Returns null if
attribute doesn't exist.
from your thread
b.button(:id,"button_666).attribute_value("name") =>  answer



On Mar 18, 1:59 am, Trampus Richmond  wrote:
> Turns out this wasn't a very clean way.  Does anyone know a better way at 
> getting at the jssh vars?
>
> Thanks.
>
> On 3/17/11 6:33 PM, "Trampus Richmond"  wrote:
>
> Looks like I was able to get at it using: div.class_eval("@element_name")
>
> On 3/17/11 3:43 PM, "Trampus Richmond"  wrote:
>
> When using Firewatir I try to get the element_name from an instance an
> element an I always get retuned an empty string.  This seems to be the cause
> for firewatir-1.8.0, on both windows and Linux.
>
> I really need to get at the jssh var name for the given firewatir element.
>
> Simple Ruby Example:
> Watir::Browser.default = "firefox"
> b = Watir::Browser.new()
> b.goto("file://c:/test-css.html")
> div = b.div(:id, "6")
> print "Div: #{div.element_name}\n"
> btn = b.button(:id, "button_666")
> print "Button: #{btn.element_name}\n"
> b.close()
>
> Simple HTML target:
> 
> 
> .tbutton {
>color: #FF;
>background-color: #00;
>font-weight: bold;}
>
> 
> test css
> 
>
> 
>
> 
> 
> 
>
> --
> Before posting, please readhttp://watir.com/support. In short: search before 
> you ask, be nice.
>
> watir-general@googlegroups.comhttp://groups.google.com/group/watir-general
> watir-general+unsubscr...@googlegroups.com

--
Before posting, please read http://watir.com/support. In short: search before 
you ask, be nice.

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com

-- 
Before posting, please read http://watir.com/support. In short: search before 
you ask, be nice.

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com


Re: [wtr-general] How to exit from for loop

2011-03-18 Thread Aravind
Thanks

It works.

aravind

On Fri, Mar 18, 2011 at 8:14 PM, Dave McNulla  wrote:

> Another Ruby question.
>
> You could try a break:
>
> http://www.wellho.net/mouth/962_Breaking-a-loop-Ruby-and-other-languages.html
>
> My favorite is goto
>
> for i in1..5
>  blah blah blah
>  goto funnyfarm if i.am.crazy
> end
>
> :funnyfarm
> puts "help, I'm in a batch script and I can't get out"
>
> Sorry, just having a little fun this morning.
>
> Dave
>
> --
> Before posting, please read http://watir.com/support. In short: search
> before you ask, be nice.
>
> watir-general@googlegroups.com
> http://groups.google.com/group/watir-general
> watir-general+unsubscr...@googlegroups.com
>

-- 
Before posting, please read http://watir.com/support. In short: search before 
you ask, be nice.

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com


[wtr-general] Re: Output to xls or .cvs file

2011-03-18 Thread Abe Heward
Dave's code is nicer. :-)

On Mar 18, 7:38 am, Dave McNulla  wrote:
> That's a ruby question.
>
> f2.puts "#{a[x]},#{url}.#{Time}"
>
> In a string, you want to encapsulate variables and code using #{}.You can do
> code in addition to variables. In the following examples, I am finding the
> logged times for a web service call and it's response. I have am putting it
> into a csv file for analysis later.
> line =
> %Q("#{counter}","#{user}","#{temp.type}","#{temp.wstype}","#{completionTime}","#{getPrettyTime(temp.timevalue)}","#{temp.cleanMessage}","#{getPrettyTime(match.timevalue)}","#{match.cleanMessage}"\n)
> File.open(@csvFile, 'a+') {|f| f.write(line) }
>
> Dave

-- 
Before posting, please read http://watir.com/support. In short: search before 
you ask, be nice.

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com


[wtr-general] Re: Output to xls or .cvs file

2011-03-18 Thread Dave McNulla
That's a ruby question. 

f2.puts "#{a[x]},#{url}.#{Time}"

In a string, you want to encapsulate variables and code using #{}.You can do 
code in addition to variables. In the following examples, I am finding the 
logged times for a web service call and it's response. I have am putting it 
into a csv file for analysis later. 
line = 
%Q("#{counter}","#{user}","#{temp.type}","#{temp.wstype}","#{completionTime}","#{getPrettyTime(temp.timevalue)}","#{temp.cleanMessage}","#{getPrettyTime(match.timevalue)}","#{match.cleanMessage}"\n)
File.open(@csvFile, 'a+') {|f| f.write(line) }

Dave


-- 
Before posting, please read http://watir.com/support. In short: search before 
you ask, be nice.

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com


Re: [wtr-general] How to exit from for loop

2011-03-18 Thread Dave McNulla
Another Ruby question.

You could try a break: 
http://www.wellho.net/mouth/962_Breaking-a-loop-Ruby-and-other-languages.html

My favorite is goto

for i in1..5
 blah blah blah
 goto funnyfarm if i.am.crazy
end

:funnyfarm
puts "help, I'm in a batch script and I can't get out"

Sorry, just having a little fun this morning. 

Dave

-- 
Before posting, please read http://watir.com/support. In short: search before 
you ask, be nice.

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com


[wtr-general] How to exit from for loop

2011-03-18 Thread Aravind
Hi

Is there any command like "exit" to come out of For loop before even
finishing the iterations.

thanks
aravind

-- 
Before posting, please read http://watir.com/support. In short: search before 
you ask, be nice.

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com


[wtr-general] Re: Output to xls or .cvs file

2011-03-18 Thread Abe Heward
It's probably better if you create a hash with the keys as the page
IDs and the values as the response times.  Then set up your File.open
loop like this:

File.open("analysis.csv", "a+") do | contents |

  hash.each do | page_id, response_time |
contents << "#{page_id}, #{response_time}\n"
  end
end

Hope that helps!

On Mar 18, 6:09 am, vin  wrote:
> Hi All,
>
> Hope this will be my last question and i really thank for all the
> support received :)
>
> I want to redirect script output to excel or .csv file and here is my
> requirement.
>
> Script will navigate to multiple pages and it will record the time for
> each page. Now, i need to create two column in xls/cvs file (say
> pageID, Response Time) and direct the output to it (a[x],rtest.Time).
>
> Script:
> --
> # Open the Firefox browser
> ff=Firefox.new
>
> # Attach HttpWatch
> control = WIN32OLE.new('HttpWatch.Controller')
> plugin = control.Firefox.Attach("")
>
> # Start Recording HTTP traffic
> plugin.Clear()
> plugin.Log.EnableFilter(false)
> plugin.Record()
>
> # Goto to the URL and wait for the page to be loaded
> ff.goto(url)
> ff.text_field(:id, "username").set "abc"
> ff.text_field(:id, "password").set "abc"
> ff.button(:id, "login").click
> plugin.Stop()
> rtime= plugin.Log.Pages(0).Entries.Summary << a =
> ["configure_access_left","configure_eny_left","configure_ac_left","configure_n_left","configure_t_left","configure_i_left"
>  ]
> #(around 40 page ID)
> for x in 0..40 do
> plugin.Clear()
> plugin.Log.EnableFilter(false)
> plugin.Record()
> ff.div(:id, a[x]).fireEvent("onmouseup")
> sleep 16
> plugin.Stop()
> rtime= plugin.Log.Pages(0).Entries.Summary << printf "Time to load page (secs):      %.3f\n", rtest.Time
> puts a[x]
> end
>
> -
>
> I tried to use this code but couldn't get required id and time into
> the file (file content is a[x],url.Time  )
> puts url.Time
> File.open('analysis.csv', 'a+') do | f2 |
> f2.puts "a[x],url.Time\n"
> f2.close
> end
>
> -
>
> Appreciate any pointers or the code to fulfill my requirement and also
> any suggestions to make script much robust.
>
> Thanks,

-- 
Before posting, please read http://watir.com/support. In short: search before 
you ask, be nice.

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com


[wtr-general] Re: Firewatir .element_name is always empty

2011-03-18 Thread Super Kevy
>From the watir api docs 
>http://wtr.rubyforge.org/rdoc/1.6.5/classes/Watir/Element.html#M000563

.attribute_value(attribute_name)
Get attribute value for any attribute of the element. Returns null if
attribute doesn’t exist.
from your thread
b.button(:id,"button_666).attribute_value("name") =>  answer



On Mar 18, 1:59 am, Trampus Richmond  wrote:
> Turns out this wasn't a very clean way.  Does anyone know a better way at 
> getting at the jssh vars?
>
> Thanks.
>
> On 3/17/11 6:33 PM, "Trampus Richmond"  wrote:
>
> Looks like I was able to get at it using: div.class_eval("@element_name")
>
> On 3/17/11 3:43 PM, "Trampus Richmond"  wrote:
>
> When using Firewatir I try to get the element_name from an instance an
> element an I always get retuned an empty string.  This seems to be the cause
> for firewatir-1.8.0, on both windows and Linux.
>
> I really need to get at the jssh var name for the given firewatir element.
>
> Simple Ruby Example:
> Watir::Browser.default = "firefox"
> b = Watir::Browser.new()
> b.goto("file://c:/test-css.html")
> div = b.div(:id, "6")
> print "Div: #{div.element_name}\n"
> btn = b.button(:id, "button_666")
> print "Button: #{btn.element_name}\n"
> b.close()
>
> Simple HTML target:
> 
> 
> .tbutton {
>    color: #FF;
>    background-color: #00;
>    font-weight: bold;}
>
> 
> test css
> 
>    
> 
>    
> 
> 
> 
>
> --
> Before posting, please readhttp://watir.com/support. In short: search before 
> you ask, be nice.
>
> watir-general@googlegroups.comhttp://groups.google.com/group/watir-general
> watir-general+unsubscr...@googlegroups.com

-- 
Before posting, please read http://watir.com/support. In short: search before 
you ask, be nice.

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com


[wtr-general] Output to xls or .cvs file

2011-03-18 Thread vin
Hi All,

Hope this will be my last question and i really thank for all the
support received :)

I want to redirect script output to excel or .csv file and here is my
requirement.

Script will navigate to multiple pages and it will record the time for
each page. Now, i need to create two column in xls/cvs file (say
pageID, Response Time) and direct the output to it (a[x],rtest.Time).

Script:
--
# Open the Firefox browser
ff=Firefox.new

# Attach HttpWatch
control = WIN32OLE.new('HttpWatch.Controller')
plugin = control.Firefox.Attach("")

# Start Recording HTTP traffic
plugin.Clear()
plugin.Log.EnableFilter(false)
plugin.Record()

# Goto to the URL and wait for the page to be loaded
ff.goto(url)
ff.text_field(:id, "username").set "abc"
ff.text_field(:id, "password").set "abc"
ff.button(:id, "login").click
plugin.Stop()
rtime= plugin.Log.Pages(0).Entries.Summary <

[wtr-general] Re: Measure response time with fireEvent("onmouseup")

2011-03-18 Thread vin
Hi Chuck,

Please find my below response:

>>Have you by any chance tried to click that div as if it was a button,
 using the ID to identify it?
Yes, but its not clicking on that object.
>>system truely re-loading the page, or is it just updating it?
Since its extjs, it is only updating the page.
>>does it ever say anything but 'done' in the status bar?
Only "done". Also i tried button click along with fireevent as
suggested but the ouptut is same.

Tim:
Those plugin are from httpwatch tool.

As Chuck suggested, I will dig in and try to use waiting option.

Thanks,

On Mar 17, 10:17 pm, Chuck van der Linden  wrote:
> I think the issue is that since it's being invoked by client-side
> code, watir doesn't really know to expect a page load at that time
>
> Have you by any chance tried to click that div as if it was a button,
> using the ID to identify it?
>
> Since I see some ajax in there, I guess the first question is, is the
> system truely re-loading the page, or is it just updating it?  In
> other words, does the browser actually act like a page is loading,
> does it ever say anything but 'done' in the status bar?  do you see
> any of the 'animations' done by the browser to indicate a page is
> being loaded?   If it is only updating portions of the page, it makes
> getting a load time a lot harder.
>
> It's been a while since I've played with this (since I needed to) but
> I could swear that in the past Watir was a little less obsessive about
> elements exactly matching the specific element type when you were
> identifying them by ID (I think the logic was that since there should
> be only ONE thing on that page with that id value, if we found one, it
> must be the one you wanted).
>
> b.button(:id, "configure_access_left").click
>
> The reason I say that is that doing that might cause watir to do it's
> normal 'wait for the page to load' thing.   I'm not sure, but it might
> be worth a shot.
>
> (that or adding that command right after the one that does the mouseup
> event, instead of a sleep)
>
> Instead of sleeps, read up on waiting with watir.. in cases like this
> it's sometimes easier to just have a small loop that waits for a
> expected object to exist within the page, as an indication you are
> ready to proceed.  (or conversely if the app displays some kind of
> 'loading' icon, you wait for that to go away)
>
> On Mar 17, 3:29 am, vin  wrote:
>
>
>
> > Hi Guys,
>
> > Debugging further shows that with "sleep" the response time and bytes
> > recieved are proper but when "sleep" is removed the time and recieved
> > bytes are "zero". Also, without "sleep" navigation to multiple pages
> > is very fast (script will not wait until page is laoded).
>
> > Script with sleep:
> > -
> > plugin.Clear()
> > plugin.Log.EnableFilter(false)
> > plugin.Record()
> > ie.div(:id, "configure_access_left").fireEvent("onmouseup")   <<<1st
> > page
> > sleep 10          <<<
> > ie.div(:id, "configure_nat_left").fireEvent("onmouseup")  <<<2nd page
> > sleep 10          <<<
> > plugin.Stop()
> > if plugin.Log.Pages.Count != 0
> >         page1= plugin.Log.Pages(0).Entries.Summary
> >         printf "Total time to load page (secs):      %.3f\n", page1.Time
> >         printf "Number of bytes received on network: %d\n",
> > page1.BytesReceived
>
> > end
>
> > ## output with sleep
>
> > Total time to load page (secs):      5.199
> > Number of bytes received on network: 427
>
> > ##Script without Sleep
> > 
>
> > ie.div(:id, "configure_access_left").fireEvent("onmouseup")   <<<1st
> > page
> > ie.div(:id, "configure_nat_left").fireEvent("onmouseup")  <<<2nd page
> > plugin.Stop()
> > 
> > #ouptput:
> > -
> > Total time to load page (secs):      0.002
> > Number of bytes received on network: 0
>
> > Kindly let me know the cause for this behaviour and also better
> > solution to use for page to laod before navigation to next page.
>
> > On Mar 17, 1:06 am, vin  wrote:
>
> > > Hi,
>
> > > I am using fireevent to click a div (button to navigate to a page) as
> > > shown:
> > > (ie.div(:id, "configure_access_left").fireEvent("onmouseup")
> > > ###
> > > irb(main):004:0* b = Watir::Browser.new
> > > => #
> > > irb(main):005:0>
> > > irb(main):006:0* b.goto "http://abc-blue";
> > > => 1.96875                         <<< > > irb(main):007:0> b.div(:id,
> > > "configure_access_left").fireEvent("onmouseup")
> > > =>
> > > nil
> > > <<< shows as nill
> > > irb(main):008:0>
>
> > > By using above method, navigate to a required page is achieved but the
> > > response shows as "nil" instead of the time. The scenario is server-
> > > client and upon navigation to a page client will fetch the data from
> > > the server. Here is the snippet captured with firebug:
>
> > > POSThttp://abc-blue/jsdm/ajax/access.php200OK571ms
> > > sajax(line 150)
> > > ParamsHeadersPostPutResponseCacheHTMLXML
> > > Response Headersview source
> > > Date    Thu, 17 Mar 2011 04:57:44 GMT
> > > Server  Mbedt

Re: [wtr-general] Re: Click on links on a dynamic pane

2011-03-18 Thread Aravind
Woow Linden

Its working fine. Surprised to see that.
Thank you very much for your help.
Till now i heard about ruby and now i am realising how easy it is.

below is the code I used.

for i in 3..table.row_count - 1
  if table[i][8].text == "APV"
table[i][1].link(:index,1).click
table[i][1].link(:index,1).parent.link(:text,"Open This
Version").click
i = table.row_count
  end
   end


thanks
aravind

On Thu, Mar 17, 2011 at 11:00 PM, Chuck van der Linden wrote:

> Can you show me the code for the click?
>
> from the looks of the dom, the original link you click to see the sub-
> menu, and those menu items, are all 'inside' that table row.   I
> suspect that the challeng is that there are other similar hidden links
> (at that point) on each of the other table rows, all with the same
> link text etc..   Making clicking the right one a challenge;
>
> So you might be able to identify them according to a sibling
> relationship with the link you clicked
>
>  Try using the same code as for the click, but replace the .click with
> the following
>
>  .parent.link(:text, "Open This Version").click
>
> as Basim indicated, you may have to FIRST fire an onmouseover event
> against that element, since I see code in there that is reacting to
> that event, and perhaps if it does not see that first, you won't be
> able to click it
>
> On Mar 17, 8:25 am, Aravind  wrote:
> > Basim
> >
> > I used Click method
> >
> > thanks
> > aravind
> >
> > On Thu, Mar 17, 2011 at 8:51 PM, Basim Baassiri 
> wrote:
> > > When you say click on the action, do you use click method or do you use
> > > fire_event ?
> >
> > >   On Thu, Mar 17, 2011 at 11:13 AM, Aravind  >wrote:
> >
> > >>   Hi
> >
> > >> This is the continuation of my previous question which is resolved.
> >
> > >> I have some links with the name "action" in the1st column of all the
> > >> rows in a table.
> > >> When I click the action link a dynamic pane will be displayed with few
> > >> more links.
> > >> Now i have click on any of the links on the pane.
> >
> > >> The image of the page and the html is attached.
> >
> > >> Please help.
> >
> > >> thanks
> > >> aravind
> >
> > >> --
> > >> Before posting, please readhttp://watir.com/support. In short: search
> > >> before you ask, be nice.
> >
> > >> watir-general@googlegroups.com
> > >>http://groups.google.com/group/watir-general
> > >> watir-general+unsubscr...@googlegroups.com
> >
> > > --
> > > Before posting, please readhttp://watir.com/support. In short: search
>  > > before you ask, be nice.
> >
> > > watir-general@googlegroups.com
> > >http://groups.google.com/group/watir-general
> > > watir-general+unsubscr...@googlegroups.com
>
> --
> Before posting, please read http://watir.com/support. In short: search
> before you ask, be nice.
>
> watir-general@googlegroups.com
> http://groups.google.com/group/watir-general
> watir-general+unsubscr...@googlegroups.com
>

-- 
Before posting, please read http://watir.com/support. In short: search before 
you ask, be nice.

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com


[wtr-general] Re: Windows IE9 support?

2011-03-18 Thread Tim
Similarly, against IE9 I've observed link clicks (ie.
@browser.link(:text, pattern).click) returning as if they had
completed successfully but without being performed.

Switching the browser to compatibility mode restored the previous IE8
behaviour, so at least there's an (imperfect) workaround for now. Of
course, if you were planning to test IE9's HTML5 support with Watir
you're all out of luck.

Tim

-- 
Before posting, please read http://watir.com/support. In short: search before 
you ask, be nice.

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com


Re: [wtr-general] Firewatir .element_name is always empty

2011-03-18 Thread Trampus Richmond
Turns out this wasn't a very clean way.  Does anyone know a better way at 
getting at the jssh vars?

Thanks.


On 3/17/11 6:33 PM, "Trampus Richmond"  wrote:

Looks like I was able to get at it using: div.class_eval("@element_name")


On 3/17/11 3:43 PM, "Trampus Richmond"  wrote:

When using Firewatir I try to get the element_name from an instance an
element an I always get retuned an empty string.  This seems to be the cause
for firewatir-1.8.0, on both windows and Linux.

I really need to get at the jssh var name for the given firewatir element.

Simple Ruby Example:
Watir::Browser.default = "firefox"
b = Watir::Browser.new()
b.goto("file://c:/test-css.html")
div = b.div(:id, "6")
print "Div: #{div.element_name}\n"
btn = b.button(:id, "button_666")
print "Button: #{btn.element_name}\n"
b.close()


Simple HTML target:


.tbutton {
   color: #FF;
   background-color: #00;
   font-weight: bold;
}

test css

   

   




--
Before posting, please read http://watir.com/support. In short: search before 
you ask, be nice.

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com

-- 
Before posting, please read http://watir.com/support. In short: search before 
you ask, be nice.

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com