Try to check for popup in concurrency
All checks were successful
Push image to registry / build-image (push) Successful in 3m35s

This commit is contained in:
2025-11-01 14:45:26 +01:00
parent e1a6bd9d42
commit 31ac892cbb

View File

@@ -10,6 +10,7 @@ use App\Notification\Providers\AllNotification;
use Facebook\WebDriver\WebDriverBy;
use Illuminate\Contracts\Queue\ShouldBeUniqueUntilProcessing;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Concurrency;
use Illuminate\Support\Facades\Log;
use Laravel\Dusk\Browser;
use App\Services\AIPrompt\OpenAPIPrompt;
@@ -107,9 +108,22 @@ abstract class InstagramAbstractJob extends BrowserJob implements ShouldBeUnique
['//button|//div[contains(text(), "OK")]', ["Popup Ok clicked"]], // OK
];
$fn = [];
foreach ($popupsTypes as $popup) {
$fn[] = function () use ($browser, $popup) {
try {
return $browser->driver->findElement(WebDriverBy::xpath($popup[0]));
} catch (\Exception $e) {
return null;
}
};
}
$buttons = Concurrency::run($fn);
foreach ($popupsTypes as $index => $popup) {
try {
$button = $browser->driver->findElement(WebDriverBy::xpath($popup[0]));
$button = $buttons[$index] ?? null;
if ($button === null) {
continue; // No button found, continue to the next popup
}