I use a mix of VBA and now Selenium to automate some of my office tasks. I have a list of serial numbers (SN) for some devices in Excel, and I am trying to write a script to open Chrome at a Dell support page, input the SN into a field to check the warranty, and return the expiration date into Excel. I cannot bypass the click button operation, usually it would work just fine, alternatively I would use submit, but this time I cannot find the solution.
I know there are APIs to use with Dell that will return the expiration date but I don't want to use the API key for some reasons.
Once I manage to sort out the click, I will pull SN values into an array and loop through instead of using ActiveCell.
Thanks for your suggestions, Karel
Sub CheckDellWarranty()
' Set up Selenium
Dim driver As New WebDriver
driver.Start "chrome"
' Navigate to the specific URL
driver.Get "https://www.dell.com/support/home/fr-fr?app=products"
' Wait for Chrome to load
driver.wait 3000
' Get the value of the currently selected cell in Excel
Dim cellValue As String
cellValue = Application.ActiveCell.value
' Insert the value into the specified field using XPath
Dim inputElement As WebElement
Set inputElement = driver.FindElementByXPath("/html/body/div[5]/div/div[3]/div[1]/div/div/div[2]/div[1]/div[1]/div[1]/div/div/form/input")
inputElement.SendKeys cellValue
' Enable the search button
driver.ExecuteScript "document.getElementById('btn-entry-select').disabled = false;"
' Find the search button by its ID
Dim searchButton As WebElement
Set searchButton = driver.FindElementById("btn-entry-select")
EVEN THOUGH IT CLICKS, THE BUTTON JUST SPINS AND WILL NOT SEARCH. WHEN I OPEN CHROME MANUALLY, THE CLICK ACTION ACTUALLY FINDS THE SN.
If Not searchButton Is Nothing Then
' Use JavaScript to trigger the click event on the search button
driver.ExecuteScript "arguments[0].click();", searchButton
Else
MsgBox "Failed to locate the button."
End If
Stop
End Sub