问题
I am making an Excel sheet that takes pictures from a webshop and places them on Pinterest.
When I try to submit the image URL I can't find the element to perform a click event.
Full HTML code from Pinterest.
<div data-test-id="website-link-submit-button" class="_50 _5a _6e _h _z7 _4q _j" style="height: 100%;">
<svg class="_u0 _3a _u1 _45" height="20" width="20" viewBox="0 0 24 24" aria-label="Verzenden" role="img">
<title>Verzenden</title>
<path d="M6.72 24c.57 0 1.14-.22 1.57-.66L19.5 12 8.29.66c-.86-.88-2.27-.88-3.14 0-.87.88-.87 2.3 0 3.18L13.21 12l-8.06 8.16c-.87.88-.87 2.3 0 3.18.43.44 1 .66 1.57.66"></path>
</svg>
</div>
I have tried:
Set HTMLButtons = HTMLDoc.getElementsByTagName("div")
For Each HTMLbutton In HTMLButtons
Debug.Print HTMLbutton.className
Next HTMLbutton
and
Set HTMLButtons = HTMLDoc.getElementsByTagName("svg")
For Each HTMLbutton In HTMLButtons
Debug.Print HTMLbutton.className
Next HTMLbutton
but neither of them has given me a useful index that can be combined with a .click event.
========================================================================= EDIT
There are three steps to get to the code that is mentioned above.
In the picture underneath you will see the three steps. number three is the button i need to click which when inspected shows the mentioned code.
回答1:
I am not sure the div is clickable but you can select the div with css attribute = value selector
ie.document.querySelector("[data-test-id='website-link-submit-button']")
You can get the svg with
ie.document.querySelector("[aria-label=Verzenden]")
You can get the path with
ie.document.querySelector("[aria-label=Verzenden] > title + path")
You can click by adding
.click
or
.FireEvent "onclick"
to the end of the above e.g.
ie.document.querySelector("[aria-label=Verzenden]").click
ie.document.querySelector("[aria-label=Verzenden] > title + path").FireEvent "onclick"
来源:https://stackoverflow.com/questions/53867389/click-a-button-defined-as-a-div-with-a-svg-linked-to-a-path-with-vba