在Selenium中,通过类名查找元素的语法是什么?请注意,我已经使用了以下语法:
并且它给我以下错误信息:
但是上述语法对于ID和NAME完美地工作:
有什么想法可以用什么正确的语法来按类搜索?
link_elements = driver.find_elements_by_class_name("BM30N")
并且它给我以下错误信息:
C:\Users\David\Desktop\Selenium\Crawl.py:17: DeprecationWarning: find_elements_by_class_name is deprecated. Please use find_elements(by=By.CLASS_NAME, value=name) instead
link_elements = driver.find_elements_by_class_name("BM30N")
当我使用:
link_elements=driver.find_elements(By.CLASS,'BM30N')
I get:
AttributeError: type object 'By' has no attribute 'CLASS'
但是上述语法对于ID和NAME完美地工作:
link_elements=driver.find_elements(By.NAME,'product-item')
link_elements=driver.find_elements(By.ID,'product-item')
有什么想法可以用什么正确的语法来按类搜索?