Firefox for google gives me the default text scrape: Screen reader users, click here to turn off Google Instant. Gmail Images Sign in Google Privacy Terms Settings Advertising Business About
This line is working correctly. its returning the whole page text not just search results puts "body is "+firefox.text #This returns Sign in in firefox! Consider if you just want search returns: ( i think thats that right div element) puts "body is "+firefox.div(:id,"search").text.to_s On Tuesday, March 10, 2015 at 11:06:18 AM UTC-5, Titus Fortner wrote: > > Your code works just fine for me. > Are you looking at the browser as this executes? The firefox.text is > returning a sign in because there is something on the page that is > requiring a sign in for some reason. Can you see what the sign in is for? > > Titus > > On Thu, Mar 5, 2015 at 11:52 AM, Karthik Krish <kkpi...@gmail.com > <javascript:>> wrote: > >> Hi, >> I am new to watir and just started to play around with it. >> However, using watir-webdriver, when I user browser.text, in firefox it >> is only using the first line of the page, and similar result in chrome. My >> code is as under. Please let me know if I am doing anything wrong. >> >> prints firefox.text returns "Sign in" when it should be returning the >> entire search result body (or is my understanding incorrect?) >> >> Thx >> Karthik >> >> #-------------------------------------------------------------# >> # Demo test for the Watir controller. >> # >> # Purpose: to demonstrate the following Watir functionality: >> # * entering text into a text ffirefoxld, >> # * clicking a button, >> # * checking to see if a page contains text. >> # Test will search Google for the "pickaxe" Ruby book. >> #-------------------------------------------------------------# >> >> # the Watir controller >> require "watir-webdriver" >> >> # set a variable >> test_site = "http://www.google.com" >> >> # open a firefox instance >> firefox = Watir::Browser.new:firefox >> >> # print some comments >> puts "Beginning of test: Google search." >> >> puts " Step 1: go to the test site: " + test_site >> firefox.goto test_site >> >> puts " Step 2: enter 'pickaxe programming ruby' in the search text >> ffirefoxld." >> firefox.text_field(:name => 'q').set 'pickaxe programming ruby' >> #text_ffirefoxld(:name, "q").set "pickaxe programming ruby" # "q" is the >> name of the search ffirefoxld >> >> puts " Step 3: click the 'Google Search' button." >> firefox.button(:name, "btnG").click # "btnG" is the name of the Search >> button >> >> puts " Expected Result:" >> puts " A Google page with results should be shown. 'Programming Ruby' >> should be high on the list." >> >> puts " Actual Result:" >> if firefox.text.include? "Programming Ruby" >> puts " Test Passed. Found the test string: 'Programming Ruby'. Actual >> Results match Expected Results." >> else >> puts " Test Failed! Could not find: 'Programming Ruby'." >> end >> puts "body is "+firefox.text #This returns Sign in in firefox! >> >> puts "End of test: Google search." >> >> -- >> -- >> Before posting, please read http://watir.com/support. In short: search >> before you ask, be nice. >> >> watir-...@googlegroups.com <javascript:> >> http://groups.google.com/group/watir-general >> watir-genera...@googlegroups.com <javascript:> >> >> --- >> 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 <javascript:>. >> For more options, visit https://groups.google.com/d/optout. >> > > -- -- 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 --- 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-general+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.