Closed rcs08 closed 3 months ago
Thanks for using my project!
From your screenshot and the error message in it, it looks like you just didn't import the "By" object.
Google-Colab-Selenium just sets up Selenium for you, and so to use any other features/objects in Selenium, like the "By" object, you'll need to import them separately from Selenium.
Try something like this:
from selenium.webdriver.common.by import By
driver = gs.Chrome()
driver.get('https://www.google.com')
elements = driver.find_elements(By.XPATH, '//a')
print(len(elements))
driver.quit()
I want to preface this by saying this is my first time using google_collab_selenium, but I am using your example, so hoping I have not done something basically wrong.
https://colab.research.google.com/drive/1MX3xY23Go1STe7LbDMvwf2KaqHpbrVhC?usp=sharing#scrollTo=vpwUq19kqKqP
I can follow and use driver.get and driver.title, but I cannot get driver.find_element(s) to work (see attached image).
Using "By.ID" produces an error, I have also tried "By.CLASS_NAME" and "by=BY.ID" and get the same error. Is this something I am doing wrong or a issue with find_element(s)
My end goal is to use selenium to use cookies to access a webpage, or, failing that, use selenium to find the element with the accept button to accept cookies before accessing a webpage.