0

HTML Code

HTML code

Selenium Code snippet used

self.driver = webdriver.Chrome(chrome_options=self.__chrome_options, 
executable_path=self.__path_for_browser_driver)
self.driver.implicitly_wait(10) # seconds
self.driver.get(self.__url)
self.driver.find_element_by_id('username').send_keys(self.__username)
self.driver.find_element_by_id ('password').send_keys(self.__password)
self.driver.find_element_by_xpath(self.__login_button_xpath).click()
self.driver.find_element_by_id('ReportBugFormModal_title').send_keys('Test')

Recieved following error --

selenium.common.exceptions.StaleElementReferenceException: Message: stale element reference: element is not attached to the page document

Please help me resolve this. Thank you

Derek Pollard
  • 6,953
  • 6
  • 39
  • 59
Sangal
  • 1
  • 2
  • Did you try adding an explicit wait for the presence of the element? – GPT14 Jun 05 '18 at 03:23
  • @GPT14 : explicit wait may not work. – cruisepandey Jun 05 '18 at 04:13
  • possible duplicate of https://stackoverflow.com/questions/12967541/how-to-avoid-staleelementreferenceexception-in-selenium?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa – cruisepandey Jun 05 '18 at 04:14
  • Please read why [a screenshot of code is a bad idea](https://meta.stackoverflow.com/questions/303812/discourage-screenshots-of-code-and-or-errors). Paste the code and properly format it instead. – JeffC Jun 05 '18 at 04:22
  • 1
    Please give full error message, we need to know which element caused StaleElementReferenceException. The full message should tell which element. – yong Jun 05 '18 at 04:37
  • I am agree with @yong , Need to know which element is causing – Ishita Shah Jun 05 '18 at 04:58
  • is test is a text or document – bhupathi turaga Jun 05 '18 at 06:55
  • Use wait() when y try to locate an element. Something like this: wait = WebDriverWait(driver, 10) element = wait.until(EC.element_to_be_clickable((By.ID, 'someid'))) – Zhivko.Kostadinov Jun 05 '18 at 08:11
  • Sorry for not pasting code, will do it soon. Meantime -- Error is produced on self.driver.find_element_by_id('ReportBugFormModal_title').send_keys('Test') This element is highlighted in the HTML code snapshot – Sangal Jun 05 '18 at 19:48
  • Tried with explicit wait, but receiving the same error. – Sangal Jun 06 '18 at 03:11

0 Answers0