I need to know,
1. How to extract data from the application and export it to an external excel sheet
2. Is there any option to bind an external Excel file during execution
Regards,
Yogi
14 Answers, 1 is accepted
You can get the text of most elements using code something like this:
Pages.Bing.SbFormQText.Text;
To write into an Excel file you will have to implement your own code. WebUI does not include any API's for reading/writing to Excel files from your own coded steps. Here's a Microsoft article describing one possible approach.
Can you give us more details about what you're trying to accomplish with binding an external Excel file during execution? Currently there is no built-in feature to do this, but there are a couple of possible tricks we can show you, depending on what exactly you are trying to accomplish.
Cody
Thanks for your response.
I'll give a try the steps specified in the Microsoft article and let you know.
In our application, based on the initial input, the application will generate an unique excel file which contains some data that needs to be feed to the application to perform an action. So it will be better if there is a technique or code to bind the excel sheet during run-time. This will help us to run the test without manual intervention.
Regards,
Yogi
Attached is a sample test of one of the tricks we can do. Basically a single test can only be bound to one specific data source/file. But what the attached test project does is split the testing into two parts, a main test and a sub test.
- The main test is data driven and gets its input from a single excel file. It dynamically swaps out the file that the subtest is bound to just before calling the subtest.
- The subtest is bound to one specific file. When it gets control it opens and begins reading from the file that the main test put there for it to read.
Cody
Thanks for your support. Given trick works only if the sub test is using a static file name.
I found out a method in MSDN forum to bind excel data source during run-time.
<DataSource(
"System.Data.Odbc"
,
"Dsn=Excel Files;dbq=C:\\POC\\Data\\testdata.xls;defaultdir=.;driverid=1046;maxbuffersize=2048;pagetimeout=5"
,
"Login$"
,
DataAccessMethod.Sequential)>
<TestMethod()>
Public
Sub
WebAiiTest1()
Dim
row = TestContext.DataRow.Table.Rows(1)
Dim
actual = row(
"col2"
)
MsgBox(actual)
End
Sub
The above code is working fine. But I'm unable to control the iteration, i.e, if the excel sheet has 10 rows, then the test is executed for 10 times.
Please let me know is there any method or trick to control the iteration by specifying a particular row to execute.
Thanks,
Yogi
The code you have posted does work well for a coded unit test. However keep in mind that WebAii tests (i.e. .aii tests) are not coded unit tests. They do not honor the DataSource attribute the way coded unit tests do.
Unfortunately you cannot programmatically control which row or rows of data will be used from the data source. The best we can do is to apply row filtering during the data binding setup as shown in the attached screenshot.
Cody
Is there any chance that we can get this feature of controling the iteration in any of the future releases of telerik? This feature is really needed for us. Pls let us know.. Thanks!!!!
Thanks,
Veera
I have entered feature request 102982 for this. I cannot specify when (or even if) we'll be able to implement this in a future version. All I can say is that it will be considered by our product manager.
Can you explain to me your business case why you need this? This will help our product manager better understand why this such an important feature to you.
Cody
This feature is required as we can Dynamically associate the excel file to the test scripts when required!!!
Hope this helps!!
Thanks,
Veera
Thank you for the additional information. I've passed it along to the product manager.
I would like to better understand this module interaction that you talk about. From the very limited understanding I have of your application and testing needs, it would seem you would have a set of test cases and one separate test per test case, possibly one for each module, and each test case for a module would be data bound to one sheet from your Excel file.
I'm pretty sure this is for the case of "As long as the module did not intereacting with one another" as you talk about. I am not yet fully understanding how dynamic data binding helps testing with your module interaction.
Greetings,
Cody
the Telerik team
Thanks, think at least I made justice this time in my explanation.
We have module like
- Entity
- Personnel
- Contact Etc
Currently, we have worksheet per module. If I have to verify the entities details in contact module, we are not able achieve that as both entity details and contact details are from diff worksheet and both info are required in order to complete the verification. which is not possible at this moment!
Hope this helps!!!
Thank you for the clarification. I think I begin to understand your test case now. Based on which Personnel you associate with an Entity you want the same type of test to run, but with different data that goes along with that Personnel record. Do I understand better now?
All the best,Cody
Hi Cody,
Only one which I would like to highlight here is There will not be one to one mapping between Personnel and Entity. One Personnel to Multiple entities and One Entity to Multiple Personnel. Hope this helps
Thanks,
Veera
Thanks! I am pretty sure I understand your business needs now.
Kind regards,Cody