selenium - Python Splinter - Message: stale element reference. However waiting does not resolve issue -
i'm writing python code navigates through webpages using chrome webdriver , splinter:
driver.switch_to.frame(driver.find_element_by_id("accountsummaryframe")) time.sleep(10) login2 = driver.find_elements_by_tag_name("a") actions.click(login2) actions.perform()
at actions.perform(), error occurs:
selenium.common.exceptions.staleelementreferenceexception: message: 'stale element reference: element not attached page document\n (session info: chrome=37.0.2062.124)\n (driver info: chromedriver=2.11.298604 (75ea2fdb5c87f133a8e1b8da16f6091fb7d5321e),platform=windows nt 6.2 x86_64)'
i tried time.sleep function stale error still happens. element on page , know programme has found it:
[<selenium.webdriver.remote.webelement.webelement object @ 0x033b3b10>]
i want inquire can resolve problem. give thanks you!
edit:
i changed code find_element_by_class_name , searched element 1 time still got stale element error?
time.sleep(5) driver.switch_to.frame(driver.find_element_by_id("accountsummaryframe")) time.sleep(5) actions.click(driver.find_element_by_class_name("platform_spot")).perform()
the whole code following:
import os splinter import browser splinter import driver selenium import webdriver import time selenium.webdriver.common.action_chains import actionchains url = "http://www.example.com" driver = webdriver.chrome(executable_path='c:\chromedriver_win32\chromedriver.exe') driver.get(url) actions = actionchains(driver) driver.switch_to.frame(driver.find_element_by_tag_name("iframe")) form_username = driver.find_element_by_name('login[username]') form_password = driver.find_element_by_name('login[password]') form_username.send_keys("username") form_password.send_keys("password") time.sleep(5) login_button = driver.find_element_by_id('mini_submit_login') actions.click(login_button) actions.perform() driver.switch_to.default_content() time.sleep(5) driver.switch_to.frame(driver.find_element_by_id("accountsummaryframe")) time.sleep(5) actions.click(driver.find_element_by_class_name("platform_spot")).perform()
python selenium selenium-webdriver webdriver splinter
No comments:
Post a Comment