you have to attach that new windows, do the activities and then close that
and come back to your original browser.

in my ruby+watir framework I use the below if any new window opens where i
need to do anything

if attach_url(/<url in reg exp>/) then

enter_text_into_text_field_text("Enter the value in text field", "entry",
"abc")

# do what ever you want to do in this new window
# then close this new window
end

the attach_url and enter_text_into_text_field are called from testbase.rb

def enter_text_into_text_field_text(title, name, value)
  startAction title, "type '" + value + "' in '" + name + "' text field"

  if no_fatal_error then
   begin
          $ie.text_field(:name, name).set(value)
          logPass
      rescue => e
       handleFail e
      end
  end
 end

def attach_url(urlName)
  startAction "opening new IE instance", urlName.to_s
  if no_fatal_error then
      begin
          new_ie = Watir::IE.attach(:url, urlName)
          new_ie.set_fast_speed
          @stored_ie = $ie
          $ie = new_ie
          logPass
          return true
      rescue => e
          @fatal_error="true"
       handleFail e
      end
  end

  return false
    end

On Fri, Aug 13, 2010 at 12:21 PM, cyril.gonsal...@mastek.com <
cyril.gonsal...@mastek.com> wrote:

> Hi,
>
> I am writing script for a testcase below.
>
> 1. Open Link abc.htm
> 2. Click link "chat me" on abc.htm
> 3. Enter text in the testfield on the newly opened page
> 4. Click submit button
>
> While written script for above like this
>
>
> # Reuired libraries
>
>  require 'watir'
>
>  site_text = "http://localhost:8080/XXX/a.htm";
>  ie = Watir::IE.new
>  ie.goto(site_text)
>  ie.link(:text,"Chat me").click
>
> ie.text_field(:name,"entry").set "abc" # text field on the opened link
>
>
> I get below error messge :
>
> `assert_exists': Unable to locate element, using :name,
> "entry" (Watir::Exception::UnknownObjectException)
>        from
> C:/ruby/lib/ruby/gems/1.8/gems/watir-1.6.5/lib/watir/element.rb:
> 288:in `enabled?'
>        from
> C:/ruby/lib/ruby/gems/1.8/gems/watir-1.6.5/lib/watir/element.rb:
> 60:in `assert_enabled'
>        from C:/ruby/lib/ruby/gems/1.8/gems/watir-1.6.5/lib/watir/
> input_elements.rb:327:in `set'
>        from D:/Ruby/rbC1.tmp:15
> Complete(1)
>
>
> The problem could be because of the new browser window.
>
> if yes then how to access objects e.g textfield in the browser i.e.
> opened by clicking the link in another browser
>
> --
> Before posting, please read http://watir.com/support. In short: search
> before you ask, be nice.
>
> You received this message because you are subscribed to
> http://groups.google.com/group/watir-general
> To post: watir-general@googlegroups.com
> To unsubscribe: 
> watir-general+unsubscr...@googlegroups.com<watir-general%2bunsubscr...@googlegroups.com>
>

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

You received this message because you are subscribed to 
http://groups.google.com/group/watir-general
To post: watir-general@googlegroups.com
To unsubscribe: watir-general+unsubscr...@googlegroups.com

Reply via email to