问题:
源代码:
问题原因:
在html中class内容里面可以多类名,以空格间隔,减少css代码的重复性,提高类的重用性
在selenium中by.class_name的语法是:不能有空格,多个类名的时候,选其中一个类名就能找到。
解决办法:
1.选择多各类名的其中一个去寻找
login_btn = driver.find_element_by_class_name('box-header')
2.使用css_selector方法,在每个类名前面加“.”
login_btn = driver.find_element_by_css_selector('.box-header.user-header')
好啦,完结撒花!