Issue
Hopefully someone can help me out here.
My goal is to successfully connect to this website using Python (Selenium + Chromedriver) and successfully search for an address in the search bar. Im struggling to manage to find the actual search bar itself using Selenium. The HTML code doesn't have an ID or NAME to distinguish it by, all it has is a class and when i search for the class, i get an error saying it cannot be found.
Hopefully this is an easy fix and im just being silly. Thanks a lot.
P.S First post - please drop some hints on what to change next time :)
CODE
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
PATH = "C:\Program Files (x86)\chromedriver.exe"
driver = webdriver.Chrome(PATH)
driver.get("https://creeper.banano.cc/")
search = driver.find_element_by_class_name("ValidatedSearch form-control form-control-lg ")
ERROR CODE
NoSuchElementException: no such element: Unable to locate element: {"method":"css selector","selector":".ValidatedSearch form-control form-control-lg "}
Solution
ValidatedSearch form-control form-control-lg
is what are referred to as multiple class names.
In order to find the element we use css selector.
driver.find_element(By.CSS_SELECTOR,".ValidatedSearch.form-control.form-control-lg")
Also don't use driver.find_element_by since they are depreciated instead import By and use that.
Answered By - Arundeep Chohan
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.