Fix joining giveaways

This commit is contained in:
2025-03-15 16:26:29 +01:00
parent 63216ae7e8
commit ad10dcaa0f

View File

@ -52,7 +52,7 @@ class HellcaseJob extends BrowserJob implements ShouldBeUniqueUntilProcessing
} catch (\Exception $e) { } catch (\Exception $e) {
$this->jobRun->success = false; $this->jobRun->success = false;
$this->jobRun->save(); $this->jobRun->save();
AllNotification::send(new JobErrorNotification($this->jobId, "Erreur lors de la participation aux concours gratuits", $e->getMessage())); AllNotification::send(new JobErrorNotification($this->jobId, "Erreur lors de la participation aux concours gratuits : " . $e->getMessage()));
} }
$this->getDailyFree($browser); $this->getDailyFree($browser);
@ -170,7 +170,6 @@ class HellcaseJob extends BrowserJob implements ShouldBeUniqueUntilProcessing
"content" => "" "content" => ""
])); ]));
} }
foreach ($buttons as $button) {
try { try {
$nextSlideButton = $browser->driver->findElement(WebDriverBy::xpath('//button[@class="_button_1ygbm_7 _next_1ygbm_24"]')); $nextSlideButton = $browser->driver->findElement(WebDriverBy::xpath('//button[@class="_button_1ygbm_7 _next_1ygbm_24"]'));
} catch (\Exception $e) { } catch (\Exception $e) {
@ -178,8 +177,10 @@ class HellcaseJob extends BrowserJob implements ShouldBeUniqueUntilProcessing
AllNotification::send(new JobDebugNotification($this->jobId, "No next slide button found")); AllNotification::send(new JobDebugNotification($this->jobId, "No next slide button found"));
return; return;
} }
foreach ($buttons as $button) {
// Click the next slide button if the button is not clickable
$clickedFailsCounter = 0; $clickedFailsCounter = 0;
while ($clickedFailsCounter < 7 && $clickedFailsCounter > 0) { while ($clickedFailsCounter < 7 && $clickedFailsCounter >= 0) {
try { try {
$button->click(); $button->click();
} catch (\Exception $e) { } catch (\Exception $e) {
@ -192,7 +193,8 @@ class HellcaseJob extends BrowserJob implements ShouldBeUniqueUntilProcessing
} }
$clickedFailsCounter = -1; $clickedFailsCounter = -1;
} }
sleep(5);
sleep(5); // Wait a bit for loading
$this->joinGiveaway($browser); $this->joinGiveaway($browser);
$browser->within(new MainNav, function (Browser $browser) { $browser->within(new MainNav, function (Browser $browser) {
$browser->goToHome(); $browser->goToHome();