我在 if() 语句中遇到错误:NoSuchElementException: Unable to locate element:

问题描述

company = contact = browser.find_element_by_xpath("//*[@class='compTitle']")
if browser.find_element_by_xpath("//*[@class='partialContents']/div[4]/div[1]/div[10]").is_enabled():
  contact=browser.find_element_by_xpath("//*[@class='partialContents']/div[4]/div[1]/div[10]")

else:
    contact = browser.find_element_by_xpath("//*[@class='partialContents']/div[4]/div[1]/div[9]
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//*[@class='partialContents']/div[4]/div[1]/div[10]"}
  (Session info: chrome=89.0.4389.72)

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)