Debug message when pasting text
All checks were successful
Push image to registry / build-image (push) Successful in 4m46s
All checks were successful
Push image to registry / build-image (push) Successful in 4m46s
This commit is contained in:
@ -5,6 +5,7 @@ namespace App\Browser;
|
|||||||
use App\Models\Job;
|
use App\Models\Job;
|
||||||
use App\Models\JobArtifact;
|
use App\Models\JobArtifact;
|
||||||
use App\Models\JobRun;
|
use App\Models\JobRun;
|
||||||
|
use App\Notification\Notifications\JobDebugNotification;
|
||||||
use App\Notification\Notifications\JobErrorNotification;
|
use App\Notification\Notifications\JobErrorNotification;
|
||||||
use App\Notification\Providers\AllNotification;
|
use App\Notification\Providers\AllNotification;
|
||||||
use Closure;
|
use Closure;
|
||||||
@ -22,6 +23,7 @@ use Illuminate\Queue\SerializesModels;
|
|||||||
use Laravel\Dusk\Browser;
|
use Laravel\Dusk\Browser;
|
||||||
use Laravel\Dusk\Chrome\SupportsChrome;
|
use Laravel\Dusk\Chrome\SupportsChrome;
|
||||||
use Laravel\Dusk\Concerns\ProvidesBrowser;
|
use Laravel\Dusk\Concerns\ProvidesBrowser;
|
||||||
|
use Log;
|
||||||
use PHPUnit\Framework\Attributes\BeforeClass;
|
use PHPUnit\Framework\Attributes\BeforeClass;
|
||||||
use Throwable;
|
use Throwable;
|
||||||
|
|
||||||
@ -333,19 +335,26 @@ abstract class BrowserJob implements ShouldQueue
|
|||||||
*/
|
*/
|
||||||
public function pasteText(Browser $browser, string $text, string $querySelector): void
|
public function pasteText(Browser $browser, string $text, string $querySelector): void
|
||||||
{
|
{
|
||||||
$text = $this->parseJavaScriptString($text);
|
try {
|
||||||
$querySelector = $this->parseJavaScriptString($querySelector);
|
$text = $this->parseJavaScriptString($text);
|
||||||
|
$querySelector = $this->parseJavaScriptString($querySelector);
|
||||||
|
|
||||||
$browser->script("
|
$browser->script("
|
||||||
var el = document.querySelector('{$querySelector}'), text = '{$text}';
|
var el = document.querySelector('{$querySelector}'), text = '{$text}';
|
||||||
el.focus();
|
el.focus();
|
||||||
const dataTransfer = new DataTransfer();
|
const dataTransfer = new DataTransfer();
|
||||||
dataTransfer.setData('text', text);
|
dataTransfer.setData('text', text);
|
||||||
const event = new ClipboardEvent('paste', {
|
const event = new ClipboardEvent('paste', {
|
||||||
clipboardData: dataTransfer,
|
clipboardData: dataTransfer,
|
||||||
bubbles: true
|
bubbles: true
|
||||||
});
|
});
|
||||||
el.dispatchEvent(event)
|
el.dispatchEvent(event)
|
||||||
");
|
");
|
||||||
|
} catch (Exception $e) {
|
||||||
|
$errorMessage = "Failed to paste text into element: {$querySelector} - " . $e->getMessage() . "\n With text: {$text}";
|
||||||
|
Log::error($errorMessage);
|
||||||
|
$browser->screenshot(JobDebugScreenshot::getFileName($this->jobId));
|
||||||
|
AllNotification::send(new JobDebugNotification($this->jobId, $errorMessage));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user