0
我的表沒有一個提交按鈕。相反,我使用了一個錨標籤。PHPUnit的點擊錨標記元素,而不是提交按鈕
<a href="#"
onclick="javascript:submitOfQuestion();"
data-toggle="dropdown"
class="btn btn-primary dropdown-toggle"><i
class="fa fa-upload icon-white"></i> Upload </a>
而且我寫了下面的測試方法。
/** @test */
public function testUploadQuestion(){
$this->visit('/upload_question')
->select('Computer', 'subject')
->select('7 - 10', 'ageCategory')
->type('Test Case Test Question 1', 'question')
->attach('C:\xampp\htdocs\IntelliKid\public\test_resources\Capture2.JPG', 'file[]')
->type('Test Case Test Answer 1', 'ans1')
->type('Test Case Test Answer 2', 'ans2')
->type('Test Case Test Answer 3', 'ans3')
->type('Test Case Test Answer 4', 'ans4')
->press('Upload')
->see('Success!');
}
但我得到以下錯誤。
1) UploadQuestionTest::testUploadQuestion
InvalidArgumentException: Could not find a form that has submit button [Upload].
C:\xampp\htdocs\IntelliKid\vendor\laravel\framework\src\Illuminate\Foundation\Testing\Concerns\InteractsWithPages.php:731
C:\xampp\htdocs\IntelliKid\vendor\laravel\framework\src\Illuminate\Foundation\Testing\Concerns\InteractsWithPages.php:711
C:\xampp\htdocs\IntelliKid\vendor\laravel\framework\src\Illuminate\Foundation\Testing\Concerns\InteractsWithPages.php:691
C:\xampp\htdocs\IntelliKid\vendor\laravel\framework\src\Illuminate\Foundation\Testing\Concerns\InteractsWithPages.php:678
C:\xampp\htdocs\IntelliKid\tests\UploadQuestionTest.php:33
C:\xampp\php\pear\PHPUnit\TextUI\Command.php:176
C:\xampp\php\pear\PHPUnit\TextUI\Command.php:129
FAILURES!
Tests: 6, Assertions: 14, Errors: 1.
什麼是你想解決的具體問題? – Castaglia