I use selenium with the chromedriver in python.
My problem is that selenium gives me an error as i try to access elements on the chrome download page (chrome://downloads). For example i try to get the file url "http://file.jpg".
<a id="url" target="_blank" href="http://file.jpg">http://file.jpg</a>
But as i try to get the element by its id I get an exception.
Code:
driver = webdriver.Chrome("chromedriver.exe")
driver.get("chrome://downloads/")
file_url = driver.find_element_by_id("url").get_attribute("href")
Exception:
Traceback (most recent call last):
File "<pyshell#34>", line 3, in <module>
driver.find_element_by_id("url")
File "D:\Python\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 269, in find_element_by_id
return self.find_element(by=By.ID, value=id_)
File "D:\Python\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 752, in find_element
'value': value})['value']
File "D:\Python\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 236, in execute
self.error_handler.check_response(response)
File "D:\Python\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 192, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"id","selector":"url"}
(Session info: chrome=56.0.2924.87)
(Driver info: chromedriver=2.27.440174 (e97a722caafc2d3a8b807ee115bfb307f7d2cfd9),platform=Windows NT 10.0.10586 x86_64)
Using javascript via driver.execute_script()
didn't work for me either.
Why am i getting a NoSuchElementException
when i can see the element in the browser?