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 <[email protected]> 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.
>
> [email protected]
> http://groups.google.com/group/watir-general
> [email protected]
>
> ---
> 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 [email protected].
> 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.

[email protected]
http://groups.google.com/group/watir-general
[email protected]

--- 
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to