python查找时,不支持compound class
2015-12-29 16:39 sophia194910 阅读(440) 评论(0) 编辑 收藏 举报1.python使用如下代码查找页面上的元素时,
browser.findElement_by_class_name("widget-content nopadding")
报错:
selenium.common.exceptions.WebDriverException: Message: u'Compound class names not permitted'
python不支持类名中间带有空格,上述类名会被当做2个处理,因此会报错。
2.解决方法如下:
browser.find_element_by_css_selector(".widget-content.nopadding")
改用css selector来进行查找即可。
我所喜欢的生活,在混沌中顿悟,和喜欢的一切在一起。