我如何 "uncheck" 复选框字段与 Laravel 应用程序测试?

How can I "uncheck" a checkbox field with Laravel Application testing?

在Laravel 5.1中根据http://laravel.com/docs/5.1/testing#interacting-with-your-application我可以使用:

$this->visit('/register')
     ->type('Taylor', 'name')
     ->check('terms')
     ->press('Register')
     ->seePageIs('/dashboard');

但是有什么方法可以取消选中复选框吗? (无论是否勾选)

谢谢

您可以使用底层 DOM 爬虫 (Symfony)。

  • 您通过提交按钮上的文本引用表单
  • 您可以选中或取消选中元素
  • 你终于提交了表格

    $form = $this->getForm('SUBMIT');
    $form['single_cb']->untick();
    $form['multiple_cb'][0]->untick();
    $form['multiple_cb'][1]->tick();
    $form['multiple_cb'][2]->tick();
    $this->makeRequestUsingForm($form);
    

您现在也可以使用

$this->uncheck('#my-checkbox');