Can't Access Elements On Page (Selenium Python)


I’m trying to access the elements on this page:

I can only access the highest elements (for example, the element with the ID "app"). Whenever I try and access any other element, I get a Exception has occurred: NoSuchElementException error (check my code and the website to see what I’m referring to). Something has to be in the way, but I don’t know what is.


options  = Options()
options.add_experimental_option("prefs", {"download.default_directory" : r"C:\Users\jack_l\Downloads\TESTING TIKTOK"})

driver = webdriver.Chrome(ChromeDriverManager().install(), chrome_options=options)
driver.get(' dog videos')

action = ActionChains(driver)

driver.find_element(By.ID, 'app') # THIS WORKS
driver.find_element(By.CLASS_NAME, 'tiktok-12azhi0-DivHeaderContainer e10win0d0') #THIS GETS AN ERROR

I know that there is no iframe (that I can find at least) on the page. I also know that there is only one window handle. What could be in my way of accessing the elements?


Second line doesn’t work because you cannot pass multiple class names to search by class name. Either try to select element by single class name like

driver.find_element(By.CLASS_NAME, 'tiktok-12azhi0-DivHeaderContainer')


driver.find_element(By.CLASS_NAME, 'e10win0d0')

or use search by CSS-selector

driver.find_element(By.CSS_SELECTOR, '.tiktok-12azhi0-DivHeaderContainer.e10win0d0')

Answered By – JaSON

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published