我希望能够单击同意按钮以同意网站上的 cookie,我知道如何在 selenium webdriver 中执行此操作,但是,我不知道如何使用 js 和 mocha 执行此操作,因为我正在尝试学习任何帮助表示赞赏。
我试过了
browser.switchToFrame($('#sp_message_iframe_207015'));
$(getHighlightedText('Agree')).click();
但是没用
基本上,我启动该网站,然后弹出一个询问同意 cookie 并管理 cookie/首选项的弹出窗口,我只想能够点击同意
#sp_message_iframe_207015
是 iframe 的 ID
同意元素看起来像这样
<button
tabindex="0"
title="Agree"
aria-label="Agree"
class="message-component message-button no-children"
path="[0,4,1]"
style="padding: 10px 50px; margin: 10px; border-width: 1px; border-color: rgb(0, 115, 197); border-radius: 20px; border-style: solid; font-size: 14px; font-weight: 600; color: rgb(255, 255, 255); font-family: "trebuchet ms", helvetica, sans-serif; width: auto; background: rgb(0, 115, 197);"
>
Agree
</button>