How to write code to get focuse the application which is open from server

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • vinthan

    How to write code to get focuse the application which is open from server

    hi,
    I am new to python. I have to write test cases in python. An
    application is open in the desk top ( application writen in .Net) I
    have to write code to get focuse the application and click on the link
    which in the one side and it will load the map on the other and I have
    to check map is loaded. Any one tell me how do I use Dispatch or any
    other method to write a code.

  • Paul McGuire

    #2
    Re: How to write code to get focuse the application which is open from server

    "vinthan" <svithi@gmail.c omwrote in message
    news:1168143871 .536432.252010@ v33g2000cwv.goo glegroups.com.. .
    hi,
    I am new to python. I have to write test cases in python. An
    application is open in the desk top ( application writen in .Net) I
    have to write code to get focuse the application and click on the link
    which in the one side and it will load the map on the other and I have
    to check map is loaded. Any one tell me how do I use Dispatch or any
    other method to write a code.
    >
    If you are running on Windows, look into pywinauto
    (http://www.openqa.org/pywinauto/).

    I have successfully used it to interact with a Flash animation running
    within an IE browser.

    I also had to inspect the graphics displayed by the Flash animation, for
    this I used PIL (http://www.pythonware.com/products/pil/).

    Good luck,
    -- Paul


    Comment

    • vithi

      #3
      Re: How to write code to get focuse the application which is open from server

      Hi Paul,
      Since your reply I try to use pywinauto. I was able to get the control
      of a window that is a good news but it is not working for sub window
      this main window create.(popup windows)
      eg) File -print will open print window but the code is not
      clicking print button. I try several combination
      app,Print.OK.Cl oseClick() or app,Print.OK.Cl ick() is not working

      my code goes like that
      app=application .Application()
      qi = app.window_(tit le_re = ".*arcMap.* ")
      qi.TypeKeys("%F P")
      app,Print.OK.Cl ick()

      the last line of code is not working same thing with file open to
      qi.TypeKeys("%F O") create popup window "open" but
      app,Open.Filena me.SetEditText( "test1,txt" ) is not working any help to
      overcome to this problem (Here the "Print" , "Open" are windows title I
      am using without any undestanding why I am using. Any help?





      Paul McGuire wrote:
      "vinthan" <svithi@gmail.c omwrote in message
      news:1168143871 .536432.252010@ v33g2000cwv.goo glegroups.com.. .
      hi,
      I am new to python. I have to write test cases in python. An
      application is open in the desk top ( application writen in .Net) I
      have to write code to get focuse the application and click on the link
      which in the one side and it will load the map on the other and I have
      to check map is loaded. Any one tell me how do I use Dispatch or any
      other method to write a code.
      If you are running on Windows, look into pywinauto
      (http://www.openqa.org/pywinauto/).
      >
      I have successfully used it to interact with a Flash animation running
      within an IE browser.
      >
      I also had to inspect the graphics displayed by the Flash animation, for
      this I used PIL (http://www.pythonware.com/products/pil/).
      >
      Good luck,
      -- Paul

      Comment

      • vithi

        #4
        Re: How to write code to get focuse the application which is open from server

        Hi Paul,
        Since your reply I try to use pywinauto. I was able to get the control
        of a window that is a good news but it is not working for sub window
        this main window create.(popup windows)
        eg) File -print will open print window but the code is not
        clicking print button. I try several combination
        app,Print.OK.Cl oseClick() or app,Print.OK.Cl ick() is not working

        my code goes like that
        app=application .Application()
        qi = app.window_(tit le_re = ".*arcMap.* ")
        qi.TypeKeys("%F P")
        app,Print.OK.Cl ick()

        the last line of code is not working same thing with file open to
        qi.TypeKeys("%F O") create popup window "open" but
        app,Open.Filena me.SetEditText( "test1,txt" ) is not working any help to
        overcome to this problem (Here the "Print" , "Open" are windows title I
        am using without any undestanding why I am using. Any help?





        Paul McGuire wrote:
        "vinthan" <svithi@gmail.c omwrote in message
        news:1168143871 .536432.252010@ v33g2000cwv.goo glegroups.com.. .
        hi,
        I am new to python. I have to write test cases in python. An
        application is open in the desk top ( application writen in .Net) I
        have to write code to get focuse the application and click on the link
        which in the one side and it will load the map on the other and I have
        to check map is loaded. Any one tell me how do I use Dispatch or any
        other method to write a code.
        If you are running on Windows, look into pywinauto
        (http://www.openqa.org/pywinauto/).
        >
        I have successfully used it to interact with a Flash animation running
        within an IE browser.
        >
        I also had to inspect the graphics displayed by the Flash animation, for
        this I used PIL (http://www.pythonware.com/products/pil/).
        >
        Good luck,
        -- Paul

        Comment

        • vithi

          #5
          Re: How to write code to get focuse the application which is open from server

          Dennis,
          I am sorry that was a typing error. I try like that
          app.Print.OK.Cl ick() but it was not working. The printer window was not
          IdentifiedIs their any method I can use to achive the same goal. How
          the window title was used as class name?. Could you please help me to
          solve this problem.
          thanks
          this is the error meassage

          Traceback (most recent call last):
          File "C:\Python24\te st1.py", line 10, in -toplevel-
          app.Print.Ok.Cl oseClick()
          File "c:\python24\py winauto\pywinau to\application. py", line 237, in
          __getattr__
          ctrls = _resolve_contro l(
          File "c:\python24\py winauto\pywinau to\application. py", line 854, in
          _resolve_contro l
          ctrl = _get_ctrl(crite ria)
          File "c:\python24\py winauto\pywinau to\application. py", line 622, in
          _get_ctrl
          dialog = controls.WrapHa ndle(
          File "c:\python24\py winauto\pywinau to\findwindows. py", line 62, in
          find_window
          windows = find_windows(** kwargs)
          File "c:\python24\py winauto\pywinau to\findwindows. py", line 177, in
          find_windows
          windows = findbestmatch.f ind_best_contro l_matches(
          File "c:\python24\py winauto\pywinau to\findbestmatc h.py", line 483, in
          find_best_contr ol_matches
          raise MatchError(item s = name_control_ma p.keys(), tofind =
          search_text)
          MatchError: Could not find 'Print' in '['', u'Transparent Windows
          Client0', u'Transparent Windows Client2', u'Transparent Windows
          Client1', u'Print - \\\\Remote', u'Transparent Windows Client', u'Print
          - \\\\RemoteTrans parent Windows Client']'

          This is the code
          import sys
          import time
          import application
          app = application.App lication()
          qi=app.window_( title_re = ".*ArcView. *")
          time.sleep(2)
          qi.TypeKeys("%F P")
          time.sleep(2)

          app.Print.Ok.Cl oseClick()


          Dennis Lee Bieber wrote:
          On 14 Jan 2007 21:11:35 -0800, "vithi" <vithi99@hotmai l.comdeclaimed
          the following in comp.lang.pytho n:
          >

          my code goes like that
          >
          "goes like"? Don't type similarities from memory -- cut&paste the
          actual code (or, preferably, a stripped down version that you've
          actually run) that shows the behavior in question.
          >
          app=application .Application()
          qi = app.window_(tit le_re = ".*arcMap.* ")
          qi.TypeKeys("%F P")
          app,Print.OK.Cl ick()
          And what is that last line supposed to be doing. "app,anythi ng" is
          two separate objects: an application object, and something called Print
          with an attribute called OK which itself has a method called Click
          >
          I suspect, at a minimum, that last line is supposed to be
          >
          app.Print.OK.Cl ick()
          ^ period, not

          Comment

          • vithi

            #6
            Re: How to write code to get focuse the application which is open from server

            Dennis,
            I am sorry that was a typing error. I try like that
            app.Print.OK.Cl ick() but it was not working. The printer window was not
            IdentifiedIs their any method I can use to achive the same goal. How
            the window title was used as class name?. Could you please help me to
            solve this problem.
            thanks
            this is the error meassage

            Traceback (most recent call last):
            File "C:\Python24\te st1.py", line 10, in -toplevel-
            app.Print.Ok.Cl oseClick()
            File "c:\python24\py winauto\pywinau to\application. py", line 237, in
            __getattr__
            ctrls = _resolve_contro l(
            File "c:\python24\py winauto\pywinau to\application. py", line 854, in
            _resolve_contro l
            ctrl = _get_ctrl(crite ria)
            File "c:\python24\py winauto\pywinau to\application. py", line 622, in
            _get_ctrl
            dialog = controls.WrapHa ndle(
            File "c:\python24\py winauto\pywinau to\findwindows. py", line 62, in
            find_window
            windows = find_windows(** kwargs)
            File "c:\python24\py winauto\pywinau to\findwindows. py", line 177, in
            find_windows
            windows = findbestmatch.f ind_best_contro l_matches(
            File "c:\python24\py winauto\pywinau to\findbestmatc h.py", line 483, in
            find_best_contr ol_matches
            raise MatchError(item s = name_control_ma p.keys(), tofind =
            search_text)
            MatchError: Could not find 'Print' in '['', u'Transparent Windows
            Client0', u'Transparent Windows Client2', u'Transparent Windows
            Client1', u'Print - \\\\Remote', u'Transparent Windows Client', u'Print
            - \\\\RemoteTrans parent Windows Client']'

            This is the code
            import sys
            import time
            import application
            app = application.App lication()
            qi=app.window_( title_re = ".*ArcView. *")
            time.sleep(2)
            qi.TypeKeys("%F P")
            time.sleep(2)

            app.Print.Ok.Cl oseClick()


            Dennis Lee Bieber wrote:
            On 14 Jan 2007 21:11:35 -0800, "vithi" <vithi99@hotmai l.comdeclaimed
            the following in comp.lang.pytho n:
            >

            my code goes like that
            >
            "goes like"? Don't type similarities from memory -- cut&paste the
            actual code (or, preferably, a stripped down version that you've
            actually run) that shows the behavior in question.
            >
            app=application .Application()
            qi = app.window_(tit le_re = ".*arcMap.* ")
            qi.TypeKeys("%F P")
            app,Print.OK.Cl ick()
            And what is that last line supposed to be doing. "app,anythi ng" is
            two separate objects: an application object, and something called Print
            with an attribute called OK which itself has a method called Click
            >
            I suspect, at a minimum, that last line is supposed to be
            >
            app.Print.OK.Cl ick()
            ^ period, not

            Comment

            • Gabriel Genellina

              #7
              Re: How to write code to get focuse the application which isopen from server

              At Monday 15/1/2007 15:53, vithi wrote:
              >I am sorry that was a typing error. I try like that
              >app.Print.OK.C lick() but it was not working. The printer window was not
              >IdentifiedIs their any method I can use to achive the same goal. How
              >the window title was used as class name?. Could you please help me to
              >solve this problem.
              app.Print looks for a window whose title contains the word "Print"
              (does it exist?), inside, looks for a control with "OK" (presumably a
              button), and sends it a mouse click event.
              There is a forum specific for pywinauto questions - see its homepage.


              --
              Gabriel Genellina
              Softlab SRL






              _______________ _______________ _______________ _____
              Preguntá. Respondé. Descubrí.
              Todo lo que querías saber, y lo que ni imaginabas,
              está en Yahoo! Respuestas (Beta).
              ¡Probalo ya!


              Comment

              • Mark

                #8
                Re: How to write code to get focuse the application which is open from server

                Hi,

                There are better places to find me then on comp.lang.pytho n (just too
                much traffic for me)
                pywinauto forums: http://forums.openqa.org/forum.jspa?forumID=15
                or subscribe pywinauto mailing list:
                Simple Windows GUI automation with Python. No pre-recording or window capture needed before use - just code and run :-)



                vithi wrote:
                <SNIP>
                MatchError: Could not find 'Print' in '['', u'Transparent Windows
                Client0', u'Transparent Windows Client2', u'Transparent Windows
                Client1', u'Print - \\\\Remote', u'Transparent Windows Client', u'Print
                - \\\\RemoteTrans parent Windows Client']'
                >
                This is the code
                import sys
                import time
                import application
                app = application.App lication()
                qi=app.window_( title_re = ".*ArcView. *")
                time.sleep(2)
                qi.TypeKeys("%F P")
                time.sleep(2)
                >
                app.Print.Ok.Cl oseClick()
                >
                >
                My guess is that problem above is that teh title of the window is
                u"Print - \\Remote", and "Print" is not enough information for
                pywinauto to go on.

                I suggest you replace the last line with one of the following...
                app.PrintRemote .Ok.CloseClick( )
                app.window_(tit le_re = "Print - .*").Ok.CloseCl ick()

                Someone also was wondering why they do not have to call
                Application.Sta rt() or Application.Con nect() explicitly - that is
                because the first call to app.window_() will initialize the application
                appropriately. The reason for this is that most usages ended up being
                a) Connect to a window with specific title, then use that window in the
                next line - so I was trying to avoid duplication.

                Thanks
                Mark

                Comment

                Working...