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

Dynamic data UI Tests

5 Answers 106 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Kelli
Top achievements
Rank 1
Kelli asked on 17 Sep 2014, 07:48 PM
My company is a .net shop and our data is very Dynamic.  Each time we access a form on a web page, that page creates what we call a “Recid”. When I record an automated test and then re-run that test, I get an error saying “element  was not found”. I am guessing this is because the page now has a Recid different than the one when I first recorded the test. How can I get around this? I need the automated test to except whatever the newest Recid will be.
 
Example.
 
When I recorded an automated test, the Recid=15266 (see below). The next time I access the same web-page, this Recid will equal 15227 (or even higher number)
 
https:/ser/Crf/Enter.aspx?Id=R01-0028BB&RecId=15226
  
I am testing out  Test Studio  trial to see if this is a product my company may want to purchase. However, the above issue would be a show stopper for us.
  
Also, is there a way to ignore pop ups when recording UI recorded tests?

5 Answers, 1 is accepted

Sort by
0
Kelli
Top achievements
Rank 1
answered on 22 Sep 2014, 11:03 AM
Any help? Really trying to consider this software
0
Madhu
Top achievements
Rank 1
answered on 22 Sep 2014, 03:37 PM
Hi Kelli,

Try this one:

http://docs.telerik.com/teststudio/user-guide/knowledge-base/test-automation/dynamically-generated-id-attributes.aspx

--Madhu
0
Cody
Telerik team
answered on 22 Sep 2014, 04:38 PM
Hi Kelli,

The article that Madhu pointed you too (thank you Madhu) is excellent for overcoming the problem you describe. One thing I do want to clear up is that when Test Studio is running a test, it doesn't pay any attention to the URL in the browser when looking for elements. It literally operates in the fashion "look for element X on whatever page happens to be currently loaded in the browser". The fact that Recid changes in the URL will not affect test execution.

I will admit there is an exception... when a popup browser window opens we will look for the correct window using the URL. However this is easily overcome by trimming the URL to look for and making sure IsUrlPartial is checked - see attached screen shot.

Another exception is when an element is contained with an <iframe>. The iframe has a src property which is a URL. We need to find the correct iframe first, using the URL, before we find the right element. Here too you can specify a partial URL as shown in the attached screen shot, remove Recid from the URL in the process.

If you still get stuck let me know and I'll be happy to assist. It would help me to help you the most by going to Step Failure Details, find and click Export and attach the generated .zip file. It contains valuable information I need to begin diagnosing the root cause of any test failure.

Regards,
Cody
Telerik
 
The New Release of Telerik Test Studio Is Here! Download, install,
and send us your feedback!
0
Kelli
Top achievements
Rank 1
answered on 23 Sep 2014, 03:30 PM
Thanks Cody. The only way I can get the tests to pass is by using the xPath. Is this the only way it will work? I can change the identification logic to look at xPath first and it works every time. However if we decided to move a control to  a different spot my test will fail. I rather have it by id or name. My problem is that it can never find the element because of the ID is changing. Is there a way to set up a wildcard with an element?

I've attached my failure zip.

Also, I don't see a way to run tests sequentially from the project level. I have to click one at a time. This would be a show stopper for my company. Do I need to adjust my test to execute tests from the project level?

My last question is there a way to create my data source that I've binded as a test step? I connected to my database and used t-sql to run a sql script. It runs at the beginning of my test but is there a way just to make it a test step. For example, I might not want it to run first every time. If not I'm assuming I would have to rewrite the sql into .net script coded test?
0
Cody
Telerik team
answered on 25 Sep 2014, 02:34 AM
Hi Kelli,

Thank you for the additional information. I see exactly what the problem is now and it's really easy to solve. Let me walk you through it.

In the log we see this error:

Unable to locate element. Details: Attempting to find [Html] element using 
Find logic 
 (Html): [href 'Exact' /ndocs/sysdev2/User/Crf/Initialize.aspx?PtId=R01-0083NN&amp;SectionName=REnrVisitInfo_aDE&amp;TransId=3112ee9c-c65f-4401-a608-0dae3c391e3f] AND [tagname 'Exact' a]
 
Notice Test Studio is looking for an <a> element (i.e. a hyperlink, also known as an "anchor" in HTML programming terms) that has a long and complicated href value, and that it's doing an "exact" comparison i.e. the href value must match identically.

But when we look at the actual HTML captured at the time of failure we find this for that <a> element:

<A href="/ndocs/sysdev2/User/Crf/Initialize.aspx?PtId=R01-0083NN&amp;SectionName=REnrVisitInfo_aDE&amp;TransId=c4075a24-d87c-4ceb-b88a-5732377920bb">Visit Information</A>
 
If you look closely you'll discover that the Transid value has changed, but everything else in the href is the same. This implies that the Transid value is dynamically generated every time the application is run, or that particular page is displayed. Now that we know this all we need to do is modify the find expression to do a "contains" comparison and remove the TransId value, as shown in the attached screen shot. I realize you can't see the full value of the href in the screen shot. It is set to:

/ndocs/sysdev2/User/Crf/Initialize.aspx?PtId=R01-0083NN&amp;SectionName=REnrVisitInfo_aDE

With that small adjustment Test Studio will be able to very reliably find the correct link, regardless of the Transid value, without relying on a brittle xpath expression.

To run tests sequentially you want to put them into a test list then run that test list. Also once you create your test lists, you'll be able to take advantage of our Scheduling and remote execution server, which comes with Test Studio.

is there a way to create my data source that I've binded as a test step?

I'm not sure I understand this question. I'll do my best to answer based on the rest of your statements following this.

In a Data Driven Test Studio test, it will always read all of the data from the data source (e.g. Excel file or SQL DB) during test initialization and create an in memory data table containing that data. The data source is then disconnected and never used again. The test now runs multiple iterations, once per row of data contained in this in memory data table. There is no way to update/modify this data table once the test iterations have begun.

You can of course run a coded step to perform a SQL query at any time. Then you just need to figure out how to use the data in the test that was returned as a result of the SQL query.

Does that help answer your question? If you can clarify your need better I'll be able to answer it better.

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