Duke - This is how I get this value in IRB:
C:\Users\Alan>irb --noreadline irb(main):001:0> require 'watir' => true irb(main):002:0> br = Watir::Browser.attach(:url, //) => #<Watir::IE:0x4b1a0f4 url="https://www.google.com/accounts/ServiceLogin?service=mail" title="Gmail: Email from Google "> irb(main):003:0> br.span(:id, 'quota').text => "7621.509110" irb(main):004:0> br.span(:id, 'quota').text => "7621.509118" irb(main):005:0> br.span(:id, 'quota').text => "7621.509122" irb(main):006:0> br.span(:id, 'quota').text => "7621.509126" irb(main):007:0> br.span(:id, 'quota').text => "7621.509126" irb(main):008:0> br.span(:id, 'quota').text => "7621.509130" irb(main):009:0> br.span(:id, 'quota').text => "7621.509134" irb(main):010:0> br.span(:id, 'quota').text => "7621.509134" You are making things way harder than they need to be. I don't know why you are using Nokogiri, Watir has it's own DOM parser and as I demonstrated above is adequate for what you want it to do. Let me know if this solves your problem. Alan On Tue, Aug 30, 2011 at 9:39 AM, Duke <[email protected]> wrote: > Hi folks, > > Please welcome the newest user of watir! I just heard about watir when > searching for web automation, and after reading some how-to articles, I was > quite excited with my first script running below (run fine in ubuntu x86, > havent tried in mac or windows yet): > > #### CODE START #### > #!/usr/bin/env ruby > > require 'rubygems' > require 'watir' > require 'nokogiri' > #require 'watir-webdriver' > > #start the browser up > #browser = Watir::Browser.new :chorme > browser = Watir::Browser.start > "https://www.google.com/accounts/ServiceLogin?service=mail" > > #pass in current page's html to nokogiri for parsing > page_html = Nokogiri::HTML.parse(browser.html) > text = page_html.xpath(".//*[@id='quota']").inner_text > > while((text.to_f)<7621.000000) > page_html = Nokogiri::HTML.parse(browser.html) > text = page_html.xpath(".//*[@id='quota']").inner_text > puts text > sleep 2 > end > #### CODE END #### > > Since I am totally new to watir, I would appreciate any one helping me with > my questions below: > > * Main advantage of watir compared to traditional method (manual crawling), > as far as I understand, is to reduce the number of automated queries sent to > the interested page. With what I am doing above, am I doing it right? Is it > considered as one query each time when I call > page_html.xpath(".//*[@id='quota']").inner_text? If not, then anyone can > explain to me how it is working? > > * I have the feeling that the code above works as to extract infos from > HTML code, whereas the quote produced from gmail is from a javascript. Is > there a way that I capture infos from javascript instead of HTML code? > > * Now if I want to *detect* the change of quota, meaning I want a kind of > *real-time* code that reports me quota anytime when quote on gmail changes > its value. Anyone can recommend me how to achieve that? > > Thanks so much in advances, and sorry for many questions. > > D. > > -- > 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] > -- 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]
