Selenium python find_element_by_class_name() stopped working from v 2.2 to 2.21 — cannot use 'Compound Class Name'

后端 未结 4 936
轻奢々
轻奢々 2020-12-09 12:00

I am using Selenium\'s python library to scrape data from a html page in Firefox.

I have had to update from Selenium 2.0 to 2.21 because the server has updated Firef

4条回答
  •  余生分开走
    2020-12-09 12:35

    You need to use a CssSelector in the format ".nameA.nameB.nameC" you can have as many as you'd like, just add the "."

    Alternatively you can match the whole attribute (you can also do this with xpath): "[class='exact class name here']" XPath - "//[@class='exact class name here']"

    There are ways to do starts with or ends with or contains too (in both CSS and xpath) which helps if the classes are generated dynamically.

提交回复
热议问题