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

Trying to grab current url during Web test

1 Answer 179 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
April
Top achievements
Rank 1
April asked on 08 Nov 2018, 09:30 PM

I'm trying to grab the current url during a test and append some text on the end of it, to navigate to a certain page.

For context, we have both a production and debug server. I figured it would be easier instead of toggling between the debug/prod urls in a NavigateTo step (which would also defeat the purpose of continuous integration because we would have to manually change it).

However, what I came up with, I'm getting a compiler error:

...tstest.cs(56,33) : error CS0103: The name 'HttpContext' does not exist in the current context

The namespace that is supposed to be used according to Microsoft is System.Web. 

This is the code block that I'm using:

                  string currentUrl = HttpContext.Current.Request.Url.AbsoluteUri;
            
       //Append the /share to the url
       string urlWeWant = currentUrl + "/share";
            
       //Navigate to the url
       ActiveBrowser.NavigateTo(urlWeWant);

1 Answer, 1 is accepted

Sort by
0
Elena
Telerik team
answered on 09 Nov 2018, 04:19 PM
Hi April,

I reviewed the shared resource you have referred to and it doesn't seem to be working in the context you intend to use that. As far as I understood this can be used for individual HTTP requests. 

Anyways, what will be required for you to cover the current requirement and take the current URL, is the Browser class and its Url property. 

Apart from that, I would like to share an article with you explaining how you could use BaseURL in Test Studio as I guess this will be of interest for you. 

I hope the shared notes will be useful for you. And, of course, in case you have any troubles or further questions, please let me know.

Regards,
Elena Tsvetkova
Progress Telerik
 
The New Release of Telerik Test Studio Is Here! Download, install,
and send us your feedback!
Tags
General Discussions
Asked by
April
Top achievements
Rank 1
Answers by
Elena
Telerik team
Share this question
or