mercredi 5 septembre 2018

How can I update my list if Selenium Elements are changed?

i am really stuck in this problem. I have an method which check if the move changed by length. My problem is that lichess automatically insert a empty String to the ending of the list.

I am trying to do an update of value changes but I reallly dont know how I should do it.

def get_data_from_game(driver):
# 0 = white
# 1 = black
colors = []

# Updated if Move gets an new element
moves = []
move_index = 0


status_elem_exist = check_exists_by_xpath('//*[@id="site_header"]/div[2]/div/div/div[3]',driver)
while not status_elem_exist:

    moves_elem = driver.find_elements_by_tag_name("move")

    moves = []

    if move_index != len(moves_elem):
        for move in moves_elem:

            moves.append(move.text)

        print(moves)



    status_elem_exist = check_exists_by_xpath('//*[@id="site_header"]/div[2]/div/div/div[3]', driver)
    move_index = len(moves_elem)

I know why he is doing it but I dont know how I could fix it. That is what I get printed but my opponent played Bc5 which is not detected.

['e4','e6','f3','']

Hopefully you guys can help me.

Best Regards Cren

Aucun commentaire:

Enregistrer un commentaire