Been struggling on this for a little while now and I'm pulling my hairout. Why does the 1st code not work? But second one does?
'''from selenium import webdriver
from selenium.webdriver.common.keys import Keys
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
driver = webdriver.Chrome(executable_path='/Users/jackrossanderson/Desktop/chromedriver')
driver.get('https://www.url.Iwanttoscrape.com')
search = driver.find_element_by_name('searchbar')
search.send_keys("hometown")
search.send_keys(Keys.RETURN)
try:
element = WebDriverWait(driver, 10).until(
EC.presence_of_element_located((By.Class_Name, 'button i want to click'))
)
element.click()
driver.back()
except:
print(error)'''
'''from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
import time
driver = webdriver.Chrome(executable_path='/Users/jackrossanderson/Desktop/chromedriver')
driver.get('https://www.urlIwanttoscrape')
search = driver.find_element_by_name('searchbar')
search.send_keys("home town")
search.send_keys(Keys.RETURN)
time.sleep(12)
element = driver.find_element_by_class_name('button I want to press')
element.click()
driver.back()'''
I know the second way is frowned upon but I cant see why the top one doesnt work?