我有一个弹出窗口无法关闭的问题。我曾尝试使用try/except来捕捉任何错误,但不知何故找到了元素并单击了close按钮,但该元素实际上并未从页面中消失。下面是我尝试过的代码,但我相信有一个更有效的方法来处理它
def isElementPresent():
try:
close_button = find_element_by_xpath(".//*[@class='x-close']")
if close_button == "Some_Element":
close_button.click()
except:
print('No Such Element')
return False
return True
elementSwitch = isElementPresent()
while elementSwitch == True:
run = isElementPresent()
如有任何建议,我们将不胜感激
目前没有回答
相关问题 更多 >
编程相关推荐