SPONSORS:






User Tag List

Results 1 to 7 of 7
  1. #1
    Junior Member
    Join Date
    Apr 2002
    Posts
    10
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Switching between windows using handles

    I'm testing a web application. It has a main window and up to twelve separate report windows, most of which share the same title. I want to switch to each of the report windows in turn, to make sure that actions in the main window haven't changed their contents. As I've opened each window, I've obtained its handle using GetHandle(). Can I use those handles to set the windows active?

    The only reference I found to handles in the online help was an explanation of how to obtain them; no mention of how to use them. I also searched this forum with no luck - someone asked this question in July, but got no answer. I'm hoping that doesn't mean it's impossible. If I've missed something obvious, I'm sorry.

    Thanks,

    Abigail.

  2. #2
    Senior Member
    Join Date
    Feb 2000
    Posts
    1,497
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Switching between windows using handles

    You don't need handles for that. Use the name you applied to each window in their declaration files instead. For example:


    John


    ------------------

  3. #3
    Junior Member
    Join Date
    Apr 2002
    Posts
    10
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Switching between windows using handles

    Thanks, but I don't think it's that easy in this case. I have 12 windows to check:

    6 are instances of window A as declared in the .inc file. They have Title A. Two have identical contents; the other four are all distinct.

    3 are instances of window B as declared in the .inc file. They have Title B, and are all distinct.

    3 are instances of window C as declared in the .inc file. They have Title C, and are all distinct.

    (Why this number? The purpose of the reports is to allow the user to print out information: for each report type, the user can choose to include all items, selected items, or just a single page. And there are two different locations from which reports of type A can be generated: we need to check that both code paths work correctly. It's important to have all the reports open at once to verify that the application does not confuse them, because the user might reasonably want to compare and contrast several at the same time.)

    I've chosen to declare an arbitrary instance of each report in the .inc file; its title and basic structure are applicable to all instances of that report, but the data in it (both the values themselves and the number of values) can't be expected to match those in any report generated during testing. I *could* produce a separate declaration for each version that I want to generate while testing, and I guess that would be my last resort, but I'd prefer not to.

    So I think if I tried ReportA.SetActive(), having switched off the uniqueness verification, Silk would pick one instance arbitrarily - probably the most recently opened instance. (Actually, when I tried it, Silk complained that it couldn't find any such window, but I expect that's surmountable.)

    Another complexity: One of the ways in which the report generation could go wrong is that, when a new report is generated, the old report window updates with the new report contents. So the same window might change in the middle of the test from an instance of window A to an instance of window B. And in this case, I want to be able to report that the window that used to hold report A1 now holds a copy of report B3 (or whatever), rather than just reporting that A1 doesn't exist any more.

    Sorry about the long response; I hope it makes sense.

    Abigail.


  4. #4
    Senior Member
    Join Date
    Feb 2000
    Posts
    1,497
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Switching between windows using handles

    <BLOCKQUOTE><font size="1" face="Verdana, Arial, Helvetica">quote:</font><HR>Originally posted by alg24:
    Thanks, but I don't think it's that easy in this case.
    I have 12 windows to check:
    6 are instances of window A as declared in the .inc file. They have Title A. Two have identical contents; the other four are all distinct.
    3 are instances of window B as declared in the .inc file. They have Title B, and are all distinct.
    3 are instances of window C as declared in the .inc file. They have Title C, and are all distinct.
    <HR></BLOCKQUOTE>

    Sure it is! Trust me!
    Factor-out all common characteristics and place them into distinct classes. Then address class-specific abilities inside each class. Finally assign those class names to the named entities in the declarations.
    <BLOCKQUOTE><font size="1" face="Verdana, Arial, Helvetica">quote:</font><HR>
    I've chosen to declare an arbitrary instance of each report in the .inc file; its title and basic structure are applicable to all instances of that report, but the data in it (both the values themselves and the number of values) can't be expected to match those in any report generated during testing. I *could* produce a separate declaration for each version that I want to generate while testing, and I guess that would be my last resort, but I'd prefer not to.
    <HR></BLOCKQUOTE>
    Multiples of a given class could be handled as individual entries in "list of windows Reports = {}". Add to the list as reports are opened, remove entries when they are closed. When you change input focus from one report to another change the index (of a global window variable) to point to the correct instance. "window CurrentReport = Reports[x]". All subsequent actions on any report then resolve down to CurrentReport.method() calls.

    This can either be accomplished using static declarations (ie: "I've chosen to declare an arbitrary instance of each report ") or by using constructors to create fully dynamic instance declarations from the relevant class.

    <BLOCKQUOTE><font size="1" face="Verdana, Arial, Helvetica">quote:</font><HR>
    So I think if I tried ReportA.SetActive(), having switched off the uniqueness verification, Silk would pick one instance arbitrarily - probably the most recently opened instance. (Actually, when I tried it, Silk complained that it couldn't find any such window, but I expect that's surmountable.)
    <HR></BLOCKQUOTE>
    This would likely only happen if your tags are defined too vaguely to be useful discriminators fpr recognizing the report that assumes current focus.

    John



    ------------------

  5. #5
    Senior Member
    Join Date
    Jun 2000
    Location
    Hartford, CT, USA
    Posts
    163
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Switching between windows using handles

    With due respect to what Miller has said...
    the question here is how do I execute or terminate a program or a service using its Handle? As a corrolory how do we get handle of a service without its GUI?

    ------------------
    Jaimini Bhatt
    jaiminita@hotmail.com
    jaiminita@yahoo.com
    Jaimini Bhatt

  6. #6
    Senior Member
    Join Date
    Sep 1999
    Location
    San Jose,CA,USA
    Posts
    340
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Switching between windows using handles

    Well I only worked the example with two notepad's with different titles. The answer to your post is if you want to work with window handles you need to employ the win32
    API calls against them.

    Yeah I know sounds hard .. it's not so bad and I include some simple code that set the windows active and even closes them for you:

    The first line
    use "msw32.inc"
    Is a silk wrap to include a lot of the win32 api .. fancy way of saying allows you to make dll calls directly. I think the win32 calls are preety obvious .. they haven't changed since windows 3.1 .. scary huh!

    Also the corallary .. there has been some really awesome tools out there for "Unix like" ps and kill utilities for windows.

    ps is the tool which lists processes
    kill is the tool that kills processes if you have the corresponding pid.

    They are free and when I go in tommorow I will post a follow up on the site with a url.

    They work great and really only require you to wrap the Sys_execute .. parse the output of ps .. to grab the pid .. and employ kill to "whack" the main window or service.

    Anyway I hope this helps ..

    ------------------
    "Smoke me a kipper, I'll be back for breakfast!"
    Sincerely
    Richard Weth
    Sr. QA Engineer
    mailto:rick_weth@yahoo.com

    [This message has been edited by rick_weth (edited 03-02-2003).]
    Smoke me a kipper, I'll be back for breakfast!
    Sincerely
    Richard Weth
    Sr. QA Engineer

  7. #7
    Junior Member
    Join Date
    Apr 2002
    Posts
    10
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Switching between windows using handles

    Thanks to everyone who replied.

    As it happens, shortly after I last posted I spotted the GetCloseWindows() method, which returns a list of the windows Silk would have to close to restore the base state. This gives me exactly what I need, i.e. a list of all the extra browser windows that have been opened, and seems to be working nicely. So I guess now we have three solutions that might help the next person who searches for this!

    Thanks for your help.

    Abigail.

 

 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

vBulletin Optimisation provided by vB Optimise v2.6.0 Beta 4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.0.9 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Questions / Answers Form provided by vBAnswers (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
vBNominatevBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Feedback Buttons provided by Advanced Post Thanks / Like (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Username Changing provided by Username Change (Free) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
BetaSoft Inc.
Digital Point modules: Sphinx-based search
All times are GMT -8. The time now is 07:32 AM.

Copyright BetaSoft Inc.