selenium中class_name定位元素出现异常
driver.find_element_by_class_name('pass-text-input pass-text-input-phone').send_keys('1234567890')出错原因是因为class_name中的空格是后代选择器,只需要将空格及其前面的删除及可解决```pythonselenium.common.exceptions.InvalidSelectorExcept
·
driver.find_element_by_class_name('pass-text-input pass-text-input-phone').send_keys('1234567890')
出错原因是因为class_name中的空格是后代选择器,只需要将空格及其前面的删除及可解决
```python
selenium.common.exceptions.InvalidSelectorException: Message: The given selector pass-text-input pass-text-input-phone is either invalid or does not result in a WebElement. The following error occurred:
InvalidSelectorError: Compound class names not permitted
下面是正确的:
driver.find_element_by_class_name('pass-text-input-phone').send_keys('1234567890')
更多推荐
已为社区贡献1条内容
所有评论(0)