Python Selenium unable to locate element even thought it shows up in inspect tab

Question:

I run a query to a webpage and selenium opens the page and I wait till all the scripts are loaded. Then I perform a tag search and by far I’ve tried every method but it always returns
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"css selector","selector":".dowload"}

even though that element is visible on the page and shows up on the inspect tab.

Here’s the code:

from selenium.webdriver.common.by import By
from selenium.webdriver import Chrome, ChromeOptions
from time import sleep

options = ChromeOptions()
# options.addargument("--headless=new")
driver = Chrome(options=options)
driver.set_page_load_timeout(10.0)
Sike = "https://www.instagram.com/"
downloadLink = 'https://gotaku1.com/download?id=OTA3OTk=&typesub=Gogoanime-DUB&title=Death+Note+%28Dub%29+Episode+1'

driver.get(Sike)
sleep(5)
driver.execute_script(f'''window.open("{downloadLink}","_blank");''')
driver.execute_script(f'''window.open("{downloadLink}","_blank");''')
driver.execute_script(f'''window.open("{downloadLink}","_blank");''')
sleep(10)
tags = driver.find_element(By.CLASS_NAME, 'dowload')
print(tags)

The instagram link is just there for no reason

Asked By: Mythical Phantom

||

Answers:

You are opening multiple (3) tabs, but Selenium is trying to find the element on the first opened tab (instagram.com)

Answered By: capy