From 55ec81b4f0891f0373d22d7e81cd29ec26b293d5 Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Sat, 15 Jul 2023 21:03:22 +0200 Subject: [PATCH] Delete cookie banner only if necessary --- scripts/Windows/Scripts/AmdSoftwarePackage.ps1 | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/scripts/Windows/Scripts/AmdSoftwarePackage.ps1 b/scripts/Windows/Scripts/AmdSoftwarePackage.ps1 index d2043cbb..ecf71b8e 100644 --- a/scripts/Windows/Scripts/AmdSoftwarePackage.ps1 +++ b/scripts/Windows/Scripts/AmdSoftwarePackage.ps1 @@ -9,6 +9,7 @@ function Install-AmdSoftwarePackage() { ) $tempDir = $context.GetTempDirectory(); + $cookieBannerSelector = "#onetrust-consent-sdk"; $osSelector = ".os-group:first-of-type"; $summarySelector = "$osSelector summary:first-of-type"; $downloadSelector = "$osSelector .driver:first-of-type a:first-of-type"; @@ -22,9 +23,11 @@ function Install-AmdSoftwarePackage() { $summary.Click(); } - Start-Sleep 10; - $browser.ExecuteScript("document.querySelector('#onetrust-consent-sdk').remove()"); - $browser.FindElement([OpenQA.Selenium.By]::CssSelector($downloadSelector)).Click(); + if (($browser.FindElements([OpenQA.Selenium.By]::CssSelector($cookieBannerSelector))).Count -gt 0) { + $browser.ExecuteScript("document.querySelector('$cookieBannerSelector').remove()"); + } else { + $browser.FindElement([OpenQA.Selenium.By]::CssSelector($downloadSelector)).Click(); + } } $file = Start-CustomDownload $context $url $action $tempDir;