Hi Shalini,

Just try this code (modified your code a little)
def text(wait_seconds = 1)
           # sleep 0.3
           autoit = WIN32OLE.new("AutoItX3.Control")
           autoit.WinWait("Microsoft Internet Explorer", nil, wait_seconds)
if wait_seconds
           s = autoit.WinGetText("Microsoft Internet Explorer")
           file = File.open("c:\\test.txt", "w")           # DONT MAKE
YOUR VARIABLES GLOBAL UNNECESSARILY
           file.puts(s)
           file.close
           s unless s == "1"            # NOT SURE WHY YOU ARE DOING THIS
end
Let me know if this works.

Regards,
Prema

On 4/25/07, SHALINI GUPTA <[EMAIL PROTECTED]> wrote:

hi,

i have tried to write this as

def text(wait_seconds = 1)
            # sleep 0.3
            autoit = WIN32OLE.new("AutoItX3.Control")
            autoit.WinWait("Microsoft Internet Explorer", nil,
wait_seconds) if wait_seconds
            s = autoit.WinGetText ("Microsoft Internet Explorer")
            $File = File.open("c:\\test.txt", "w")
            $File.puts(s.to_s)
            s unless s == "1"
        end

but it is printing only 1..in the file.
please help.

shalini gupta

On 4/25/07, SHALINI GUPTA < [EMAIL PROTECTED] > wrote:
>
> hi,
> Thanks for quick reply...
>
> please tell me how can i write output of one method to a file....
>
> my method is..
> def text(wait_seconds = 1)
>             # sleep 0.3
>             autoit.WinWait(WINDOW_TITLE, nil, wait_seconds) if
> wait_seconds
>             s = autoit.WinGetText(WINDOW_TITLE)
>             s unless s == "1"
>         end
> please help me..
>
> Thanks In Advance
> Regards
> Shalini Gupta
>
> On 4/25/07, Angrez Singh <[EMAIL PROTECTED]> wrote:
> >
> > Hi,
> > As Paul said that you need to store the text in a file and then read
> > that file in your main process. Because pop up's are handled in different
> > process. So even if you return that value from the method it won't be
> > visible to main process. Write this value to a file and then read the
> > contents.
> >
> > Regards,
> > Angrez
> >
> > On 4/25/07, SHALINI GUPTA < [EMAIL PROTECTED] > wrote:
> > >
> > > hi,
> > >
> > > thanks for reply!!!
> > >
> > > but i have used autoit and WinGet Text as:---(with no success)
> > >
> > >  #----- js_dialog.rb -----
> > >
> > > require 'win32ole'
> > > require 'test/unit'
> > > require 'test/unit/ui/console/testrunner'
> > > #
> > > # Use AutoIt to read and close Javascript dialog windows
> > > #
> > > module JavascriptDialog
> > >
> > >     #
> > >     # Target javascript dialogs with this window title
> > >     #
> > >     WINDOW_TITLE = "Microsoft Internet Explorer"
> > >
> > >     class << self
> > >
> > >         #
> > >         # Return the text contained in a javascript dialog (e.g. an
> > > "alert()")
> > >         # if such a dialog is present or appears within
> > > +wait_seconds+.
> > >         #
> > >         def text(wait_seconds = 1)
> > >             # sleep 0.3
> > >             autoit.WinWait(WINDOW_TITLE, nil, wait_seconds) if
> > > wait_seconds
> > >             s = autoit.WinGetText(WINDOW_TITLE)
> > >             s unless s == "1"
> > >         end
> > >
> > >         #
> > >         # Close any active javascript dialog
> > >         #
> > >         def close
> > >             autoit.WinClose WINDOW_TITLE
> > >         end
> > >
> > >         #
> > >         # Press the "OK" button on a javascript dialog
> > >         #
> > >         def ok
> > >             autoit.ControlClick(WINDOW_TITLE, "", "OK")
> > >         end
> > >         #
> > >         # Press the "Cancel" button on a javascript dialog
> > >         #
> > >         def cancel
> > >             autoit.ControlClick (WINDOW_TITLE, "", "Cancel")
> > >         end
> > >         #
> > >         # Press the "Yes" button on a javascript dialog
> > >         #
> > >         def yes
> > >             autoit.ControlClick(WINDOW_TITLE, "", "Yes")
> > >         end
> > >         #
> > >         # Press the "No" button on a javascript dialog
> > >         #
> > >         def no
> > >             autoit.ControlClick(WINDOW_TITLE, "", "No")
> > >         end
> > >
> > >         private
> > >
> > >             #
> > >             # Return an AutoIt COM object, creating it if it doesn't
> > > already
> > >             # exist
> > >             #
> > >             def autoit
> > >                 unless defined? @@autoit
> > >                     @@autoit = WIN32OLE.new("AutoItX3.Control")
> > >                 end
> > >                 @@autoit
> > >             end
> > >     end
> > > end
> > >
> > > module Test::Unit::Assertions
> > >     #
> > >     # Passes if a Javascript dialog appears within +wait_seconds+
> > > and its
> > >     # text matches the given (optional) pattern.
> > >     #
> > >     # Use like this:
> > >     #  assert_js_dialog do
> > >     #    watir_command_to_make_dialog_appear
> > >     #  end
> > >     # Or like this:
> > >     #  assert_js_dialog /Text to find in the dialog/, "Cancel" do
> > >     #    watir_command_to_make_dialog_appear
> > >     #  end
> > >     #
> > >     def assert_js_dialog(pattern = //, action = "close", message =
> > > nil)
> > >         _wrap_assertion do
> > >             begin
> > >                 pipe = IO.popen("ruby exetry.rb #{action}")
> > >                 yield
> > >                 window_text = pipe.read rescue ""
> > >                 pipe.close
> > >                 unless window_text.empty?
> > >                     assert_block(build_message(message,
> > >                         "<?> not found in JavaScript dialog.",
> > > pattern)) do
> > >                             window_text.match(pattern)
> > >                     end
> > >                 else
> > >                     raise Test::Unit:: AssertionFailedError.new(
> > >                         build_message(message, "No JavaScript window
> > > found."))
> > >                 end
> > >             ensure
> > >                 pipe.close if pipe && !pipe.closed?
> > >             end
> > >         end
> > >     end
> > > end
> > >
> > > # test - will close and print the text of an opened javascript
> > > dialog if
> > > # run as "ruby js_dialog.rb"
> > > if $0 == __FILE__
> > >     action = ARGV.shift || "close"
> > >     print JavascriptDialog.text || ""
> > >     JavascriptDialog.send action
> > > end
> > >
> > > if possible then please help me...and give me some code...
> > >
> > > Regards
> > > Shalini Gupta
> > >
> > >
> > > On 4/24/07, Paul Rogers < [EMAIL PROTECTED] > wrote:
> > > >
> > > > there is stuff in the winclicker to do it too. We've got the
> > > > javascript pop up text back to the main app by saving it to a file
> > > >
> > > >
> > > > Paul
> > > >
> > > > Hi,
> > > >
> > > > As far as I know, clicking some button on Pop up window happens in
> > > > a different process (different from current process in which your 
script is
> > > > running). Correct me if I am wrong here?
> > > >
> > > > You can get the text using AutoIt3 and WinGetText method. The only
> > > > thing you need to find out is how you communicate data or the text 
between
> > > > two different processes.
> > > >
> > > > Regards,
> > > > Angrez
> > > >
> > > > On 4/24/07, SHALINI GUPTA < [EMAIL PROTECTED] > wrote:
> > > > >
> > > > > HI List,
> > > > >
> > > > > Please help regarding popup.
> > > > > How to get the text of a popup window..
> > > > > its very urgent please help.
> > > > >
> > > > > Regards
> > > > > Shalini gupta
> > > > >
> > > > > _______________________________________________
> > > > > Wtr-general mailing list
> > > > > Wtr-general@rubyforge.org
> > > > > http://rubyforge.org/mailman/listinfo/wtr-general
> > > > >
> > > >
> > > >
> > > > _______________________________________________
> > > > Wtr-general mailing list
> > > > Wtr-general@rubyforge.org
> > > > http://rubyforge.org/mailman/listinfo/wtr-general
> > > > _______________________________________________
> > > > Wtr-general mailing list
> > > > Wtr-general@rubyforge.org
> > > > http://rubyforge.org/mailman/listinfo/wtr-general
> > > >
> > >
> > >
> > > _______________________________________________
> > > Wtr-general mailing list
> > > Wtr-general@rubyforge.org
> > > http://rubyforge.org/mailman/listinfo/wtr-general
> > >
> >
> >
> > _______________________________________________
> > Wtr-general mailing list
> > Wtr-general@rubyforge.org
> > http://rubyforge.org/mailman/listinfo/wtr-general
> >
>
>

_______________________________________________
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general




--
Prema Arya
_______________________________________________
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general

Reply via email to