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

How to data bind a navigation step

6 Answers 224 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
David asked on 03 May 2019, 02:48 PM

Hi, 

I'm trying to add step inside a test which basically takes a list of ids from a data source, iterates through each record where it would concatenate the data source value (id) to a url query string navigate to it, and then repeat this step for the next iteration after verifying the address was valid.

So far I've created the test, I've added a sql data source, bound the data source to my test, where data source is a list of guid ids'.

As part of the test I've added a 'Navigate to' step, added the Navigate Url  and bound the data source to the NavigateUrl field (see boundfield.png)

The failure report reads 

"Unable to resolve to an absolute URL: '9706a3f2-27d9-40af-aedb-0000286ab5ea'.
Unable to resolve to an absolute URL: '9706a3f2-27d9-40af-aedb-0000286ab5ea'."

the application log is attached 

 

Could you please help with this scenario.

Thank you 

 

 

 

 

 

 

6 Answers, 1 is accepted

Sort by
0
Elena
Telerik team
answered on 03 May 2019, 04:17 PM
Hello David,

Thank you for the shared details. 

As far as I understand the guid from the data source - the SQL database, should be added to a baseURL. And it seems you hadn't listed any baseURL for the project or for the particular step.

Usually, baseUrl is set on project level, when you intend to use the automation project against multiple environments - like described here. Then, you can set a URL in the setting project which will be used for all navigation steps. Then, once you include the tests in test lists, then you can set the baseURL in the settings for each test list

This is the common case. However, I am not sure if this is the final goal you have as a requirement, and I will focus on the current navigation step shown in the shared screenshot. Probably the url should be similar to this: 

https://www.myCompany.com/id=[guidFromTheDataSource]

If the project has no BaseURL set, then you need to add it for this step in the BaseUrl field. Then, Test Studio will be able to concatenate the strings and pass a valid url to navigate to. 

I hope the above notes will be helpful for you. Though, if you need any further assistance, please do not hesitate to get back to us. 

Regards,
Elena Tsvetkova
Progress Telerik
 
The New Release of Telerik Test Studio Is Here! Download, install,
and send us your feedback!
0
David
Top achievements
Rank 1
answered on 07 May 2019, 12:09 PM

Hi Elena

Thank you for your help, I've managed to get a little further but I'm still unsure of a couple of points. 

to give more information - this test is set to do following 

1 navigate to a url, 

2 log in 

3 Once logged in - navigate to a particular page with a query string comprising an ID from a bound sql list

4 verify the page

5 navigate to the url with the next iteration of the bound dataset

6 repeat step 4

7 repeat step 5

finish test

-----------------------------------------------------------------------------------------------------------------------------------

 

As instructed I added a base URL to the test

The Id comes from my data source which is a tsql table query which simply returns 10 unique guid ids

I add the redirect url into the NavigationURL text field and then bind the data source to this field. 

However this simply tries to redirect to the base url + the id value ie ...

https://www.baseurl.com/id

The bound value seems to over wright the NavigationUrl field.

To work around this - I edited the step as code and this is what the step looked like 

[CodedStep(@"Navigate to : '/client-files/client/overview.aspx?id=' - DataDriven: [$(clnt_client_id)]")]
        public void V6LoginClientSearch_CodedStep()
        {
            // Navigate to : '/client-files/client/overview.aspx?id='
            ActiveBrowser.NavigateTo(((string)(System.Convert.ChangeType(Data["clnt_client_id"], typeof(string)))), true);
            
        }

 

As you can see there is no address to navigate to.

So I edited the step to include the navigation url as follows

ActiveBrowser.NavigateTo("/client-files/client/overview.aspx?id=" + Data["clnt_client_id"], true);

So when I run the test for the first iteration of the bound dataset, it works as expected - however for the other 9 iterations the test tried to redirect to just the base url with no query string?

I'm not sure what I'm missing. I thought about adding a while loop for the duration of the number of bound values- in this case 10, however I don't know how to bind the data set number to the while loop? is this possible to do?

For each redirect - I would like to carry out some test steps for verification purposes before it hits the next redirect. After after the final bound redirect the test should finish. If any of the bound redirects cannot be verified - I would just like to log this fact and have the test continue through all other databound redirects. 

