Cann't launch the page that has encoded reserved characters in URL

4 posts, 0 answers
  1. Yan
    Yan avatar
    1 posts
    Member since:
    May 2011

    Posted 12 Aug 2011 Link to this post

    // Launch the page

    A decoded the URL string, "http://localhost/myapp/object/display/ObjRef///MainSite/5100.MT1", was sent to the browser and resulted in an error.

  2. Plamen
    Plamen avatar
    8 posts

    Posted 15 Aug 2011 Link to this post

    Hello Yan,

    I'm sorry you are running into this problem. It is a well known problem caused by the .Net logic we use and not by some implementation specific to Test Studio. The culprit is this URI class and more specifically:
    By default, any reserved characters in the URI are escaped in accordance with RFC 2396. This behavior changes if International Resource Identifiers or International Domain Name parsing is enabled in which case reserved characters in the URI are escaped in accordance with RFC 3986 and RFC 3987.
    As part of canonicalization in the constructor for some schemes, escaped representations are compacted. The schemes for which URI will compact escaped sequences include the following: file, http, https, net.pipe, and net.tcp. For all other schemes, escaped sequences are not compacted. For example: if you percent encode the two dots ".." as "%2E%2E" then the URI constructor will compact this sequence for some schemes. For example, the following code sample shows a URI constructor for the http scheme. 
     Uri uri = new Uri("http://myUrl/%2E%2E/%2E%2E"); Console.WriteLine(uri.AbsoluteUri); Console.WriteLine(uri.PathAndQuery); When this code is executed, it returns the following output with the escaped sequence compacted.
    Previous customers have worked around the issue by creating a page with hyperlinks in it. By clicking a link with the URL, the issue was bypassed.
    I hope this helps!

    Best wishes,
    the Telerik team
    Vote for Telerik Test Studio at the Annual Automation Honors Voting!
  3. Adam
    Adam avatar
    1 posts
    Member since:
    Oct 2013

    Posted 07 Oct 2013 Link to this post

    This is a really frustrating bug.  Fortunately, you don't have to create a separate page with hyperlinks just to work around it.  Assuming your page has at least one anchor on it, the following extension method that we use should get you what you're needing.  It just hijacks an anchor, changes its href, and clicks it.  And of course if your home page has no hyperlinks, then you should be able to just as easily use jQuery (or plain JavaScript) to create and attach one). 

    public static void GoToHash(this BaseTest B, string hash, string userLogin = BaseSettings.AutomatedTesterLoginValue)
        B.ActiveBrowser.Actions.InvokeScript("var a = jQuery('a:visible:first');a.attr('href', '" + BaseSettings.websiteRoot + userLogin + hash + "');a[0].click();");
  4. Velin Koychev
    Velin Koychev avatar
    88 posts

    Posted 09 Oct 2013 Link to this post

    Hi Adam,

    Thank you for sharing this solution and helping others. We really appreciate it. 

    I have also updated your Telerik points.

    Velin Koychev
    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
Back to Top