[Python] Can you perform WebDriverWait in an ActionChain?

Discussão em 'Python' iniciado por Stack, Março 6, 2025.

  1. Stack

    Stack Membro Participativo

    I often build ActionChains to interact with MUI components. Here is one that enters the date MM/DD/YYYY but ensures we start typing in the MM portion of the input. I have to wait for the animation of the field label to move out of the way before the input will accept anything.

    actions = ActionChains(driver, duration=CHAIN_DURATION)
    actions.move_to_element(element)
    actions.click(element)
    actions.pause(.25) # animation of label to move out of the way.
    actions.send_keys(Keys.ARROW_LEFT)
    actions.send_keys(Keys.ARROW_LEFT)
    actions.send_keys(date_str)
    actions.send_keys(Keys.TAB)
    actions.perform()


    [​IMG]

    The problem is this animation speed is variable (and it's not always known how fast each component will be). What I wish I had was the ability to perform a WebDriverWait.until(expected_condition) in the middle of the ActionChain. In this case I would wait until the label element (different from the input element) has stopped moving. Is this possible in some way?

    Continue reading...

Compartilhe esta Página