I have tried to locate this element in the screenshot by searching for xpath, outerhtml, expanded xpath, css selector, class name, and others. I am automating a program to download a pdf from a website but for some reason the element that I need to click on to download it is a dynamic element. Here is my code (I have censored sensitive information):
from selenium import webdriver
import time
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
username = "***"
password = '***'
driver = webdriver.Chrome()
def info_fill():
driver.get ('***')
driver.find_element_by_xpath('//*[@id="fsLoginUsernameField1249"]').send_keys(username)
driver.find_element_by_xpath ('//*[@id="fsLoginPasswordField1249"]').send_keys(password)
def login():
driver.find_element_by_xpath('//*[@id="fsEl_1249"]/div/div[1]/form/input[5]').click()
def portal():
time.sleep(4)
driver.get('***')
def get_grade_doc():
time.sleep(4)
driver.find_element_by_xpath('//*[@id="navigation-top"]/ic-sidebar/div/ic-tool-list/nav/ul/li[5]/a').click()
try:
element = WebDriverWait(driver, 10).until(
EC.presence_of_element_located((By.CLASS_NAME, "/html/body/iframe[@id='xh-bar']"))
)
finally:
driver.find_element_by_xpath("/html/body/iframe[@id='xh-bar']").click()
info_fill()
login()
portal()
get_grade_doc()
driver.quit()
Here is a screenshot of the web inspector. The element that I am targeting is highlighted.
this is the error message I am getting
<li _ngcontent-pts-c11="" class="divider__content documents__row clickable
flex--space-between" role="link" tabindex="0"><div _ngcontent-pts-c11=""
class="pr-4 float-left"><div _ngcontent-pts-c11="">Gradebook Detail -
November 2020</div><!----><!----><!----><!----><div _ngcontent-pts-c11=""
class="text-secondary pt-1"> </div><!----><div _ngcontent-pts-c11=""
class="text-secondary pt-1"> 20-21 Upper<!----></div><!----><!----></div><div
_ngcontent-pts-c11="" class="hide-tiny float-right"><!----><i _ngcontent-pts-
c11="" class="fa fa-chevron-right fa-light float-right"></i></div><i
_ngcontent-
pts-c11="" class="fa fa-chevron-right fa-light float-right hide-until-tiny">
</i></li>