Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
928 views
in Technique[技术] by (71.8m points)

selenium - How to open href link in chrome to VBA?

Its my first time using VBA. Apparently i need it to help me edit the available stocks from various products (gonna need to learn about looping) and that various products left me with different href stocks edit link Is it possible to click on the href link and open it ? heres the element href location

heres the vba script

Sub AutoFill()

    Dim obj As New WebDriver
    
    obj.Start "chrome", ""
    obj.Get "https://siplah.blibli.com/login/merchant"

    obj.FindElementById("txt-email").SendKeys (ThisWorkbook.Sheets("Pass").Range("E20").Value)
    obj.FindElementById("txt-password").SendKeys (ThisWorkbook.Sheets("Pass").Range("F20").Value)
    obj.FindElementById("btn-login").Click
    obj.Wait (500)
    obj.FindElementByClass("modal-footer").Click
    obj.FindElementById("menu-product").Click

    obj.FindElementById("txt-product-name").SendKeys (ThisWorkbook.Sheets("31 CV").Range("E4").Value)
    obj.FindElementById("btn-search-product").Click

    
    
End Sub

Thank you before!

question from:https://stackoverflow.com/questions/65909122/how-to-open-href-link-in-chrome-to-vba

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Combining an attribute = value css selector with ends with operator to target href by the end if its href value, along with adding in the element className should be sufficient

obj.FindElementByCss(".link[href$='Slip']").click

Read about css selectors here: https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...