SPONSORS:






User Tag List

Results 1 to 8 of 8
  1. #1
    Member
    Join Date
    Sep 2001
    Posts
    69
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Making code more readable

    I have been trying to make some test cases more readable and ran into a problem. I have code in test cases that look like the following:

    CreateAccountStep1.HtmlTable1.HtmlColumn3.HtmlTabl e1.HtmlColumn3.UserName.SetText ("joev_12")

    I want to be able to make this code more readable and maintainable. I would like it to read something like this:

    CreateAccountStep1.Registration.UserName.SetText(" joev_12")

    Now the 'Registration' object should be basically equal to 'HtmlTable1.HtmlColumn3.HtmlTable1.HtmlColumn3'. I tried to create a new window in my test frame but I had some problems. I did something like this in my frame but it didn't work:

    [-] window HtmlColumn Naviagtion
    [ ] tag "MyApp"
    [ ] parent MyApp.HtmlTable1.HtmlColumn3.HtmlTable1

    I don't think the parent statement allows the type of syntax shown above. Anyway, I know this is possible I have seen it before I just don't remeber how to go about doing it. Any ideas on how I can change my test frame to do this?

    Thanks,

    - Joe



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

  2. #2
    Senior Member
    Join Date
    Jun 2000
    Location
    Sunyyvale CA USA
    Posts
    422
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Making code more readable

    Best way to do this is make evrything as a function that takes a parameter. small example for login.

    website.HtmlText("#1").SetText ("userid")
    website.HtmlText("#2").SetText ("password")


    make this as a function as follows
    public login (string username, string password)
    website.HtmlText("#1").SetText (username)
    website.HtmlText("#2").SetText (password)

    use this in a testcase
    testcase tmp1 ()
    Login (username, password)

    Nobody bothers to see how u have written the function as long as its working.

    Hope this may help u.

    ------------------
    Sree

    [This message has been edited by sree (edited 09-05-2001).]
    Sree

  3. #3
    Member
    Join Date
    Dec 2000
    Location
    San Francisco, CA
    Posts
    51
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Making code more readable

    try this
    <BLOCKQUOTE><font size="1" face="Verdana, Arial, Helvetica">quote:</font><HR>Originally posted by Joe_v:
    I have been trying to make some test cases more readable and ran into a problem. I have code in test cases that look like the following:

    CreateAccountStep1.HtmlTable1.HtmlColumn3.HtmlTabl e1.HtmlColumn3.UserName.SetText ("joev_12")

    I want to be able to make this code more readable and maintainable. I would like it to read something like this:

    CreateAccountStep1.Registration.UserName.SetText(" joev_12")

    Now the 'Registration' object should be basically equal to 'HtmlTable1.HtmlColumn3.HtmlTable1.HtmlColumn3'. I tried to create a new window in my test frame but I had some problems. I did something like this in my frame but it didn't work:

    [-] window HtmlColumn Naviagtion
    [ ] tag "MyApp"
    [ ] parent MyApp.HtmlTable1.HtmlColumn3.HtmlTable1

    I don't think the parent statement allows the type of syntax shown above. Anyway, I know this is possible I have seen it before I just don't remeber how to go about doing it. Any ideas on how I can change my test frame to do this?

    Thanks,

    - Joe

    <HR></BLOCKQUOTE>

    ------------------
    kalabog73@hotmail.com

    [This message has been edited by kalabog (edited 09-05-2001).]

  4. #4
    Member
    Join Date
    Sep 2001
    Posts
    69
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Making code more readable

    Thanks, kalabog!! This worked.

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

  5. #5
    Junior Member
    Join Date
    Aug 2001
    Posts
    27
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Making code more readable

    You might wnat to try "with" statement if those statements are togather.

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

  6. #6
    Senior Member
    Join Date
    Aug 2000
    Location
    NY,NY,USA
    Posts
    103
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Making code more readable

    Keep it simple

    Declare a new window, then reference that window:

    window ModifyClient = BrowserPage.BrowserChild("#3").BrowserChild("#2"). BrowserChild("#2")

    Then

    ModifyClient.HtmlPopupList("Select an industry group from the[1]|#1").SetFocus()

  7. #7
    Junior Member
    Join Date
    Apr 2001
    Location
    San Francisco, Ca. USA
    Posts
    11
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Making code more readable

    russromei is right. I have a file entirely dedicated to aliasing statements like these, and though the initial workload was large, the benefits hugely outweigh the initial time cost and keep coming.


    ------------------
    Robert

  8. #8
    Senior Member
    Join Date
    Jun 2000
    Location
    Chicago, IL USA
    Posts
    383
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Making code more readable

    I also alias these long references with "window" declarations. I try to make alias "groups" based on functionality that will not change when the appearance of the window changes in future versions. This makes future updates easier:

    Becomes:

    In the declarations:
    In the test:
    [This message has been edited by RobKapteyn (edited 09-07-2001).]
    Rob Kapteyn, CSTE
    RobKapteyn@gmail.com

 

 

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 09:19 AM.

Copyright BetaSoft Inc.