Answer the question
In order to leave comments, you need to log in
How to compare with child element class?
Hello, there is a rublix.best site, and in the Wheel section (prnt.sc/ueuzz3). There is a column with the history of games (the latter is added to the top). It is necessary for me that depending on what color of the last game, this or that value is displayed in the console, for example, if it is gray, then the print ('GREY') function is executed. I tried to find the entire list by find_element_by_xpath, then assigned it to the all_games variable, and then tried to do it by the class of the child div.
from selenium import webdriver
driver = webdriver.Chrome()
driver.get("https://rublix.best/")
time.sleep(35)
wheel = driver.find_element_by_xpath("/html/body/div[1]/div[1]/nav/ul[1]/li[2]/a").click()
while True:
all_games = driver.find_elements_by_xpath("/html/body/div[1]/div[2]/div[6]/div[1]/div[3]/div")
if all_games[0].find_element_by_class_name('lggr'):
print('GREEN')
if all_games[0].find_element_by_class_name('lgg'):
print('GREY')
if all_games[0].find_element_by_class_name('lgb'):
print('BLUE')
if all_games[0].find_element_by_class_name('lgr'):
print('RED')
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question