Traceback (most recent call last): File "D:\pythonsthl\flaskProject\SeleniumTest\18Test11.py", line 43, in <module> element = driver.find_element(By.XPATH, '//*[@id="form_item_account"]').send_keys(VideoAccount) File "D:\pythonsthl\flaskProject\venv\lib\site-packages\selenium\webdriver\remote\webelement.py", line 232, in send_keys Command.SEND_KEYS_TO_ELEMENT, {"text": "".join(keys_to_typing(value)), "value": keys_to_typing(value)} File "D:\pythonsthl\flaskProject\venv\lib\site-packages\selenium\webdriver\common\utils.py", line 140, in keys_to_typing for i in range(len(val)): TypeError: object of type 'type' has no len() Process finished with exit code 1
时间: 2023-08-11 12:07:12 浏览: 254
Python3+selenium配置常见报错解决方案
5星 · 资源好评率100%
这个错误是由于您的`VideoAccount`变量的类型不正确,无法使用`send_keys`方法进行输入。请确保`VideoAccount`的值是一个字符串类型。您可以使用`str()`函数将其转换为字符串,如下所示:
```python
element = driver.find_element(By.XPATH, '//*[@id="form_item_account"]').send_keys(str(VideoAccount))
```
这样就可以解决TypeError错误了。
阅读全文