I have below program to take screenshot via selenium
from selenium import webdriver
from selenium.common.exceptions import TimeoutException
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
driver = webdriver.Chrome(executable_path='C:\Downloadsnew\chromedriver_win32\chromedriver.exe')
driver.maximize_window()
#driver.implicitly_wait(40)
driver.get("https://now.com/welcome.do")
#element=WebDriverWait(driver, 10).until(EC.visibility_of_element_located((By.id,'user_name')))
elem = driver.find_element_by_id("user_name")
elem.send_keys("user1")
elem = driver.find_element_by_id("user_password")
elem.send_keys("password1")
elem.send_keys(Keys.RETURN)
elem.click()
WebDriverWait(driver, 100).until(EC.url_changes(driver.current_url))
element=WebDriverWait(driver, 10).until(EC.presenceOfElementLocated((By.XPATH,"//div[@class='sn-widget-list-title'][contains(.,'Dashboards')]"))).click()
print(element)
When i execute it should login with user name and password , and then it will open another page, then I need to click on a link where it says dashboard.
Now what happens is it login sucessfully , then after going to main page, its throwing below error
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.StaleElementReferenceException: Message: stale element reference: element is not attached to the page document
(Session info: chrome=71.0.3578.98)
so I am not sure which element it was saying stale and its dashboard click is not working... can some one suggest what is wrong...so I used one chrome extension called truepath to know exact xpath for that Dashboard link...it said like
//div[@class='sn-widget-list-title'][contains(.,'Dashboards')]
When I another tool called Element locator, then I got xpath as below
//*[@id="b9169d55873212001ac119fa84e3ece3"]/div[1]/div[1]
When I do normal inspect on that dashboard link then do a copy of selector and xpath I get like this:
//*[@id="b9169d55873212001ac119fa84e3ece3"]/div/div
css selector:
#b9169d55873212001ac119fa84e3ece3 > div > div
This is html inspect for that dashboard
I tried all above for locating that element and then click but not working any suggestions please.