Is this something that is possible to do in the test studio.

Thank you again for your help with this.

0
David
Top achievements
Rank 1
answered on 07 May 2019, 12:25 PM
0
David
Top achievements
Rank 1
answered on 08 May 2019, 04:25 PM

Hi Elena, 

I've also tried the following 

I created a simple consisting of a navigation step with a dummy url and then databound the navigation field with dataset of 10 guid IDs as a test.

What I found was that when I applied the databind to the navigation field - the databound value overwrite the url I had entered to navigate to. Is this normal behaviour? I had to edit the step in code and re work the step eg 

With no data-bind, this is what the step looks like 

[CodedStep(@"Navigate to : '' - DataDriven: [$(clnt_client_id)]")]

        public void loopSet_CodedStep()
        {
                        // Navigate to : ''
                        ActiveBrowser.NavigateTo("http://v6.tpinside.com/client-files/client/overview.aspx?id=", true);
                       
        }
    

0
David
Top achievements
Rank 1
answered on 08 May 2019, 04:33 PM

continued from my last post...

Once I add the data-bind to the navigation field and apply It this is what the step looks like

[CodedStep(@"Navigate to : '' - DataDriven: [$(clnt_client_id)]")]
        public void loopSet_CodedStep()
        {
                        // Navigate to : ''
                        ActiveBrowser.NavigateTo(((string)(System.Convert.ChangeType(Data["clnt_client_id"], typeof(string)))), true);
                       
        }

So I amended the step to look like the following 

 

[CodedStep(@"Navigate to : '' - DataDriven: [$(clnt_client_id)]")]
        public void loopSet_CodedStep()
        {
                        // Navigate to : ''
                        ActiveBrowser.NavigateTo("http://v6.tpinside.com/client-files/client/overview.aspx?id=" + ((string)(System.Convert.ChangeType(Data["clnt_client_id"], typeof(string)))), true);
                       
        }

I packaged this up as a test step and used it as a sub test in a larger test that 1st logs into the site in question, and then should iterate over all the data bound values on the navigate step which is used a redirect + the id as a query string.

The actual behaviour works up until the databound redirect, where it attemps the first iteration, but then for some reason starts the test script over again and repeats for the number of data bound values. 

I have to say this is something that should be fairly straightforward - but in the documentation, there is no real help for this situation. 

Thanks in advance for your help here. 

 

 

 

 

0
Elena
Telerik team
answered on 09 May 2019, 08:51 AM
Hello David,

Please, excuse me I didn't have the chance to get back to you earlier. 

Back on the discussion in this thread, there are few more things I would like to provide details for to avoid any further misunderstanding. 

Data Binding feature 

This is the first topic I would like to address and explain how this works - any step property, which is bound to data source, uses only the respective value from the data file - even if the recorded value is not deleted from the original step, if the property is data bound, it will take the data from the source. 

As you have found out yourself, you can combine the data binding in a coded step with a static part of the required string to pass to the step property and this is applicable for any similar situation, when only part of the value should be dynamically generated during execution time. 

BaseURL 

Depending on the complete scenario you need to build, you probably want to keep the BaseUrl to be "http://v6.tpinside.com" and concatenate the NavigateUrl with the coded step. And this will be the more appropriate decision if there will be multiple environments to test against. 

However, for testing purposes, you can try the following to better understand the data binding particularly for the navigation step.
1. Create a new sample project to test in it. 
2. Set the baseURL http://v6.tpinside.com/client-files/client/overview.aspx?id=
3. Add a test and a navigate step in it. 
4. Add data source containing the required ids and data bind the NavigateUrl of the navigation step. 

The project set that way, will have the straight forward behavior as you initially expected it. However, as far as I understand the particular scenario to iterate few urls with different query values is only a small part of the project to build and my opinion is that the approach you went for - to iterate the Urls in a sub test, should fit better. 

Nested data driven tests 

What left is to get familiar how the execution of multi level data driven tests works and this is described here in details - I think this is the missing piece to setup the tests as required. 

I hope these notes will be helpful for you and, of course, if you have any doubts or questions, please let me know. 

Thank you in advance for your cooperation. 

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
David
Top achievements
Rank 1
Answers by
Elena
Telerik team
David
Top achievements
Rank 1
Share this question
or