This is a migrated thread and some comments may be shown as answers.

Conditional step based on active URL

3 Answers 116 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Alex
Top achievements
Rank 1
Alex asked on 31 Aug 2015, 10:50 AM

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.

3 Answers, 1 is accepted

Sort by
0
Accepted
Cody
Telerik team
answered on 31 Aug 2015, 10:05 PM
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!
0
Ryan
Top achievements
Rank 1
answered on 18 May 2017, 05:45 PM

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.

0
Elena
Telerik team
answered on 23 May 2017, 12:15 PM
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!
Tags
General Discussions
Asked by
Alex
Top achievements
Rank 1
Answers by
Cody
Telerik team
Ryan
Top achievements
Rank 1
Elena
Telerik team
Share this question
or