18.4 C
New York
Monday, March 10, 2025

selenium webdriver – Net scrape – Not clickable Submit button


Solved. Due to AmMilinPatel’s nice assist. to me it is nice!!

Utilizing the assistance,I(user56534)accomplished my remaining supply code and share for others’s reference.
However it have a bug that I do not know the rationale.If anybody know,please beneficiant to me.
[URL-1!]
https://datacentersupport.lenovo.com/ch/ko/warrantylookup#/
[URL-2!]
https://datacentersupport.lenovo.com/ch/ko/merchandise/servers/thinksystem/sr650/7×06/7x06cto1ww/j30a7xlg/guarantee
Bug description:The VBA clicks URL-1, then get URL-2 routinely nicely most case.
However in an important whereas,between URL-1 and URL-2, a alert window(see connected picture) pop up.
In that solid, I have to click on one among two choices. I wish to do it in Code.
I attempted chd.SwitchToAlert.Settle for with out success.
My new objective: how can click on one among two choices between URL-1 and URL-2.

Picture desc: Due to not figuring out the way to add picture,I describe in textual content.
Primarily based on IP,though bodily consumer is in Switzerland,this web site is in US.
Both ahead to Switzerland or proceed with this US web site.
After which beneath, there’re two icons. one is for Switzerland and the opposite is for US.

'My new revised full code
Sub ScrapeWTY_Solved()
Dim ss As String
Dim i, j
                
    Dim chd As New Selenium.ChromeDriver

    Dim arr As Variant, merchandise As Variant
    arr = Array("j30a7xlg", "J303A3DB")
               
    chd.Get "https://datacentersupport.lenovo.com/us/ko/warrantylookup#/"
    
For i = 1 To 10
For j = LBound(arr) To UBound(arr)
    
    chd.FindElementByClass("button-placeholder__input").SendKeys arr(j)
    '-----------------------------------------
    ' Look ahead to the submit button to turn out to be clickable
    'chd.WaitElementPresentByCss("#app-standalone-warrantylookup button", timeout:=5000) 'Not working, Why?
    chd.Wait 5000
       
    'chd.SwitchToAlert.Settle for 'Not working
    
    ' Click on the submit button
    chd.FindElementByCss("#app-standalone-warrantylookup button").Click on

    chd.Wait 5000
    Debug.Print i, j, arr(j), chd.FindElementByCss("#app-psp-warranty > div.psp-warranty__body > div > div.psp-warranty__status > div > div.warranty-status__content > div > div.chart-time-bucket > div.chart-expires > p:nth-child(2) > sturdy").Textual content
    
    chd.GoBack
    
Subsequent j
Subsequent i

Finish Sub

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles