selenium定位元素报错——AttributeError: ‘WebDriver’ object has no attribute ‘find_elements_by_class_name’

报错:

selenium定位元素报错——AttributeError: ‘WebDriver’ object has no attribute ‘find_elements_by_class_name’_第1张图片

查看find_elements的源码(发现是源码改了):

之前的写法:

selenium定位元素报错——AttributeError: ‘WebDriver’ object has no attribute ‘find_elements_by_class_name’_第2张图片 现在:

selenium定位元素报错——AttributeError: ‘WebDriver’ object has no attribute ‘find_elements_by_class_name’_第3张图片

记住加一句:

from selenium.webdriver.common.by import By

运行成功!

selenium定位元素报错——AttributeError: ‘WebDriver’ object has no attribute ‘find_elements_by_class_name’_第4张图片

你可能感兴趣的:(解决的bug,selenium,测试工具)