我无法单击Power BI中的任何按钮

问题描述

说明:

下午好,您能帮助我知道如何在Power BI界面中单击按钮吗?我正在尝试此操作,但对我不起作用

await page.ClickAsync(".themableBackgroundColor");

Url Power Bi

https://app.powerbi.com/view?r=eyjrijoiNGE3Mjg4OWMtZTFhYi00MDUyLTllNzAtNDJmogE4NjY2MzMwIiwidCI6IjhhNDc1YTdmLThlOGYtNDliMi1iMDRkLTZlY2IwNTkzYzYzMyJ9

Power Bi按钮的图像

Image of Power Bi buttons

示例代码HTML

<button type="button" class="themableBackgroundColor" style="width: 40px; height: 40px; overflow: hidden; position: relative; display: block; background-color: transparent; cursor: pointer;">
<span class="button-text" style="text-align: right; max-width: 32px; pointer-events: none; color: rgb(102,102,102); font-family: &quot;Segoe UI&quot;,wf_segoe-ui_normal,helvetica,arial,sans-serif; font-size: 13.3333px; position: absolute; right: 4px; top: 20px;"></span>
<div class="button-icon"><svg viewBox="0 0 22.59 32" width="32" height="32" style="fill: none; pointer-events: none; position: absolute; left: 4px; top: 4px;"><polygon points="20.04 29.25 11.21 25.43 2.37 29.25 2.37 2.5 20.04 2.5 20.04 29.25" style="vector-effect: non-scaling-stroke; stroke-width: 3px; stroke: rgb(102,102); stroke-opacity: 1;"></polygon></svg></div>
<div class="button-outline" style="pointer-events: none; top: 0px; left: 0px; position: absolute; width: 40px; height: 40px; border: none;"></div>
</button>

解决方法

只需使用此功能即可通过脚本单击按钮:

let btn = document.querySelector(".themableBackgroundColor")
btn.addEventListener("click",() => console.log("Button Clicked!"))
btn.click();