Selenium-xpath“ NoSuchElementException:消息:没有这样的元素:无法找到元素:

时间:2018-09-04 21:53:41

标签: selenium google-chrome selenium-webdriver xpath selenium-chromedriver

我尝试用硒,python和google Chrome浏览器单击一个按钮,但是我总是遇到相同的错误。这是我的代码:

timeout = 40

try:
    element_present = EC.presence_of_element_located((By.ID, 'w106'))
    WebDriverWait(driver, timeout).until(element_present)
except TimeoutException:
    print("Timed out waiting for page to load")

driver.find_element_by_xpath(".//*[@id='w106']").click()

-错误:

  

selenium.common.exceptions.NoSuchElementException:
  消息:没有这样的元素:
  无法找到元素:{“ method”:“ xpath”,“ selector”:“ .//*[@ id ='w106']”}
    (会话信息:chrome = 68.0.3440.106)
    (驱动程序信息:chromedriver = 2.38.552522(437e6fbedfa8762dec75e2c5b3ddb86763dc9dcb),platform = Windows NT 10.0.16299 x86_64)

我也尝试使用

driver.find_element_by_xpath("//span[contains(text(),'continuar')]").click()

-但是我遇到了同样的错误:

  

selenium.common.exceptions.NoSuchElementException:
  消息:没有这样的元素:无法找到元素:{“ method”:“ xpath”,“ selector”:“ // span [contains(text(),'continuar')]”}}
    (会话信息:chrome = 68.0.3440.106)
    (驱动程序信息:chromedriver = 2.38.552522(437e6fbedfa8762dec75e2c5b3ddb86763dc9dcb),platform = Windows NT 10.0.16299 x86_64)

Button code

0 个答案:

没有答案
相关问题