Python selenium Error:
el = driver.find_element_by_xpath('//*[@id="changeCityBox"]/ul/li[2]/a')
driver.find_element_by_xpath('//*[@id="search_input"]').send_keys('python',Keys.ENTER)
Solution: Modify the codes above to:
from selenium.webdriver.common.by import By
el = driver.find_element(By.XPATH,r'//*[@id="changeCityBox"]/ul/li[2]/a')
driver.find_element(By.XPATH,r'//*[@id="search_input"]').send_keys("python",Keys.ENTER)
War here to use the browser driver for Google, other browsers can also be Edge to edge, modify the driver needs to configure the environment
from selenium.webdriver import Chrome
from selenium.webdriver.common.keys import Keys # Button commands for the keyboard
from selenium.webdriver.common.by import By
driver = Chrome()
driver.get("https://www.lagou.com/")
# Find the element copyxpath that the browser needs to operate on
el = driver.find_element(By.XPATH,r'//*[@id="changeCityBox"]/ul/li[2]/a')
# el = driver.find_element_by_xpath('//*[@id="changeCityBox"]/ul/li[2]/a')
el.click() # Click event
# find the input box F12 element copyxpath, enter python content, enter or search button xpath
driver.find_element(By.XPATH,r'//*[@id="search_input"]').send_keys("python",Keys.ENTER)
# driver.find_element_by_xpath('//*[@id="search_input"]').send_keys('python',Keys.ENTER)
Read More:
- [Solved] AttributeError: ‘WebDriver‘ object has no attribute ‘find_element_by_id‘
- [Solved] AttributeError: module ‘selenium.webdriver‘ has no attribute ‘Chrome‘
- Python+Selenium Error: AttributeError: ‘WebDriver‘ NameError: name ‘By‘ is not defined
- [Solved] Selenium python send_key error: list object has no attribute
- [Python] Right-click Selenium to Save the picture error: attributeerror: solution to module ‘pyscreen’ has no attribute ‘locationonwindow’
- [Solved] AttributeError: ‘Manager‘ object has no attribute ‘get_by_natural_key‘
- How to Solve Python AttributeError: ‘module’ object has no attribute ‘xxx’
- Python 3.7 Error: AttributeError: ‘str‘ object has no attribute ‘decode‘ [How to Solve]
- [Modified] AttributeError: ‘socket‘ object has no attribute ‘ioctl‘ python linux
- How to Solve Python AttributeError: ‘dict’ object has no attribute ‘item’
- [Solved] Python Keras Error: AttributeError: ‘Sequential‘ object has no attribute ‘predict_classes‘
- [Solved] python Error: AttributeError: ‘NoneType‘ object has no attribute ‘split‘
- [2021-10-05] Python Error: AttributeError: ‘NoneType‘ object has no attribute ‘append‘
- Python Openyxl Error: AttributeError: ‘int‘ object has no attribute ‘upper‘ [How to Solve]
- Python writes DICOM file (attributeerror: ‘filemetadataset’ object has no attribute ‘transfersyntax uid’ solution)
- [Solved] Pycharm error: attributeerror: ‘Htmlparser’ object has no attribute ‘unescape’
- [Solved] TUM associate.py Scripte Error: AttributeError: ‘dict_keys‘ object has no attribute ‘remove‘
- [Solved] Paramiko error: AttributeError: ‘NoneType’ object has no attribute ‘time’
- [Solved] AttributeError: ‘NoneType‘ object has no attribute ‘append‘
- [Solved] AttributeError: ‘_IncompatibleKeys’ object has no attribute