SPONSORS:






User Tag List

Thanks Thanks:  0
Likes Likes:  0
Dislikes Dislikes:  0
Results 1 to 10 of 10
  1. #1
    Junior Member
    Join Date
    Mar 2009
    Posts
    6
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    XML file for input (Data driven test cases)

    Does silk support xml file for passing data to test cases?

  2. #2
    Member
    Join Date
    Jul 2006
    Location
    Ma
    Posts
    62
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: XML file for input (Data driven test cases)

    Try the XMLParserClass in the downloads tab on this sight.
    If that doesnt have what you are looking for try a vbs script.

    I import all my specifications into each testcase from xml then write the results back. Then use a style sheet to display the testcase results.
    SILK noob

  3. #3
    Junior Member
    Join Date
    Mar 2009
    Posts
    6
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: XML file for input (Data driven test cases)

    hi,

    Could you please share how the test cases read a XML file? I would like to use the XML file instead of a test file.

    Please suggest.

  4. #4
    Member
    Join Date
    Mar 2009
    Posts
    36
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: XML file for input (Data driven test cases)

    Does anyone know how to do this?

  5. #5
    Member
    Join Date
    Jul 2006
    Location
    Ma
    Posts
    62
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: XML file for input (Data driven test cases)

    Here is a quick example just to get the basics of 'one' way to do it:

    XML FILE
    <font class="small">Code:</font><hr /><pre>
    &lt;?xml version="1.0" encoding="UTF-8"?&gt;
    &lt;root&gt;

    &lt;SomeNode&gt;
    &lt;ID&gt;Node 1&lt;/ID&gt;
    &lt;description&gt;Something to do with something node 1 &lt;/description&gt;
    &lt;/SomeNode&gt;

    &lt;SomeNode&gt;
    &lt;ID&gt;Node2&lt;/ID&gt;
    &lt;description&gt;Something else about Node 2&lt;/description&gt;
    &lt;/SomeNode&gt;

    &lt;/root&gt;
    </pre><hr />

    DisplayXML.vbs
    <font class="small">Code:</font><hr /><pre>
    xmlFile = Wscript.Arguments(0)
    Set xmlDoc = Createobject ( "Microsoft.XMLDOM" )
    xmlDoc.async = False
    xmlDoc.resolveExternals = False

    If ( xmlDoc.Load ( xmlFile ) ) then

    for each Node in xmlDoc.documentElement.childNodes

    Wscript.Echo "Node: " &amp; Node.nodename &amp;VbCr&amp; "Text: " &amp; Node.text

    next

    Else ' Xml File Load Error

    Wscript.Echo "LOAD ERROR:" &amp; xmlFile &amp;VbCr&amp;_
    "Line #" &amp; xmlDoc.ParseError.Line &amp;VbCr&amp;_
    "Error #" &amp; xmlDoc.parseError &amp;VbCr&amp;_
    "Possible Error Cause: " &amp; xmlDoc.ParseError.Reason

    End If
    </pre><hr />

    Silk
    <font class="small">Code:</font><hr /><pre>
    STRING xmlFile = "C:\Folder\file.xml"
    STRING pathVbs = "C:\SomeFolder"
    Sys_Execute ( "Cscript.exe {PathVbs}\DisplayXML.vbs {Chr(34)}{xmlFile}{Chr(34)} " , cmdReturn )
    LISTPRINT ( cmdReturn )
    </pre><hr />

    Now theres not much error handling here. After you get the script working right, you may want to write a silk wrapper function or throw some checking in the file.

    Im not an xml/vbs Guru but i can try to give you a hand with altering the .vbs file to fit your needs.

    What does your xml look like? And what data do you need from it?
    SILK noob

  6. #6
    Member
    Join Date
    Mar 2009
    Posts
    36
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: XML file for input (Data driven test cases)

    I have attached a example xml file. I need to read all of the data into records that I have created in silk. I was hoping it would be easy like reading a text file but this method might be hard for what I need...

    puesdo code
    myCampaign.name = //search xml file
    for mediaplan in //search xml for media plans
    //process media plan
    //etc
    Attached Files Attached Files

  7. #7
    Member
    Join Date
    Jul 2006
    Location
    Ma
    Posts
    62
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: XML file for input (Data driven test cases)

    Well this was a tricky one.

    The best I could come up with is using the full xPath in a second argument.

    DisplayXML.vbs
    <font class="small">Code:</font><hr /><pre>

    If ( xmlDoc.Load ( xmlFile ) ) then

    Set Node = xmlDoc.selectSingleNode ( wscript.Arguments(1) )
    wscript.echo Node.nodeName &amp; "=" &amp; Node.text


    Else ' Xml File Load Error

    Wscript.Echo "LOAD ERROR:" &amp; xmlFile &amp;VbCr&amp;_
    "Line #" &amp; xmlDoc.ParseError.Line &amp;VbCr&amp;_
    "Error #" &amp; xmlDoc.parseError &amp;VbCr&amp;_
    "Possible Error Cause: " &amp; xmlDoc.ParseError.Reason

    End If

    </pre><hr />


    Example:

    If you want the campaign name value

    Cscript.exe c:\DisplayXML.vbs C:\file.xml campaign/name
    returns:
    name=TemplateCampaign

    If you want the mediaplan type value:

    Cscipt.exe c:\DisplayXML.vbs C:\file.xml campaign/mediaplans/mediaplan/type

    returns:
    type=Internet Radio

    or ( this way is a little messy )
    Second argument is Either campaign | mediaplan | flight

    DisplayXML.vbs
    <font class="small">Code:</font><hr /><pre>
    If ( xmlDoc.Load ( xmlFile ) ) then

    Set NodeList = xmlDoc.getElementsByTagName( Wscript.Arguments(1) &amp; "/*")
    iNode = NodeList.Length
    For i = 1 To iNode
    Set CurrNode = NodeList.nextNode
    wscript.Echo CurrNode.nodeName &amp; "=" &amp; CurrNode.text
    Next

    Else ' Xml File Load Error

    Wscript.Echo "LOAD ERROR:" &amp; xmlFile &amp;VbCr&amp;_
    "Line #" &amp; xmlDoc.ParseError.Line &amp;VbCr&amp;_
    "Error #" &amp; xmlDoc.parseError &amp;VbCr&amp;_
    "Possible Error Cause: " &amp; xmlDoc.ParseError.Reason

    End If
    </pre><hr />

    Example:
    Cscript.exe c:\DisplayXML.vbs C:\file.xml campaign

    Returns:

    name=TemplateCampaign
    client=TemplateClient
    startdate=01/01/2009
    enddate=01/01/2009
    restrictdemographicpercent=5
    gender=Persons
    agegroup=12+
    markets=New York,NY New York,NY
    mediaplans=Internet Radio Template Campaign - Internet Radio 123456789 100000 impressions or spots 01/01/2009 01/01/2009 CBS1 CBS1 Flight1 01/01/2009 01/01/2009 50 50 true or false Monday Monday Monday 6a-10a 6a-10a 6a-10a creative1 creative1 true or false filename filename url filename url CBS1 CBS1

    Example
    Cscript.exe c:\DisplayXML.vbs C:\file.xml flight

    returns:

    name=Flight1
    startdate=01/01/2009
    enddate=01/01/2009
    trafficpercentrequested=50
    trafficnumberrequested=50
    trafficdistrubte=true or false
    schedule=Monday Monday Monday 6a-10a 6a-10a 6a-10a
    creative=creative1 creative1 true or false filename filename url filename url
    stations=CBS1 CBS1

    perhaps just reading the file.xml in silk is better.
    Sorry i couldnt be more help.
    SILK noob

  8. #8
    Member
    Join Date
    Mar 2009
    Posts
    36
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: XML file for input (Data driven test cases)

    perhaps just reading the file.xml in silk is better. What do you mean by that?

  9. #9
    Member
    Join Date
    Jul 2006
    Location
    Ma
    Posts
    62
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: XML file for input (Data driven test cases)

    I meant that if there is no better alternative to get the data, just read the file in silk ( fileOpen( ) ) and process each line.

    Were any of those scripts helpful?
    SILK noob

  10. #10
    Member
    Join Date
    Mar 2009
    Posts
    36
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: XML file for input (Data driven test cases)

    They were... It is a hack job but I can read all the data I need from the xml now...

 

 

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.34%
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 12:20 PM.

Copyright BetaSoft Inc.