Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

findElement Error Python using selenium

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

like image 408
Jerad Bill Avatar asked Aug 11 '14 17:08

Jerad Bill


People also ask

How do you handle no such element exception in selenium Python?

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.

How do I ignore no such element exception in selenium?

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.

Why do we get no such element exception in selenium?

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.


1 Answers

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')
like image 104
alecxe Avatar answered Oct 16 '22 19:10

alecxe