Question Need help with adjusting the existing method


Jul 13, 2022
Programming Experience
Hello everyone!

I am doing mobile automation and facing some difficulties.
Currently, I have a test that selects specific programs(behavioral health) and collects data for them.

        [TestCase("App", "Only goals", "test duration", "Baseline to Teaching - Frequency_V2", "Keeping Hands Appropriate while Sitting")]
        public void TestCollectDataForAppClient(string client, string behProgram1, string behProgram2, string skProgram1, string skProgram2)
            new LoginScreen(driver).LoginToCollectData(Config.apptStaff, Config.apptStaffPassword)
                .ChooseBehaviorsPrograms(behProgram1, behProgram2)
                .ChooseSkillsPrograms(skProgram1, skProgram2)
                .CollectSkillDataForAppClient(4, 2, 1)
                .CollectBehaviorDataForAppClient(3, 10)
                .FillOutTheABCNote("Notes Check")

Methods ChooseBehaviorsPrograms and ChooseSkillsPrograms accept two parameters which are the names of each program that I provided in TestCase attribute, but my lead wants to use an array that will store variables(the list of programs in this case) like this string[] behaviors and in the test, it would like this .ChooseBehaviorsPrograms(behaviors)

Here is the snippet of ChooseBehaviorsPrograms method I currently have:

        public ProgramsScreen ChooseBehaviorsPrograms(string programName1, string programName2)
            listOfPrograms.ClickElementFromList(driver, programName1);
            listOfPrograms.ClickElementFromList(driver, programName2);
            return this;

It's a bit confusing for me just to build the logic for that. The elements that the driver finds are stored in a list of AppiumWebElements. As far as I know, we need first to convert the list of elements to a list of strings and then to an array. How can I adjust the method that would accept an array of strings and still choose multiple options by text? And how parameters in the TestCase for the test will look like with an array?

Thank you in advance!
You can't change that test. If you change that test, then the test will either start failing. That then will mean that your application is not valid anymore -- unless that test never succeeded in the first place.

I feel that you are trying to do too much in a single test and completely breaking the Single Responsibility Principle. You should keep that current test. Instead look at the MSTest documentation looking for "data driven tests", because that is essentially what you are trying to do with those arrays -- perform the same test, but with different data for each iteration of the test.
Top Bottom