Skip to content

Commit

Permalink
Bug Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jayrodksmith authored Mar 21, 2024
1 parent 51675a5 commit 165aa76
Showing 1 changed file with 5 additions and 14 deletions.
19 changes: 5 additions & 14 deletions Public/Get-WarrantyHP.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ function Get-WarrantyHP {
try{
Get-WebDriver -WebDriver $DriverMode
Get-SeleniumModule
Write-Verbose "Starting SeleniumModule with drivemode = $DriverMode"
$driver = Start-SeleniumModule -WebDriver $DriverMode -Headless $true
}catch{
Write-Verbose $_.Exception.Message
Expand Down Expand Up @@ -109,15 +110,15 @@ function Get-WarrantyHP {
Write-Host "Checking HP website for serial : $Serial"
$driver.Navigate().GoToUrl("https://support.hp.com/au-en/check-warranty")
# Locate and input the serial number into the form
Write-Verbose "Waiting for any popups"
Start-Sleep -Seconds 15
Write-Verbose "Tyring to get rid of popups"
Set-Privacy
Set-Iframe
Write-Verbose "Inputting serial info"
$serialnumber = $Serial
$inputField = $driver.FindElementById("inputtextpfinder")
Set-Privacy
Set-Iframe
$inputField.SendKeys($serialnumber)
Set-Iframe
Set-Privacy
$submitButton = $driver.FindElementById("FindMyProduct")
$submitButton.Click()
# Wait for the page to load (you might need to adjust the sleep time)
Expand All @@ -136,12 +137,8 @@ function Get-WarrantyHP {
Write-Host "Using SystemSKU input"
Write-Verbose "Need Product ID"
$productField = $driver.FindElementById("product-number inputtextPN")
Set-Privacy
Set-Iframe
$productField.SendKeys($SystemSKU)
$submitButton = $driver.FindElementById("FindMyProductNumber")
Set-Privacy
Set-Iframe
$submitButton.Click()
Write-Host "Waiting for results......."
Start-Sleep -Seconds 15
Expand All @@ -160,12 +157,8 @@ function Get-WarrantyHP {
$systemSKU = Get-ItemProperty -Path $regPath -Name "SystemSKU" -ErrorAction Stop | Select-Object -ExpandProperty "SystemSKU"
Write-Host "SystemSKU value: $systemSKU"
$productField = $driver.FindElementById("product-number inputtextPN")
Set-Privacy
Set-Iframe
$productField.SendKeys($systemSKU)
$submitButton = $driver.FindElementById("FindMyProductNumber")
Set-Privacy
Set-Iframe
$submitButton.Click()
Write-Host "Waiting for results......."
Start-Sleep -Seconds 15
Expand All @@ -179,8 +172,6 @@ function Get-WarrantyHP {
else {
# Continue
}
Set-Privacy
Set-Iframe
# Find the element containing the 'Start date' text
try {
$startDateElement = $driver.FindElementByXPath("//div[contains(@class,'info-item')]//div[contains(@class,'label') and contains(text(), 'Start date')]/following-sibling::div[contains(@class,'text')]")
Expand Down

0 comments on commit 165aa76

Please sign in to comment.