SPONSORS:






User Tag List

Thanks Thanks:  0
Likes Likes:  0
Dislikes Dislikes:  0
Results 1 to 5 of 5
  1. #1
    Member
    Join Date
    Feb 2005
    Location
    jersey
    Posts
    42
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Compare weblinks with parameter names

    I dont know how to explain this but i will give it a try.

    The code below does the following thing. It picks up a parameter name from the list of parameters available(which are nothing but the all possible links available in the app) in the datatable and then goes and picks up the first link from the webtable and compares it if not goes to second link and compares it and when it finds a match, first it goes into the first if loop and a value C = "Available" is assigned and now it also picks up the value present in the parameter(which can be "Available" or "Unavailable"). It compares the values and presents the result. Now this part works fine. Also the iteration goes from column to column as that is how my datatable is.

    But there is another condition here, i.e when it has not found a single match for the particular parameter name it picked. Now i tried to introduce another loop right after next stmt but that would be a disaster since everything is running in a loop here, even after finding even a right value the first loop will continue all the way till it reaches the end and execute the values in the next after statement too. Meaning i need something that would skip this whole loop when the right value is found and continue to go to next parameter. I did use the "exit for" but still it would transfer the control to stmts after next.

    So in summary this is what i want, once the match is found i need it to write the results and skip to the next parameter or column and if a match is never found i need a stmt just like the first loop stating that this particular link that is in the parameter is unavailable.

    Note:The datatable is in the form of a matrix with link name as parameter names and whether available or unavailable as a value for the corresponding parameter. This has to be done for multiple users and thats why the matrix.


    Set MyObject = Description.Create()
    MyObject("micclass").Value = "Link"
    Set LinkObject = Browser("Welcome to IE").Page("Welcome to IE").ChildObjects(MyObject)
    NumberofLinks = LinkObject.Count
    ParamTotal = DataTable.GetSheet("homepagelinks").GetParameterCo unt
    For j = 1 To ParamTotal
    P = DataTable.GetSheet("homepagelinks").GetParameter(j ).Name
    B = Replace(P,"_"," ")
    For i = 0 To NumberofLinks-1
    MyString = LinkObject(i).GetROProperty("innertext")
    D = StrComp(B,MyString,1)
    A = Datatable.GetSheet("homepagelinks").Getparameter(j )
    If D = 0 Then
    C = "AVAILABLE"
    If A=C Then
    Reporter.ReportEvent micPass,B,"was available"
    Else
    Reporter.ReportEvent micFail,B,"was not available"
    End If
    End If
    Next
    Next

    I would'nt ask you to break your brains over it but gimme some suggestion like change in code or the way the data is taken in or even the whole approach. I just need one more brain working on it i am tired doing this alone.

    Thanks guys for reading this far. frankly, thats a task in itself.

  2. #2
    Super Member
    Join Date
    Oct 2004
    Posts
    1,222
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Compare weblinks with parameter names

    NumberofLinks = LinkObject.Count
    ParamTotal = DataTable.GetSheet("homepagelinks").GetParameterCo unt

    For j = 1 To ParamTotal

    P = DataTable.GetSheet("homepagelinks").GetParameter(j ).Name
    B = Replace(P,"_"," ")

    flag = 0

    For i = 0 To NumberofLinks-1

    If flag = 0 Then

    MyString = LinkObject(i).GetROProperty("innertext")
    D = StrComp(B,MyString,1)
    A = Datatable.GetSheet("homepagelinks").Getparameter(j )

    If D = 0 Then
    C = "AVAILABLE"

    If A=C Then
    Reporter.ReportEvent micPass,B,"was available"
    flag = 1
    End If

    End If

    End If

    Next

    If flag = 0 Then
    Reporter.ReportEvent micFail,B,"was not available"
    End If


    Next
    (I'm hiring Software Development Engineers in Test in Seattle, WA)

  3. #3
    Super Member
    Join Date
    Oct 2004
    Posts
    1,222
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Compare weblinks with parameter names

    Raj,

    This is what I've done to your code. Before the 2nd For loop in your code I initialize a flag value as 0. This flag value will only change within the loop if a match is found. When this flag value changes, the statements within the For loop are ignored.
    If however the entire For loop is completed without a match the flag value remains unchanged and a fail report is sent commenting "unavailable". In your previous code this "unavaialble" is sent everytime there is a mismatch. In my code it will be sent just once. If you wish to send this with every mismatch you can simply move the If...Then for the "unavailable" within the For loop as it was before.

    The changes I have made are in bold italics. I haven't run the code so I cant say for sure if it will work. It seems logically right to me. Sorry if it's not though.

    Also I'm not a programming expert but I think if you reduce the number of variables in your code it will be more readable and easier to understand when you try to debug. For example C ="Available" is not necessary. Simply have If A = "Available". You get rid of C. Same for some of the other variables in the code. The more variables you have, the more you have to keep track of and manage.

    Goodluck. I hope this works for you.
    (I'm hiring Software Development Engineers in Test in Seattle, WA)

  4. #4
    Member
    Join Date
    Feb 2005
    Location
    jersey
    Posts
    42
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Compare weblinks with parameter names

    Mark,

    It worked just right. Actually there was one another method which i actually implemented before i got this answer from you i.e

    I took the that if i = Number of links(total number of links) then it must have literally scanned everysingle link for the given parameter and so there should not be any link as mentioned. But that would be a probs if the last link was the one that found a match. But with this i would not that problem.

    And yes i really need to look into a way to reduce the number of variables in there.

    Thanks Mark. The solution was simple and very effective.

    raj.

  5. #5
    Super Member
    Join Date
    Oct 2004
    Posts
    1,222
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Compare weblinks with parameter names

    No worries Raj.
    (I'm hiring Software Development Engineers in Test in Seattle, WA)

 

 

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 11.54%
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 08:32 AM.

Copyright BetaSoft Inc.