Parameterized Test Lists? SOLVED?

3 posts, 0 answers
  1. Ray
    Ray avatar
    6 posts
    Member since:
    Jul 2019

    Posted 09 Sep Link to this post

    Perhaps. We will see.

    I see many questions about parameterization when running test lists on the forums and they all answer one thing: "BaseURL". But I want to parameterize on several other criteria. Can I? I cannot see a way to do it. Always the answer seems to be that we should use BaseURL. We have 3 custom properties in a Test. But how many in Test List? None.

    So, what to do?

    Well, Telerik is telling us to use the BaseURL.

    A solution is this, I use one test step for all my logins. I need to connect to http://foobar.com

    My tests have:

             BaseURL = "http://foobar.com"

    and my test lists have this and I now have three custom settings in my Test List, or however many I want.

             BaseURL = "http://foobar.com/ray_x=thing1,ray_y=thing2,ray_z=whatever".

    And now, with the code below, I see this in my log when I am running from the test:

    '9/9/2019 4:02:24 PM' - Using 'https://foobar.com' as base url.
    '9/9/2019 4:02:24 PM' - LOG: p size = 3
    '9/9/2019 4:02:24 PM' - LOG: p[0]: "https:"
    '9/9/2019 4:02:24 PM' - LOG: p[1]: ""
    '9/9/2019 4:02:24 PM' - LOG: p[2]: "foobar.com"
    '9/9/2019 4:02:24 PM' - LOG: q size = 1
    '9/9/2019 4:02:24 PM' - LOG: realUrl: "https://foobar.com"
    '9/9/2019 4:02:24 PM' - LOG: paramstr: ""

    And I see this in my log when I am running from my test list:

    '9/9/2019 4:01:48 PM' - Using 'http://foobar.com/ray_x=thing1,ray_y=thing2,ray_z=whatever' as base url.
    '9/9/2019 4:01:48 PM' - LOG: p size = 3
    '9/9/2019 4:01:48 PM' - LOG: p[0]: "http:"
    '9/9/2019 4:01:48 PM' - LOG: p[1]: ""
    '9/9/2019 4:01:48 PM' - LOG: p[2]: "foobar.com/ray_x=100,ray_y=200"
    '9/9/2019 4:01:48 PM' - LOG: q size = 2
    '9/9/2019 4:01:48 PM' - LOG: realUrl: "https://foobar.com"
    '9/9/2019 4:01:48 PM' - LOG: paramstr: "ray_x=thing1,ray_y=thing2,ray_z=whatever"

    And the test and the test list work the same.

    If I have paramStr, I split it up by commas and I am done.

    And I used the BaseURL and nothing else. :--)

    cheers - ray

     

            [CodedStep(@"Navigate to : 'http://foobar.com'")]
            public void MinimalLogin_CodedStep1()
            {
                String baseUrl = ActiveBrowser.Manager.Settings.Web.BaseUrl.ToString();

                String[] sep = { "/" };

                String[] p = baseUrl.Split(sep, 3, StringSplitOptions.None);
                Log.WriteLine("p size = " + p.Length);

                Log.WriteLine("p[0]: \"" + p[0] + "\"");
                Log.WriteLine("p[1]: \"" + p[1] + "\"");
                Log.WriteLine("p[2]: \"" + p[2] + "\"");

                String[] q = p[2].Split(sep, 2, StringSplitOptions.None);
                Log.WriteLine("q size = " + q.Length);

                String realUrl;
                String paramStr;

                if (q.Length == 1) {
                    realUrl = p[0] + "//" + p[2];
                    paramStr = "";
                }
                else {
                    realUrl = p[0] + "//" + q[0];
                    paramStr = q[1];
                }
                Log.WriteLine("realUrl: \"" + realUrl + "\""); 
                Log.WriteLine("paramstr: \"" + paramStr + "\"");

                ActiveBrowser.NavigateTo(realUrl + "admin.cgi", true);
             }

    }

     

    ps:So, why do I need to do the split twice? If I knew the insides of th URL structure, I would know. But it works. Done and done.

     

  2. Ray
    Ray avatar
    6 posts
    Member since:
    Jul 2019

    Posted 11 Sep in reply to Ray Link to this post

    Yeah. And I could have just used 

             BaseURL = "http://foobar.com,ray_x=thing1,ray_y=thing2,ray_z=whatever"

    and split based on commas and split only once. Whatevs.

    And, hey, premature optimization is the root of all evil. (DK)


  3. Elena
    Admin
    Elena avatar
    1155 posts

    Posted 12 Sep Link to this post

    Hello Ray,

    Thanks for sharing your ideas in public and making them available for our customer base. 

    Regards,
    Elena
    Progress Telerik
     
    The New Release of Telerik Test Studio Is Here! Download, install,
    and send us your feedback!
Back to Top