通过find_element_by_xpath标识的元素返回selenium.common.exceptions.ElementNotVisibleException:消息:元素不可见 [英] Element identified through find_element_by_xpath returns selenium.common.exceptions.ElementNotVisibleException: Message: element not visible

查看:467
本文介绍了通过find_element_by_xpath标识的元素返回selenium.common.exceptions.ElementNotVisibleException:消息:元素不可见的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

点击按钮有问题.如果敌人在比赛中,则此按钮可以单击;如果敌人出局,则此按钮不能单击 开始 我尝试了这个:

I have problem with click button. This button can click if enemy is on play and can't click if enemy go out start I tried with this:

try:
    element= driver.find_element_by_xpath("//button[@class='butwb']")
    if element.is_displayed():       
        print ("Element found")
    else:
        print ("Element not found")
except NoSuchElementException:
    print("No element found") 

结果:

Element not found

如果我添加element.click():

selenium.common.exceptions.ElementNotVisibleException: Message: element not visible

我做错了什么?

推荐答案

与Kuncioso交谈并进入游戏后,我们发现有两个与他的定位器匹配的按钮,第一个被隐藏了.使用下面的代码单击了他想要的第二个按钮,解决了该问题.

After talking to Kuncioso and getting into a game, we found that there were two buttons that matched his locator and the first was hidden. The problem was solved using the code below to click the second button, the one he wanted.

driver.find_elements_by_xpath("//button[@class='butwb']")[1].click()

这篇关于通过find_element_by_xpath标识的元素返回selenium.common.exceptions.ElementNotVisibleException:消息:元素不可见的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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