【问题标题】:send form with Symfony crawler without save button (autosave function)使用没有保存按钮的 Symfony 爬虫发送表单(自动保存功能)
【发布时间】:2015-11-19 08:16:14
【问题描述】:

我正在为 symfony 编写功能测试,但在页面上发送表单时遇到问题,没有任何保存按钮,只有自动保存功能。

通常我首先找到保存按钮,用数据填写表单然后保存

    // find the add button
    $saveButton = $crawler->filter('button.btn-save');

    // fill the form with data and submit
    $form = $saveButton->form();

    // submit empty form
    $crawler = $client->submit($form);

谢谢!

【问题讨论】:

    标签: php symfony testing web-crawler autosave


    【解决方案1】:

    您可以在表单元素本身上调用 form() 方法。

    $form = $crawler->filter('css-selector-to-form')->form();
    $crawler = $client->submit($form);
    

    【讨论】:

      猜你喜欢
      • 2021-08-16
      • 1970-01-01
      • 1970-01-01
      • 2010-10-30
      • 1970-01-01
      • 1970-01-01
      • 2016-12-08
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多