So I'm trying to download a certain link of a webpage but each time i run the code i get an AttributeError: 'Webdriver' object has no attribute 'findElement'. I'm using selenium and python. here is my code
import selenium
from selenium import web driver
driver = web driver.Firefox()
driver.implicitly_wait(5)
driver.get("The web site I'm trying to take link from")
driver.findElement(By.partialLinkText("DEV.tgz")
Can anybody help me to why I am getting this error
1. Change in source code of the webpage. It's possible that the source code of the webpage may have been changed since the last time you accessed it. Change your code according to the new source to solve the issue.
Hence, press Control+F. A text field will appear. Write the expression and check if it matches with an element in the webpage. If it is matching, then copy the expression and paste in selenium code so we can avoid NoSuchElemetException.
NoSuchElementException is one of the most common exceptions in Selenium WebDriver, and it is thrown when an HTML element cannot be found. A NoSuchElementException occurs when the Selenium locator strategy defined is unable to find the desired HTML element in the web page.
You need to use find_element_by_partial_link_text()
here:
element = driver.find_element_by_partial_link_text('DEV.tgz')
Or, alternatively, you can take find_element()
with By
approach:
from selenium.webdriver.common.by import By
element = driver.find_element(By.PARTIAL_LINK_TEXT, 'DEV.tgz')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With