diff --git a/app/Browser/Jobs/Hellcase/HellcaseJob.php b/app/Browser/Jobs/Hellcase/HellcaseJob.php index 02f2df4..d51b962 100644 --- a/app/Browser/Jobs/Hellcase/HellcaseJob.php +++ b/app/Browser/Jobs/Hellcase/HellcaseJob.php @@ -159,6 +159,8 @@ class HellcaseJob extends BrowserJob implements ShouldBeUniqueUntilProcessing try { $buttons = $browser->driver->findElements(WebDriverBy::xpath('//a[text() = "Join for free"]')); } catch (\Exception $e) { + $browser->screenshot(JobDebugScreenshot::getFileName($this->jobId)); + AllNotification::send(new JobDebugNotification($this->jobId, "No join for free buttons found")); return; } @@ -169,15 +171,26 @@ class HellcaseJob extends BrowserJob implements ShouldBeUniqueUntilProcessing ])); } foreach ($buttons as $button) { - $clicked = false; - while (!$clicked) { + try { + $nextSlideButton = $browser->driver->findElement(WebDriverBy::xpath('//button[@class="_button_1ygbm_7 _next_1ygbm_24"]')); + } catch (\Exception $e) { + $browser->screenshot(JobDebugScreenshot::getFileName($this->jobId)); + AllNotification::send(new JobDebugNotification($this->jobId, "No next slide button found")); + return; + } + $clickedFailsCounter = 0; + while ($clickedFailsCounter < 7 && $clickedFailsCounter > 0) { try { $button->click(); } catch (\Exception $e) { + $clickedFailsCounter++; + try { + $nextSlideButton->click(); + } catch (\Exception $_) {} + sleep(3); continue; } - $clicked = true; - sleep(3); + $clickedFailsCounter = -1; } sleep(5); $this->joinGiveaway($browser);