jpjacobpadilla / Google-Colab-Selenium

The best way to use Selenium in Google Colab Notebooks!
https://pypi.org/project/google-colab-selenium/
MIT License
156 stars 18 forks source link

Google Search #4

Closed iwo9 closed 6 months ago

iwo9 commented 6 months ago

Hey, how would we use the search bar in google here? Trying search_box = driver.find_element_by_name("q") but the find_element_by_name object doesn't seem to be here

jpjacobpadilla commented 6 months ago

I believe all of the find_element_by_* have been deprecated and are no longer in Python Selenium. Instead try using find_element(By.NAME, 'name')

Like this:

from selenium.webdriver.common.by import By

driver = gs.ChromeDriver()
driver.get('https://google.com')
element = driver.find_element(By.NAME, "q")
print(element.tag_name)
driver.quit()
iwo9 commented 6 months ago

Thanks!