from selenium import webdriver
driver = webdriver.Edge()
driver.get(r'https://www.baidu.com/')
driver.find_element(id, 'kw').send_keys("123")
这句代码为什么向搜索框传递123是报错?
"D:\Program Files\JetBrains\New workstation\venv\Scripts\python.exe" "D:/Program Files/JetBrains/New workstation/selemuim_test.py"
Traceback (most recent call last):
File "D:\Program Files\JetBrains\New workstation\selemuim_test.py", line 22, in
driver.find_element(id, 'kw').send_keys("123")
File "D:\Program Files\JetBrains\New workstation\venv\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 1244, in find_element
return self.execute(Command.FIND_ELEMENT, {
File "D:\Program Files\JetBrains\New workstation\venv\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 422, in execute
response = self.command_executor.execute(driver_command, params)
File "D:\Program Files\JetBrains\New workstation\venv\lib\site-packages\selenium\webdriver\remote\remote_connection.py", line 419, in execute
data = utils.dump_json(params)
File "D:\Program Files\JetBrains\New workstation\venv\lib\site-packages\selenium\webdriver\remote\utils.py", line 23, in dump_json
return json.dumps(json_struct)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\json_init_.py", line 231, in dumps
return _default_encoder.encode(obj)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\json\encoder.py", line 199, in encode
chunks = self.iterencode(o, _one_shot=True)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\json\encoder.py", line 257, in iterencode
return _iterencode(o, 0)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\json\encoder.py", line 179, in default
raise TypeError(f'Object of type {o.class.name} '
TypeError: Object of type builtin_function_or_method is not JSON serializable