【问题标题】:Element <span> is not clickable at point (1039,84) because another element <div class="_2dDPU CkGkG"> obscures it元素 <span> 在点 (1039,84) 处不可点击,因为另一个元素 <div class="_2dDPU CkGkG"> 遮住了它
【发布时间】:2021-08-03 00:24:06
【问题描述】:

我试图用 selenium 点击like按钮,这是我得到的异常错误:

[-] Passed One Message: Element <span class="glyphsSpriteHeart__filled__16__white u-__7"> is not clickable at point (1039,84) because another element <div class="_2dDPU   CkGkG"> obscures it

我已经尝试使用一个循环来解决它,该循环使用 Xpath 来单击所有像元素一样的 aria 标签,请参阅我的代码:

        while count <= likes:
            try:
                likeopt = bot.find_elements_by_xpath("//*[@aria-label='Like'] ")
                for likeopti in likeopt:
                    likeopti.click()
                    #bot.find_element_by_class_name("fr66n").click()
                    print("[+] Liked !", count)
                    count += 1
                time.sleep(random.randint(8, 15))
                bot.find_element_by_class_name("_65Bje").click()
                time.sleep(random.randint(8, 15))
            except Exception as e:
                try:
                    bot.find_element_by_class_name("_65Bje").click()
                    time.sleep(random.randint(3, 7))
                    print("[-] Passed One", e)
                except Exception as x:
                    bot.find_elements_by_xpath("//*[@aria-label='Close'] ")
                    continue
                    print(x,"[+]click on X, finished all posts")

你觉得怎么解决?

谢谢

【问题讨论】:

标签: python selenium bots


【解决方案1】:

观察你的脚本运行,并注意它失败的地方。您可能会看到在您的目标链接上显示了某种下拉菜单、弹出“对话框”,甚至是广告。您需要关闭/关闭它才能访问目标链接。

或者,您可以通过指示驱动程序通过 Javascript 发送点击命令来破解它。 bot.execute_script("arguments[0].click();", likeopt) 我通常将此方法保存为最后的手段,因为它不代表用户将如何与页面交互。

【讨论】:

    猜你喜欢
    • 2019-07-05
    • 2020-06-10
    • 2018-08-21
    • 1970-01-01
    • 1970-01-01
    • 2020-09-24
    • 2021-07-27
    • 2020-02-03
    相关资源
    最近更新 更多