Laravel Dusk 可以断言 JavaScript 动态元素吗?

Can Laravel Dusk Assert a JavaScript Dynamic Element?

我有一个由 JavaScript 创建的表单,我可以在 Chrome 开发人员工具中看到它:CTRL + Shift + I, 但是在view-source里面看不到: Ctrl + U.

我想测试,但是LaravelDusk看不到。有没有可能Laravel Dusk断言(看,按,点击,输入等)JavaScript动态元素?

您可以让 dusk 等到您的动态元素可用:

Waiting For Elements:

If you need to pause the test for a given number of milliseconds, use the pause method:

$browser->pause(1000);

The waitFor method may be used to pause the execution of the test until the element matching the given CSS selector is displayed on the page. By default, this will pause the test for a maximum of five seconds before throwing an exception. If necessary, you may pass a custom timeout threshold as the second argument to the method:

// Wait a maximum of five seconds for the selector...
$browser->waitFor('.selector');

// Wait a maximum of one second for the selector...
$browser->waitFor('.selector', 1);