Conditional step based on active URL

4 posts, 1 answers
  1. Alex
    Alex avatar
    5 posts
    Member since:
    Jun 2015

    Posted 31 Aug 2015 Link to this post

    Hi,

    I would like to use conditional step (using if...else) based on active URL.

    For example, if after performing some action i am navigated to specific url - additional step will be executed. If browser url does not contains some value (or not equal to given url) - do nothing, just continue the regular test flow.

    I can add the coded step to verify the URL, but i'm not able to use the bool value from it into 'If' condition. Any workaround ideas?

    Something like this:

    string Url = ActiveBrowser.Url;
    bool is​PageOpened;
    is​PageOpened = Url.Contains("Start.aspx");​

     

    Thanks in advance.

  2. Answer
    Cody
    Admin
    Cody avatar
    3360 posts

    Posted 31 Aug 2015 Link to this post

    Hello Alex,

    I am sorry but our IF/ELSE block will not accept a URL condition or bool value as the condition to test. It can only use some property of an existing UI element, such as value or visibility, or the presence/absence of a specific element for the condition.

    What you're after, do something only if the URL contains some string, can only be done in a coded step.

    Regards,
    Cody
    Telerik
     
    The New Release of Telerik Test Studio Is Here! Download, install,
    and send us your feedback!
  3. Ryan
    Ryan avatar
    12 posts
    Member since:
    Sep 2014

    Posted 18 May in reply to Cody Link to this post

    what would be the coded step for this process?

    I want to verify a particular part of the URL based on some properties that get submitted on the page prior.

  4. Elena Tsvetkova
    Admin
    Elena Tsvetkova avatar
    519 posts

    Posted 23 May Link to this post

    Hello Ryan,

    Thank you for your interest in Telerik Test Studio. 

    Please find below a line of code which will get the URL of the current active browser and will store it to a string variable. 

    string myURL = this.ActiveBrowser.Url.ToString();

    You could include this variable to your custom code as per the requirements. 

    I hope this will be helpful to you! 

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