PortValhalla/scripts/Windows/Scripts/AmdSoftwarePackage.ps1

44 lines
1.3 KiB
PowerShell
Raw Normal View History

#!/bin/pwsh
. "$PSScriptRoot/Context.ps1";
. "$PSScriptRoot/BrowserAutomation.ps1";
function Install-AmdSoftwarePackage() {
param(
[Context] $context,
[string] $url
)
$tempDir = $context.GetTempDirectory();
2023-07-15 19:03:22 +00:00
$cookieBannerSelector = "#onetrust-consent-sdk";
2023-07-15 18:42:25 +00:00
$osSelector = ".os-group:first-of-type";
$summarySelector = "$osSelector summary:first-of-type";
$downloadSelector = "$osSelector .driver:first-of-type a:first-of-type";
$action = {
param([OpenQA.Selenium.Firefox.FirefoxDriver] $browser)
$summary = $browser.FindElement([OpenQA.Selenium.By]::CssSelector($summarySelector));
if (-not ([bool]$summary.GetAttribute("aria-expanded"))) {
$summary.Click();
}
$downloader = {
param()
2023-07-15 19:03:22 +00:00
$browser.FindElement([OpenQA.Selenium.By]::CssSelector($downloadSelector)).Click();
}
try {
$downloader.Invoke();
} catch {
$browser.ExecuteScript("document.querySelector('$cookieBannerSelector').remove()");
$downloader.Invoke();
}
2023-07-15 18:42:25 +00:00
}
$file = Start-CustomDownload $context $url $action $tempDir;
Start-Process -Wait -FilePath $file -ArgumentList "/S";
Remove-Item -Recurse $tempDir;
}