Skip to content

Commit

Permalink
Merge pull request #7 from jayrodksmith/dev-edge
Browse files Browse the repository at this point in the history
HP Lookup function Fix
  • Loading branch information
jayrodksmith authored Mar 12, 2024
2 parents 0478b92 + 5208d90 commit ffb1fb3
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 79 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,20 @@

## [Unreleased]

# [1.0.2] - 11-03-2024

### Added

### Changed

### Deprecated

### Removed

### Fixed

- HP Lookup function

# [1.0.1] - 11-03-2024

### Added
Expand Down
2 changes: 1 addition & 1 deletion EasyWarrantyCheck.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
RootModule = 'EasyWarrantyCheck.psm1'

# Version number of this module.
ModuleVersion = '1.0.1'
ModuleVersion = '1.0.2'

# Supported PSEditions
# CompatiblePSEditions = @()
Expand Down
71 changes: 32 additions & 39 deletions EasyWarrantyCheck_RMM.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -458,8 +458,25 @@ function Get-WarrantyDell {
$warEndDate = $FormattedDate
$warrantystatus = "In Warranty"
}
# Try for Start Date
try {
$checkDeviceDetails = $driver.FindElementByClassName("dds__button--secondary")
$checkDeviceDetails.Click()
Start-Sleep -Seconds 10
$ManageServicesButton = $driver.FindElementByClassName("viewDetailsWarranty")
$ManageServicesButton.Click()
Start-Sleep -Seconds 10
$PurchaseDateElement = $driver.FindElementById("dsk-purchaseDt")
$PurchaseDate = $PurchaseDateElement.Text
$WarrantystartDate = [datetime]::ParseExact($PurchaseDate, "dd MMM yyyy", [System.Globalization.CultureInfo]::InvariantCulture)
$warStartDate = $WarrantystartDate.ToString($dateformat)
} catch {
Write-Host "The purchase date field could not be found."
$warStartDate = $null
}

} else {
Write-Host "No matching text found for warranty status"
Write-Host "No matching text found for warranty end date "
}
# Close the browser
Stop-SeleniumModule -WebDriver $Seleniumdrivermode
Expand All @@ -468,7 +485,7 @@ function Get-WarrantyDell {
$WarObj = [PSCustomObject]@{
'Serial' = $serial
'Warranty Product name' = $null
'StartDate' = $null
'StartDate' = $warStartDate
'EndDate' = $warEndDate
'Warranty Status' = $warrantystatus
'Client' = $null
Expand Down Expand Up @@ -791,59 +808,42 @@ function Get-WarrantyHP {
}
# Find the element containing the 'Start date' text
try {
$startDateElement = $driver.FindElementByXPath("//div[@class='info-item ng-tns-c70-0 ng-star-inserted']//div[@class='label ng-tns-c70-0' and contains(text(), 'Start date')]/following-sibling::div[@class='text ng-tns-c70-0']")
$startDateElement = $driver.FindElementByXPath("//div[contains(@class,'info-item')]//div[contains(@class,'label') and contains(text(), 'Start date')]/following-sibling::div[contains(@class,'text')]")
}
catch {
$startDateElement = $null
Write-Host "Could not find warranty Start date"
}
if (-not $startDateElement) {
try {
$startDateElement = $driver.FindElementByXPath("//div[@class='info-item ng-tns-c72-0 ng-star-inserted']//div[@class='label ng-tns-c72-0' and contains(text(), 'Start date')]/following-sibling::div[@class='text ng-tns-c72-0']")
}
catch {
Write-Host "Could not find warranty Start date"
}
}

if ($startDateElement) {
# Get the text of the 'Start date' element
$startDateText = $startDateElement.Text
$startDateText = Get-Date $startDateText -Format $dateformat
}
try {
# Find the element containing the 'End date' text
$endDateElement = $driver.FindElementByXPath("//div[@class='info-item ng-tns-c70-0 ng-star-inserted']//div[@class='label ng-tns-c70-0' and contains(text(), 'End date')]/following-sibling::div[@class='text ng-tns-c70-0']")
$endDateElement = $driver.FindElementByXPath("//div[contains(@class,'info-item')]//div[contains(@class,'label') and contains(text(), 'End date')]/following-sibling::div[contains(@class,'text')]")

}
catch {
$endDateElement = $null
Write-Host "Could not find warranty End date"
}
if (-not $endDateElement) {
try {
$endDateElement = $driver.FindElementByXPath("//div[@class='info-item ng-tns-c72-0 ng-star-inserted']//div[@class='label ng-tns-c72-0' and contains(text(), 'End date')]/following-sibling::div[@class='text ng-tns-c72-0']")
}
catch {
Write-Host "Could not find warranty End date"
}
}

if ($endDateElement) {
# Get the text of the 'End date' element
$endDateText = $endDateElement.Text
$endDateText = Get-Date $endDateText -Format $dateformat
}
try {
# Find the element containing the 'Warranty Status' or 'Time Remaining' text
$warrantyStatusElement = $driver.FindElementByXPath("//div[@class='info-item ng-tns-c70-0 ng-star-inserted']//div[@class='label ng-tns-c70-0' and contains(text(), 'Time Remaining')]/following-sibling::div[@class='text ng-tns-c70-0']")
$warrantyStatusElement = $driver.FindElementByXPath("//div[contains(@class,'info-item')]//div[contains(@class,'label') and contains(text(), 'Time Remaining')]/following-sibling::div[contains(@class,'text')]")
}
catch {
$warrantyStatusElement = $null
Write-Host "Could not find warranty Status"
}
if (-not $warrantyStatusElement) {
try {
$warrantyStatusElement = $driver.FindElementByXPath("//div[@class='info-item ng-tns-c72-0 ng-star-inserted']//div[@class='label ng-tns-c72-0' and contains(text(), 'Time Remaining')]/following-sibling::div[@class='text ng-tns-c72-0']")
}
catch {
Write-Host "Could not find warranty Status"
}
}

if ($warrantyStatusElement) {
$warrantyStatusText = $warrantyStatusElement.Text
if ($warrantyStatusText -match "Expired") {
Expand All @@ -852,20 +852,13 @@ function Get-WarrantyHP {
}
try {
# Find the element containing the 'Product' information
$h2Element = $driver.FindElementByCssSelector(".product-info-text.ng-tns-c70-0 > h2")
$h2Element = $driver.FindElementByXPath("//main//h2")
}
catch {
$h2Element = $null
Write-Host "Could not find Product Name"
}
if (-not $h2Element) {
try {
# Find the element containing the 'Product' information
$h2Element = $driver.FindElementByCssSelector(".product-info-text.ng-tns-c72-0 > h2")
}
catch {
$h2Element = $null
}
}

if ($h2Element) {
$product = $h2Element.Text
}
Expand Down
21 changes: 19 additions & 2 deletions Public/Get-WarrantyDell.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,25 @@ function Get-WarrantyDell {
$warEndDate = $FormattedDate
$warrantystatus = "In Warranty"
}
# Try for Start Date
try {
$checkDeviceDetails = $driver.FindElementByClassName("dds__button--secondary")
$checkDeviceDetails.Click()
Start-Sleep -Seconds 10
$ManageServicesButton = $driver.FindElementByClassName("viewDetailsWarranty")
$ManageServicesButton.Click()
Start-Sleep -Seconds 10
$PurchaseDateElement = $driver.FindElementById("dsk-purchaseDt")
$PurchaseDate = $PurchaseDateElement.Text
$WarrantystartDate = [datetime]::ParseExact($PurchaseDate, "dd MMM yyyy", [System.Globalization.CultureInfo]::InvariantCulture)
$warStartDate = $WarrantystartDate.ToString($dateformat)
} catch {
Write-Host "The purchase date field could not be found."
$warStartDate = $null
}

} else {
Write-Host "No matching text found for warranty status"
Write-Host "No matching text found for warranty end date "
}
# Close the browser
Stop-SeleniumModule -WebDriver $Seleniumdrivermode
Expand All @@ -111,7 +128,7 @@ function Get-WarrantyDell {
$WarObj = [PSCustomObject]@{
'Serial' = $serial
'Warranty Product name' = $null
'StartDate' = $null
'StartDate' = $warStartDate
'EndDate' = $warEndDate
'Warranty Status' = $warrantystatus
'Client' = $null
Expand Down
50 changes: 13 additions & 37 deletions Public/Get-WarrantyHP.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -149,59 +149,42 @@ function Get-WarrantyHP {
}
# Find the element containing the 'Start date' text
try {
$startDateElement = $driver.FindElementByXPath("//div[@class='info-item ng-tns-c70-0 ng-star-inserted']//div[@class='label ng-tns-c70-0' and contains(text(), 'Start date')]/following-sibling::div[@class='text ng-tns-c70-0']")
$startDateElement = $driver.FindElementByXPath("//div[contains(@class,'info-item')]//div[contains(@class,'label') and contains(text(), 'Start date')]/following-sibling::div[contains(@class,'text')]")
}
catch {
$startDateElement = $null
Write-Host "Could not find warranty Start date"
}
if (-not $startDateElement) {
try {
$startDateElement = $driver.FindElementByXPath("//div[@class='info-item ng-tns-c72-0 ng-star-inserted']//div[@class='label ng-tns-c72-0' and contains(text(), 'Start date')]/following-sibling::div[@class='text ng-tns-c72-0']")
}
catch {
Write-Host "Could not find warranty Start date"
}
}

if ($startDateElement) {
# Get the text of the 'Start date' element
$startDateText = $startDateElement.Text
$startDateText = Get-Date $startDateText -Format $dateformat
}
try {
# Find the element containing the 'End date' text
$endDateElement = $driver.FindElementByXPath("//div[@class='info-item ng-tns-c70-0 ng-star-inserted']//div[@class='label ng-tns-c70-0' and contains(text(), 'End date')]/following-sibling::div[@class='text ng-tns-c70-0']")
$endDateElement = $driver.FindElementByXPath("//div[contains(@class,'info-item')]//div[contains(@class,'label') and contains(text(), 'End date')]/following-sibling::div[contains(@class,'text')]")

}
catch {
$endDateElement = $null
Write-Host "Could not find warranty End date"
}
if (-not $endDateElement) {
try {
$endDateElement = $driver.FindElementByXPath("//div[@class='info-item ng-tns-c72-0 ng-star-inserted']//div[@class='label ng-tns-c72-0' and contains(text(), 'End date')]/following-sibling::div[@class='text ng-tns-c72-0']")
}
catch {
Write-Host "Could not find warranty End date"
}
}

if ($endDateElement) {
# Get the text of the 'End date' element
$endDateText = $endDateElement.Text
$endDateText = Get-Date $endDateText -Format $dateformat
}
try {
# Find the element containing the 'Warranty Status' or 'Time Remaining' text
$warrantyStatusElement = $driver.FindElementByXPath("//div[@class='info-item ng-tns-c70-0 ng-star-inserted']//div[@class='label ng-tns-c70-0' and contains(text(), 'Time Remaining')]/following-sibling::div[@class='text ng-tns-c70-0']")
$warrantyStatusElement = $driver.FindElementByXPath("//div[contains(@class,'info-item')]//div[contains(@class,'label') and contains(text(), 'Time Remaining')]/following-sibling::div[contains(@class,'text')]")
}
catch {
$warrantyStatusElement = $null
Write-Host "Could not find warranty Status"
}
if (-not $warrantyStatusElement) {
try {
$warrantyStatusElement = $driver.FindElementByXPath("//div[@class='info-item ng-tns-c72-0 ng-star-inserted']//div[@class='label ng-tns-c72-0' and contains(text(), 'Time Remaining')]/following-sibling::div[@class='text ng-tns-c72-0']")
}
catch {
Write-Host "Could not find warranty Status"
}
}

if ($warrantyStatusElement) {
$warrantyStatusText = $warrantyStatusElement.Text
if ($warrantyStatusText -match "Expired") {
Expand All @@ -210,20 +193,13 @@ function Get-WarrantyHP {
}
try {
# Find the element containing the 'Product' information
$h2Element = $driver.FindElementByCssSelector(".product-info-text.ng-tns-c70-0 > h2")
$h2Element = $driver.FindElementByXPath("//main//h2")
}
catch {
$h2Element = $null
Write-Host "Could not find Product Name"
}
if (-not $h2Element) {
try {
# Find the element containing the 'Product' information
$h2Element = $driver.FindElementByCssSelector(".product-info-text.ng-tns-c72-0 > h2")
}
catch {
$h2Element = $null
}
}

if ($h2Element) {
$product = $h2Element.Text
}
Expand Down

0 comments on commit ffb1fb3

Please sign in to comment.