[英]Selenium: selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element:
My Code:我的代码:
driver.find_element_by_xpath("//div[@class='x-grid3-cell-inner x-grid3-col-1']//a").click() # Click on Device eid
time.sleep(15)
driver.find_element_by_xpath("//table[@id='ping']//button[contains(text(),'Ping')]").click() # click on Ping
Getting error:获取错误:
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element:
On Chrome and firefox xpath is correct, still getting the error?在 Chrome 和 firefox 上 xpath 是正确的,仍然出现错误? Can anyone help here, I know its a silly任何人都可以在这里提供帮助,我知道这很愚蠢
one.一。
Check whether element is under iFrame
tag, If yes then first need to switch into frame and then perform intended action.检查元素是否在iFrame
标签下,如果是则首先需要切换到框架然后执行预期的操作。
iframe = driver.find_element_by_name('frame_name')
driver.switch_to.frame(iframe)
If its timing related issue then introduce Implicit and explicit wait in your code.如果它的时间相关问题,则在您的代码中引入隐式和显式等待。
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
element = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH, "//div[@class='x-grid3-cell-inner x-grid3-col-1']//a"))
element.click()
Hope this will help希望这会有所帮助
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.