Try to check for popup in concurrency
All checks were successful
Push image to registry / build-image (push) Successful in 3m35s
All checks were successful
Push image to registry / build-image (push) Successful in 3m35s
This commit is contained in:
@@ -10,6 +10,7 @@ use App\Notification\Providers\AllNotification;
|
|||||||
use Facebook\WebDriver\WebDriverBy;
|
use Facebook\WebDriver\WebDriverBy;
|
||||||
use Illuminate\Contracts\Queue\ShouldBeUniqueUntilProcessing;
|
use Illuminate\Contracts\Queue\ShouldBeUniqueUntilProcessing;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
|
use Illuminate\Support\Facades\Concurrency;
|
||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
use Laravel\Dusk\Browser;
|
use Laravel\Dusk\Browser;
|
||||||
use App\Services\AIPrompt\OpenAPIPrompt;
|
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
|
['//button|//div[contains(text(), "OK")]', ["Popup Ok clicked"]], // OK
|
||||||
];
|
];
|
||||||
|
|
||||||
|
$fn = [];
|
||||||
foreach ($popupsTypes as $popup) {
|
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 {
|
try {
|
||||||
$button = $browser->driver->findElement(WebDriverBy::xpath($popup[0]));
|
$button = $buttons[$index] ?? null;
|
||||||
if ($button === null) {
|
if ($button === null) {
|
||||||
continue; // No button found, continue to the next popup
|
continue; // No button found, continue to the next popup
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user