1

我有三个测试数据 [Checking, Shipping, Delivering] 使用循环自动输入。它不会输入第三个,这会导致测试失败。这是代码。

这是我的测试数据的代码

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'],
            ],
        ];
    }

这是我用来自动输入上述三个测试数据的foreach和while循环

            $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
                        }
                    }
                }
            }

请帮忙谢谢!

4

0 回答 0