简体   繁体   English

无法使用 selenium 在带有 python 的网页上进行此搜索

[英]Can't make this search on a webpage with python using selenium

I'm running the following script to make a search for books on this webpage:我正在运行以下脚本来搜索此网页上的书籍:

from selenium import web-driver
from selenium.webdriver.common.keys import Keys
import time

PATH = "C:\Program Files (x86)\chromedriver.exe"
driver = webdriver.Chrome(PATH)

#going to a website
driver.get("https://pacobello.com.br/")

#print the page title
print(driver.title)

search = driver.find_element_by_name("s")
search.send_keys("Saramago")
search.send_keys(Keys.RETURN)

time.sleep(5)

#quit a tab
#driver.close()

#quit the browser
driver.quit()

And I'm getting the following error:我收到以下错误:

raise exception_class(message, screen, stacktrace)

ElementNotInteractableException: element not interactable
  (Session info: chrome=84.0.4147.125)

Does anyone have an idea about this?有人对此有任何想法吗?

Use XPATH instead:使用 XPATH 代替:

search = driver.find_element_by_xpath("//input[@type='text']")

Therefore the complete code will be:因此完整的代码将是:

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time


PATH = "C:\Program Files (x86)\chromedriver.exe"
driver = webdriver.Chrome(PATH)

#going to a website
driver.get("https://pacobello.com.br/")

#print the page title
print(driver.title)

search = driver.find_element_by_xpath("//input[@type='text']")
search.send_keys("Saramago")
search.send_keys(Keys.RETURN)

time.sleep(5)

#quit a tab
#driver.close()

#quit the browser
driver.quit()

install 83 version of chrome not 84安装 83 版本的 chrome 不是 84

https://chromedriver.chromium.org/downloads https://chromedriver.chromium.org/downloads

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法在python中使用selenium在网页中加载“显示更多”? - Can't load “Show more” in a webpage using selenium in python? 我无法使用Python / Selenium单击网页中的任何元素 - I can't click any element in a webpage using Python/Selenium Selenium无法点击网页python的按钮 - Selenium can't click the button of a webpage python 使用PythonAnywhere时无法在网页上进行Selenium搜索 - Can't make Selenium search on a web page when using PythonAnywhere 无法使用 selenium 和 python 获取 instagram 搜索框 - Can't get instagram search box using selenium and python 如何使用 Python 中的 Selenium 在特定区域内的网页中搜索文本 - How to search for text in a webpage within a specific area using Selenium in Python 与移动用户代理一起使用时,无法单击使用 python selenium 的网页元素 - Can't click on webpage element using python selenium when used with mobile user-agent Python Selenium - 无法从网页检索价格 - Python Selenium - Can't manage to retrieve price from webpage Python,Selenium-无法找到ID为“ next”的网页元素(按钮) - Python, Selenium - can't locate a webpage element (button) with ID 'next' Python Selenium 在网页上找不到任何元素 - Python Selenium can't find any element on a webpage
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM