【问题标题】:How can i click to "javascript:void(0)" by selenium我如何点击 selenium 的“javascript:void(0)”
【发布时间】:2021-04-24 07:48:56
【问题描述】:

您好,我想单击 href="javascript:void(0) 下的登录按钮,如下面的 html 代码 由于我对编码的了解不够,所以有人可以帮助我如何点击此链接?

我将 selenium 与 python 3.9 一起使用。非常感谢你们

<div class="flex items-center space-x-4 transition duration-150 ease-in-out text-gray-700 hover:text-primary-500 dark:text-gray-300 dark:hover:text-blue-200" x-show="!user.loggedIn &amp;&amp; !user.loading"><a href="javascript:void(0)" x-on:click="authorizeUser()">Register or Login</a></div>
<a href="javascript:void(0)" x-on:click="authorizeUser()">Register or Login</a>

【问题讨论】:

    标签: python selenium


    【解决方案1】:

    你可以得到a标签和driver.find_element然后点击它

    driver.find_element_by_link_text("Register or Login").click()
    

    【讨论】:

    • 非常感谢 :D 这比我想象的要简单 ^^
    猜你喜欢
    • 1970-01-01
    • 2020-11-24
    • 1970-01-01
    • 2016-06-08
    • 2013-04-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多