1

I am building a selenium Bot to automatically play the game cookie clicker

And I am trying to access the buildings list since the buildings in this game get unlocked as I play and I want to make the computer is aware of the state of the buildings so that when it is about to buy a building it should start checking even the newly unlocked buildings and the way the game updates the buildings is by changing the class names from "product locked disabled" to "product unlocked disabled",

so I want to count how many classes have the unlocked name in them but the problem is the inner HTML of the div's are empty so when I use the find_elements_by_class_name() it returns an empty list, so is the way I can count the div's with a specific class name

Pranav Choudhary
  • 2,726
  • 3
  • 18
  • 38

1 Answers1

0

In selenium find_elements_by_class_name accepts only one class name, whereas your desired div has 3 - product, locked/unlocked, and disabled. You should consider using CSS selectors (or XPATHs) for this.

To find a div with the classes-

  • product
  • locked
  • disabled using CSS selectors, you should use-
driver.find_elements_by_css_selector('div.product.locked.disabled')

To find a div with the classes-

  • product
  • unlocked
  • disabled using CSS selectors, you should use-
driver.find_elements_by_css_selector('div.product.unlocked.disabled')
Chase
  • 5,315
  • 2
  • 15
  • 41