1

I have three test data [Checking, Shipping, Delivering] to input automatically using loop. It will not input the third one and that causes the test to fail. Here's the code.

Here is the code for my test data

private static function getValidAdminCommentInput()
    {
        return[
            //key
            'Comment[order_comment]' => [
                //testNo           Value                input method    assertMethod
                'testSpec01' => ['Checking order',      'type',         'assertInputValue'],
                'testSpec02' => ['Shipping order',      'type',         'assertInputValue'],
                'testSpec03' => ['Delivering order',    'type',         'assertInputValue'],
            ],
        ];
    }

Here's the foreach and while loop I used to automatically input the three test data stated above

            $adminCommentInputData = self::getValidAdminCommentInput();
            $retryMax = 5;
            $retryCount = 0;
            foreach ($adminCommentInputData as $keys => $keyVal) {
                foreach ($keyVal as $key => $input) {
                    $selector = '[name="' . $keys . '"]';
                    $method = $input[1];
                    $assertMethod = $input[2];
                    sleep(60); // creates time interval of comments to simulate real commenting time interval
                    while ($retryCount++ < $retryMax) {
                        $browser->clickLink('Admin Comments')
                                ->clickLink('Create Admin Comments')
                                ->waitFor($selector)
                                ->$method($selector, $input[0]);
                        try {
                            $browser->$assertMethod($selector, $input[0])
                                    ->press('Create');
                                break;
                        } catch (AssertionFailedError $e) {
                                // ignore
                        }
                    }
                }
            }

Please help thanks!

crisceebee
  • 11
  • 2

0 Answers0