Python Selenium Tutorial #2 - Locating Elements From HTML

Tech With Tim · 747K views · 2020 · 16:12

Open on YouTube

Python, Ruby & scripting languagesTesting, debugging & developer toolsWeb developmenttutorialdated

Why Stack Overflow recommends it

Stack Overflow users mostly mention it as the tutorial they were following when their code broke, often because the video's older Selenium API calls no longer work.

Recommended by 1 people across 1 different months, 2021 to 2022.

What it is

A 16-minute Python Selenium tutorial from Tech With Tim, the second in a series, showing how to locate elements on a webpage by ID, class name, name and other attributes. The demo searches a website and lists the results.

What people said

Recommends Shawn · 2021-05 · Stack Overflow · on “How to restart webdriver Selenium when script is finished”

We do the same thing here where we test when we want to attempt a "retry" of a test. One thing to note in your code above; you give no wait time for the "cool-button" to appear, become clickable or it's presence known; that will often lead to a failing result. I added support for that; as well as encompassed the entire code in an keyboard interrupted while loop. from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC import time try: while True: driver = webdriver.Chrome() url = " [LINK] " driver.get(url) try: button = WebDriverWait(driver, 5).until(EC.p

Cites wheedwhackerjones · 2021-09 · Stack Overflow · on “Selenium - Failed to Establish New Connection”

I'm following this tutorial and pasted the exact code from the video: [this video] from selenium import webdriver PATH = "/home/matt/learnselenium/chromedriver" driver = webdriver.Chrome(PATH) driver.get(" [LINK] ") print(driver.title) driver.quit() search = driver.find_element_by_name("s") search.send_keys("test") search.send_keys(Keys.RETURN) time.sleep(5) driver.quit() And I get the following error: urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='127.0.0.1', port=54375): Max retries exceeded with url: /session/efc07a083600a61c9bc65e262061dd37/element (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f254da226a0>: Failed to establish a new connection: [Er

Cites Herkul · 2022-12 · Stack Overflow · on “Selenium find_all method raises AttributeError: 'list' object has no attribute 'find_elements'”

I was watching a YouTube Tutorial video about Selenium for python Python Selenium Tutorial - Tech with Tim [this video] . The video was uploaded 2 years ago and it seems there are changes in Selenium for python (the find_elements_by_... functions were replaced by find_elements(by = ...) ). My problem is, when I try to convert the code, I get an AttributeError as: AttributeError: 'list' object has no attribute 'find_elements' . I am sharing both the old and new version of the code. What is the difference between the old version and why am I getting the following error? How can I fix it? Thanks in advance! ###Old Version### from selenium import webdriver from selenium.webdriver.common.keys import K