单击定义为带有 SVG 的 DIV 的按钮,该按钮链接到带有 VBA 的路径 [英] Click a button defined as a DIV with a SVG linked to a path with VBA

查看:28
本文介绍了单击定义为带有 SVG 的 DIV 的按钮,该按钮链接到带有 VBA 的路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在制作一张 Excel 表格,可以从网上商店拍摄照片并将它们放在 Pinterest 上.

当我尝试提交图片 URL 时,我找不到执行点击事件的元素.

来自 Pinterest 的完整 HTML 代码.

<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><路径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.18 0L13.21 12l-8.06 8.16c-.87.88-.87 2.3 0 3.18.43.44 1 .66 1.57.66"</path></svg>

我试过了:

Set HTMLButtons = HTMLDoc.getElementsByTagName("div")对于 HTMLButtons 中的每个 HTMLbuttonDebug.Print HTMLbutton.className下一个 HTML 按钮

Set HTMLButtons = HTMLDoc.getElementsByTagName("svg")对于 HTMLButtons 中的每个 HTMLbuttonDebug.Print HTMLbutton.className下一个 HTML 按钮

但他们都没有给我一个可以与 .click 事件结合使用的有用索引.

==========================================================================编辑

获得上面提到的代码需要三个步骤.

在下面的图片中,您将看到三个步骤.第三个是我需要点击的按钮,在检查时会显示提到的代码.

解决方案

我不确定 div 是否可点击,但您可以使用 css attribute = value selector 选择 div

ie.document.querySelector("[data-test-id='website-link-submit-button']")

你可以得到 svg

ie.document.querySelector("[aria-label=Verzenden]")

你可以用

获取路径

ie.document.querySelector("[aria-label=Verzenden] > title + path")

可以点击添加

.click

.FireEvent "onclick"

到上面例子的结尾

ie.document.querySelector("[aria-label=Verzenden]").clickie.document.querySelector("[aria-label=Verzenden] > title + path").FireEvent "onclick"

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.

解决方案

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"

这篇关于单击定义为带有 SVG 的 DIV 的按钮,该按钮链接到带有 VBA 的路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