Drupal 如何使用Behat和Goutte处理模态对话框?

Drupal 如何使用Behat和Goutte处理模态对话框?,drupal,behat,gherkin,Drupal,Behat,Gherkin,我正在一个允许用户填写表单的网站上测试功能性。此时,用户需要点击一个按钮,这会触发一个Ajax加载模式,允许他上传一个文件。但是,当我触发按钮时,Behat似乎没有“看到”模式窗口 也许我应该知道我在Drupal8环境中,但我不知道这是否改变了什么 让我们清楚一点,我不是说警报,而是这个 到目前为止,我的测试如下所示: Scenario: Creates a stage test with two sessions Given I am on "/user/login" And

我正在一个允许用户填写表单的网站上测试功能性。此时,用户需要点击一个按钮,这会触发一个Ajax加载模式,允许他上传一个文件。但是,当我触发按钮时,Behat似乎没有“看到”模式窗口

也许我应该知道我在Drupal8环境中,但我不知道这是否改变了什么

让我们清楚一点,我不是说警报,而是这个

到目前为止,我的测试如下所示:

Scenario: Creates a stage test with two sessions
    Given I am on "/user/login"
    And I fill in "user@user.com" for "name"
    And I fill in "password" for "pass"
    And I press "Log in"
    Then I should get a "200" HTTP response
    And I should see "User Name"
    When I go to "/node/add/stage"
    Then I should get a "200" HTTP response
    And I should see "Add content CISIA Stage"
    When I fill in "Test Cisia Stage" for "edit-title-0-value"
    And I press "Select files"
    Then I should see "Upload files" <-- fails
    And I should see "Click or drop files here to upload them" <-- gets ignored but is likely to fail too
$this->getSession()->getDriver()->switchToIFrame('iframe_name');
然而,到目前为止,我没有得到任何运气


我该怎么办?

您有一个
iframe
,需要切换到它

使用类似以下内容:

Scenario: Creates a stage test with two sessions
    Given I am on "/user/login"
    And I fill in "user@user.com" for "name"
    And I fill in "password" for "pass"
    And I press "Log in"
    Then I should get a "200" HTTP response
    And I should see "User Name"
    When I go to "/node/add/stage"
    Then I should get a "200" HTTP response
    And I should see "Add content CISIA Stage"
    When I fill in "Test Cisia Stage" for "edit-title-0-value"
    And I press "Select files"
    Then I should see "Upload files" <-- fails
    And I should see "Click or drop files here to upload them" <-- gets ignored but is likely to fail too
$this->getSession()->getDriver()->switchToIFrame('iframe_name');

我认为您也应该考虑在高层次的基础上编写您的脚本,并且还使用页面对象扩展来避免长时间难以维护和不可读的场景,并且尽可能多地重用代码。 遵循行为驱动的开发方法


你有一个
iframe
,你需要切换到它。谢谢你的回答,我花了一段时间才让它工作起来,但我现在可以在我的模式中找到我的元素!对于“长场景”,我别无选择,这是我工作中的一个直接请求,目的是尽可能清楚地让未来的人在不知道如何编码的情况下维护它