I'm trying to do web scraping with python on and I'm having trouble clicking buttons. I've tried 3 different youtube videos using Xpath, driver.find_element_by_link_text, and
driver.find_element.
What am I missing?
https://i.sstatic.net/GnzMU.png https://i.sstatic.net/NfLfX.png https://i.sstatic.net/SkUPL.png
I've tried 3 different youtube videos using Xpath, driver.find_element_by_link_text, and
driver.find_element.
https://youtu.be/USrjHgO9Niw https://youtu.be/TvkRseysDr0 https://youtu.be/U6gbGk5WPws
The javascript for the start button is taking a tiny bit longer to load in, than when selenium thinks the page is finished loading..so it ends up searching for the element and it's not there yet.
All your code needs is a wait for the element to be present on the page.
I also changed the search for the start button, since I was finding multiple elements
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 ECdef initialize_browser():driver=webdriver.Chrome()driver.get("https://virtualracingschool.appspot.com")wait = WebDriverWait(driver, 30)startRacingXpath = '//*[contains(text(), "Join any iRacing session")]/following-sibling::*'click_button = wait.until(EC.presence_of_element_located((By.XPATH, startRacingXpath)))click_button.click()initialize_browser()