From d50b9e97b3909e6e88bb67ddbfea8620562574e1 Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Sat, 15 Jul 2023 21:05:37 +0200 Subject: [PATCH] Try deleting cookie banner in case of an error --- scripts/Windows/Scripts/AmdSoftwarePackage.ps1 | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/scripts/Windows/Scripts/AmdSoftwarePackage.ps1 b/scripts/Windows/Scripts/AmdSoftwarePackage.ps1 index ecf71b8e..6cd445f4 100644 --- a/scripts/Windows/Scripts/AmdSoftwarePackage.ps1 +++ b/scripts/Windows/Scripts/AmdSoftwarePackage.ps1 @@ -23,11 +23,17 @@ function Install-AmdSoftwarePackage() { $summary.Click(); } - if (($browser.FindElements([OpenQA.Selenium.By]::CssSelector($cookieBannerSelector))).Count -gt 0) { - $browser.ExecuteScript("document.querySelector('$cookieBannerSelector').remove()"); - } else { + $downloader = { + param() $browser.FindElement([OpenQA.Selenium.By]::CssSelector($downloadSelector)).Click(); } + + try { + $downloader.Invoke(); + } catch { + $browser.ExecuteScript("document.querySelector('$cookieBannerSelector').remove()"); + $downloader.Invoke(); + } } $file = Start-CustomDownload $context $url $action $tempDir;