SPONSORS:






User Tag List

Thanks Thanks:  0
Likes Likes:  0
Dislikes Dislikes:  0
Results 1 to 9 of 9
  1. #1
    Junior Member
    Join Date
    Jun 2008
    Posts
    27
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Force close IE at start of script, error handling

    Hi all,

    Being a newbie to TestComplete, I've run into a few other questions. I do try to dig around and search for answers prior to posting to avoid duplication - but I am human, so please forgive if I overlooked something.

    I'm messing around testing an internal (test) website in JScript with TestComplete. One of the tasks we have is to load many different pages with a very similar URL (just different affiliates for a similar site).

    Anyway, I have the test data-driven and it seems to work ok. One of the things I do is call up IE7 by using TestedApps in the script...currently my script is something like:

    <font class="small">Code:</font><hr /><pre>
    TestedApps.iexplore.Run();
    BlahBlahBlah.code.here
    TestedApps.CloseAll(); </pre><hr />

    This works relatively well, as it cleans up the IE instance and fires up a new one with every iteration.

    Problem: for some odd reason, TC hangs on some test pages I hit. It's hit or miss....sometimes it's fine on a given page, other times it hangs seemingly indefinitely. Our test pages do contain a lot of adds/flash, so that might contribute....I'd like to get to the bottom of that eventually.

    Meantime, I'd really like the script to just kill IE off if it hangs, proceed, and start a new iteration (and new IE instance). Currently, it just hangs, the script throws exceptions, and it never really recovers (all other iterations fail after the first "hang" occurs).

    I tried this by adding a TestedApps.CloseAll() at the start of the script, but it's not working when I test it by opening IE before executing the script (likely because Close All will only close instances that TC started?). Perhaps my "test" of this by opening IE manually prior to executing is a bogus test because of this....



    Also, I have this in my Main, I guess it's sort of default error catching. I tried adding the TestedApps.CloseAll in there too (hoping it would close IE if an exception occurred)...hopefully this will do?

    <font class="small">Code:</font><hr /><pre> try
    {
    DDT.CSVDriver(Files.FileNameByName("Affiliates.txt "));
    DDT.CurrentDriver.DriveMethod("GetScreenshot.AffLa ndingPage");
    }
    catch(exception)
    {
    TestedApps.CloseAll();
    Log.Error("Exception", exception.description);

    } </pre><hr />


  2. #2
    Senior Member
    Join Date
    Oct 2003
    Posts
    928
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Force close IE at start of script, error handling

    Hi Eman77,

    [ QUOTE ]
    likely because Close All will only close instances that TC started?

    [/ QUOTE ]
    Yes, that's right.

    [ QUOTE ]
    I'd really like the script to just kill IE off if it hangs, proceed, and start a new iteration

    [/ QUOTE ]
    Try using the following approach:
    <font class="small">Code:</font><hr /><pre>
    for (var p = Sys.WaitProcess("iexplore"); p.Exists; p = Sys.WaitProcess("iexplore"))
    {
    p.Close();
    p.WaitProperty("Exists", false);
    }
    </pre><hr />


    [ QUOTE ]

    Also, I have this in my Main, I guess it's sort of default error catching. I tried adding the TestedApps.CloseAll in there too (hoping it would close IE if an exception occurred)...hopefully this will do?


    [/ QUOTE ]
    Yes. If an exception occurs, the "catch" block gets executed.
    I recommend that you read the "Handling Exceptions in Scripts" Help topic to learn more about this.
    Regards,
    Alex - SmartBear Support

  3. #3
    Junior Member
    Join Date
    Jul 2007
    Posts
    17
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Force close IE at start of script, error handling

    Hi all,

    I have the same problem. I am working on IE7 and when i am executing the script, in the middle IE is hanging and not able to proceed further.

    Scipts are running correctly in IE6. What could be the problem?

    It would be very helpful if anyone gives me a solution.

    Thanks in Advance!

  4. #4
    Junior Member
    Join Date
    Jun 2008
    Posts
    27
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Force close IE at start of script, error handl

    Thanks Alex, I'll give that a shot for my "hanging" script issues.

    I did check out the exception handling section, saw what I was doing wrong, and now can use it properly to do what I need.

    Additionally though - when exceptions occur, I'd like to write to a new text file (comma delimited?) that lists the variable values I'm using when those problems occur. This allows me to check that output file after a run, and even use that as a data file for the next run just to re-do the problem ones.

    So, for example, for each exception that occurs, it writes a line to the text file with the values for variables X and Y to that log. So with each script iteration, it keeps appending to that file (the variables change w/each iteration from the data file).

    I'm digging through the help currently to try to see what I can find.....

  5. #5
    Junior Member
    Join Date
    Jun 2008
    Posts
    27
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Force close IE at start of script, error handl

    To clarify, I'd put a piece of code in the exception handling section of my script that does something like:

    open file -&gt; write variables

    every time I hit an exception.

  6. #6
    Senior Member
    Join Date
    Oct 2003
    Posts
    928
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Force close IE at start of script, error handling

    Hello jaanik,

    It is hard to determine the cause of the problem without having any technical information.
    If you are able to reproduce the hang, please send us a script demonstrating the problem and we will try to find its cause.
    Thanks in advance.
    Regards,
    Alex - SmartBear Support

  7. #7
    Senior Member
    Join Date
    Oct 2003
    Posts
    928
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Force close IE at start of script, error handl

    Hello Eman77,

    Take a look at the "Working With Files From Scripts" help topic. Does this help?
    Regards,
    Alex - SmartBear Support

  8. #8
    Junior Member
    Join Date
    Jun 2008
    Posts
    27
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Force close IE at start of script, error handl

    Hi Alex, I have been looking through that section. It helps...a little. I'm currently having some issues implementing the stuff there, but will try to work through it before posting for more help here. I think I'm on the right track though.


    Unfortunately, a nice end-to-end example of "writing to an output file" is not present in the Help. As a general criticism, the Help in general seems to be lacking in clearcut examples - which are key for non-developer type folks like me. I can't just take a method definition and whip something up, for example. I need to be spoon fed examples, then I customize it and get it to work for me.

    Anyway, I like TestComplete in general, but the Help at times is a bit lacking...I'd love to see more examples there in the future. (Not that you were looking for contructive criticism, but there you go...)

  9. #9
    Senior Member
    Join Date
    Oct 2003
    Posts
    928
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Force close IE at start of script, error handl

    Hello Eman77,

    Thank you for your feedback. We try to add useful sample scripts to our Help system. If you can't find a sample, let us know, and we will consider adding it.

    As for appending data to a file, the "Working With Files From Scripts" help topic contains the following sample script that demonstrates how to do this:

    <font class="small">Code:</font><hr /><pre>
    function Test()
    {
    ForReading = 1, ForWriting = 2, ForAppending = 8, TristateFalse = 0
    var fs, f, sPath;
    sPath = "c:\\MyFile.txt";
    // Creates a new file object
    fs = Sys.OleObject("Scripting.FileSystemObject");
    // Note that you can also create the FileSystemObject
    // using the following code:
    // fs = new ActiveXObject("Scripting.FileSystemObject")
    if (!fs.FileExists(sPath))
    {
    objFile = fs.CreateTextFile(sPath);
    objFile.Close();
    }
    f = fs.OpenTextFile(sPath, ForAppending, TristateFalse);
    f.Write("Hello, world!\n");
    f.Close();
    }
    </pre><hr />

    If you have any questions regarding the sample, please feel free to let me know.
    Regards,
    Alex - SmartBear Support

 

 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Search Engine Optimisation provided by DragonByte SEO v2.0.36 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Resources saved on this page: MySQL 10.71%
vBulletin Optimisation provided by vB Optimise v2.6.4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.2.8 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
vBNominate (Lite) - vBulletin 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 01:37 AM.

Copyright BetaSoft Inc.