Delete cookie banner only if necessary

This commit is contained in:
Manuel Thalmann 2023-07-15 21:03:22 +02:00
parent cc8921ff73
commit 55ec81b4f0

View file

@ -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;