好的,需要AJAX功能支持

时间:2019-02-27 20:44:10

标签: php ajax automated-tests behat gherkin

因此,我正在网站上进行一些behat测试。到目前为止还不错,直到我遇到了AJAX功能(即单击链接或按钮都不会更改或刷新页面,但是会从已经打开的页面中添加或删除新内容)。

这给我带来了一些麻烦,因为JS不支持我的behat测试。我不确定要在Behat上使用AJAX功能要添加哪些驱动程序。我相信到目前为止,我的Behat可以在无头浏览器上运行。不知道我该如何处理这样的Ajax功能。有人可以帮我吗?

所以我的behat.yml是这个

default:
  suites:
    default:
      path: %paths.base%/features/bootstrap
      contexts: 
        - FeatureContext
  extensions:
    Behat\MinkExtension:
      base_url: http://somethingimportant.prod.com/
      sessions:
        default:
          goutte: ~

我要测试的功能文件是这个


Scenario: Manage the favourites on the favourites page
Given I am on homepage
When I will login as globaladmin
Then I click "My account"
Then I click "Favourites"
Then I click "Manage" //After this click is where the AJAX comes into play
Then I wait 2 seconds
Then I should see "Save Order"

这是我的featurecontext.php

<?php

use Behat\Behat\Context\Context;
use Behat\Gherkin\Node\PyStringNode;
use Behat\Gherkin\Node\TableNode;
use Behat\MinkExtension\Context\MinkContext;

/**
 * Defines application features from the specific context.
 */
class FeatureContext extends MinkContext implements Context
{
    **
    * @Then /^I wait (\d+) seconds$/
    */
    public function iWaitSeconds($time) 
    {
        $this->getSession()->wait($time * 1000);
    }
}

这是我得到的错误

Feature: This feature will test the Favourites page

  Scenario: Manage the favourites on the favourites page # features/favourites.feature:3
    Given I am on homepage                               # FeatureContext::iAmOnHomepage()
    When I will login as globaladmin                     # FeatureContext::iWillLoginAsGlobaladmin()
    Then I click "My account"                            # FeatureContext::assertClick()
    Then I click "Favourites"                            # FeatureContext::assertClick()
    Then I click "Manage"                                # FeatureContext::assertClick()
    Then I wait 2 seconds                                # FeatureContext::iWaitSeconds()
      JS is not supported by Behat\Mink\Driver\GoutteDriver (Behat\Mink\Exception\UnsupportedDriverActionException)
    Then I should see "Hey" 

感谢您的帮助。预先感谢世界人民:)

0 个答案:

没有答案