Data bind multiselect?

1 Answer 34 Views
Coded Steps Elements General Discussions Test Configuration
Daniel
Top achievements
Rank 1
Iron
Daniel asked on 17 Aug 2021, 07:01 PM
Hey, i'm trying to integrate test studio to work with my job's custom software. I am able to data bind select boxes, however with multi-select boxes i can't find an option to bind to data (even local data). Is there a way that this can be achieved out of the box? or do i have to write code for this (if i do can someone point me in the right direction please)? Thanks in advance

1 Answer, 1 is accepted

Sort by
0
Plamen Mitrev
Telerik team
answered on 19 Aug 2021, 01:04 PM

Hi Daniel,

I have an idea for you to help you select multiple values from a multi-select control, when this action is data driven. 

Lets explore the behavior from a user perspective and what a real user would do to select multiple values. The most common scenario is that they will interact with the control, by clicking on a dropdown for example. Then, click on the different items that need to be selected. We will automate those exact steps and bind those actions to local data source.

I prepared a set of two web tests that are connected via Test As Step and I believe this will help you automate this scenario with data binding. Please add the attached tests to an existing project and explore them. Also follow the steps below, which explain what I did on my end.

  1. I am using this demo page for testing purposes.
  2. Recorded all necessary steps, to the point when I select multiple values, in 1 web test - in my example this is the MultiSelect test. This includes the action to expand the multi-select control.
  3. Created new web test (called MultiSelectHelper) and added it as Test As Step in the main test. 
  4. Created local data in the MultiSelectHelper test with the necessary values and bind the Select item step to this data. I also added a small delay to ensure that the application has time to register the selection.
  5. Note that you might need to reference MultiSelectHelper test as a step in the main test after you import them both in a Test Studio project. This will update the reference between the two tests in the context of your project.

When you execute the MultiSelect test, it will reach the Test As Step. Since the MultiSelectHelper is data driven, the execution will iterate all of its steps as many time, as the rows of data. This concept is Multi-Level Data Driven testing in Test Studio.

Another option to data drive the selection of elements can be to create data driven find expressions. This approach can be used with controls that do not have a built in Select step. Please explore the details in the linked article.

I hope the above information and sample tests will help you automate this test scenario. Let me know if you need additional guidance or you have any follow up questions.

Regards,
Plamen Mitrev
Progress Telerik

The Test Studio R2 2021 release is out now! Register for the live release webinar on August 26 at 11 am ET | 5 pm CET and be among the first to get a preview of the fully revamped Step Failure Details in Test Studio.
Daniel
Top achievements
Rank 1
Iron
commented on 20 Aug 2021, 12:10 PM

Hey Plamen, 

Thank you for responding. I was actually able to achieve my desired outcome easily through code once i found the proper documentation.

        [CodedStep(@"Select Departments")]
        public void multiSelectTest()
        {

            string depts = Data["department"].ToString();
            string[] deptArray = depts.Split(',');
            Pages.MyCompany.FrameTbiPANE1PANE0.department.MultiSelectByValue(deptArray);
        }

I used the "Data" object to extract whatever is stored in "department" in local data. I then converted it to a string and
stored it in the "depts" variable. Then i split it according to "," into an array. which was then passed into the multi-select
function (takes an array). 

So my input in "departments" (local data) would look like this: sales,production,marketing 
Without any spaces, because i did not account for trimming or any whitespace. Just sharing the snippet incase anyone in the future encounters my same problem.

Thanks again!

Plamen Mitrev
Telerik team
commented on 23 Aug 2021, 09:08 AM

Hi Daniel, 

I am happy to know that you found a solution with coded step and the necessary documentation how to achieve it. Thank you for sharing the code and details about the implementation and test scenario. It will probably be helpful to someone else, who tries to automate a similar control.

Have a great week ahead!

Tags
Coded Steps Elements General Discussions Test Configuration
Asked by
Daniel
Top achievements
Rank 1
Iron
Answers by
Plamen Mitrev
Telerik team
Share this question
or