From f1f32c44b54033c6626634e9db6112793f53e57a Mon Sep 17 00:00:00 2001 From: Matthias Guillitte Date: Wed, 19 Feb 2025 18:50:34 +0100 Subject: [PATCH] Fix daily free screenshot --- app/Browser/Jobs/Hellcase/HellcaseJob.php | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/app/Browser/Jobs/Hellcase/HellcaseJob.php b/app/Browser/Jobs/Hellcase/HellcaseJob.php index 070f626..a0d15ac 100644 --- a/app/Browser/Jobs/Hellcase/HellcaseJob.php +++ b/app/Browser/Jobs/Hellcase/HellcaseJob.php @@ -208,6 +208,10 @@ class HellcaseJob extends BrowserJob // Click the dailyfree button $availibleInButton->click(); + sleep(15); + + $browser->waitForText("Your drop", 30, true); + $lootElement = $browser->driver->findElement(WebDriverBy::xpath('//div[contains(@class, "daily-free-win-bonus")]')); $lootElement->takeElementScreenshot(HellcaseDailyFreeScreenshot::getImgFileAbsolutePath()); @@ -222,11 +226,12 @@ class HellcaseJob extends BrowserJob * @throws \Exception * @return void */ - private function fillDailyFreeConditions(Browser $browser) { + private function fillDailyFreeConditions(Browser $browser) + { // 1. See what conditions we need to fullfill $conditions = []; $conditionsDivs = $browser->driver->findElements(WebDriverBy::xpath('//*[@class = "daily-free-requirement__heading-left"]')); - for($i = 0; $i < sizeof($conditionsDivs); $i++) { + for ($i = 0; $i < sizeof($conditionsDivs); $i++) { $conditionDiv = $conditionsDivs[$i]; // See if the element has the completed class $conditions[$i] = [ @@ -253,13 +258,14 @@ class HellcaseJob extends BrowserJob * @param \Laravel\Dusk\Browser $browser * @return void */ - private function changeSteamProfilePicture(Browser $browser) { + private function changeSteamProfilePicture(Browser $browser) + { // Get all of the availible image link $images = $browser->driver->findElements(WebDriverBy::xpath('//a[@class = "daily-free-user-requirement-avatar-item"]')); // Download the image from the second link in a special folder $imageLink = $images[1]->getAttribute("href"); // Download the image in app/Browser/downloads/ - $imagePath = base_path("app/Browser/downloads/Hellcase/pp.jpg"); + $imagePath = base_path("app/Browser/downloads/Hellcase/pp.png"); file_put_contents($imagePath, file_get_contents($imageLink)); $this->goToSteamProfileSettings($browser); @@ -292,7 +298,8 @@ class HellcaseJob extends BrowserJob } } - private function changeSteamProfileToPublic(Browser $browser) { + private function changeSteamProfileToPublic(Browser $browser) + { $this->goToSteamProfileSettings($browser); // Wait for and click "Privacy Settings" @@ -316,7 +323,8 @@ class HellcaseJob extends BrowserJob * @param \Laravel\Dusk\Browser $browser * @return void */ - private function goToSteamProfileSettings(Browser $browser) { + private function goToSteamProfileSettings(Browser $browser) + { // Get the link that has text "Steam profile" $steamProfileLink = $browser->driver->findElement(WebDriverBy::xpath('//a[contains(text(), "Steam profile")]')); $browser->visit($steamProfileLink->getAttribute("href"));