I'm having a lot of issues understanding how to do this. What i need to do is simple, which is to flag whenever my automated google search is not able to find any search results. My code example:
driver = webdriver.Chrome(executable_path)
driver.get("https://google.com/")
search = driver.find_element_by_name("q")
search.send_keys('site:'+'www.pa.gov'+ ' "ADT.com" '+'\n')
if driver.find_element(By.XPATH, "//*[@id='topstuff']/div/div/p[1]/text()[2]"):
print(True)
else:
print(False)
I keep getting this error:
InvalidSelectorException: invalid selector: The result of the xpath expression "//*[@id='topstuff']/div/div/p[1]/text()[2]" is: [object Text]. It should be an element.
(Session info: chrome=87.0.4280.88)
This is the link i've searched No Results
What am I doing wrong?