[Python] Python Seleium - ActionChains don't enter input as expected

Discussão em 'Python' iniciado por Stack, Abril 11, 2025.

  1. Stack

    Stack Membro Participativo

    I try to enter two different input fields. It only enters the input for "Your Name" and not the email.

    enter image description here

    Here is the Code:

    url = "http://automationpractice.com/"
    start_page = StartPage(chrome_browser)
    start_page.open_page(url)
    start_page.select_image(chrome_browser)

    home_page = HomePage(chrome_browser)
    home_page.select_chat_with_sales(chrome_browser)

    chrome_browser.switch_to.window(chrome_browser.window_handles[1])
    chrome_browser.implicitly_wait(10)



    email_input = chrome_browser.find_element(By.ID, "customer-email")
    email_input.click()
    email_input.send_keys("test@gmail.com")
    ActionChains(chrome_browser) \
    .key_down(Keys.SHIFT) \
    .send_keys("test@gmail.com") \
    .perform()
    chrome_browser.implicitly_wait(5)
    your_name = chrome_browser.find_element(By.ID, "customer-name")
    your_name.click()

    ActionChains(chrome_browser) \
    .key_down(Keys.SHIFT) \
    .send_keys("Test Testsson") \
    .perform()

    chrome_browser.implicitly_wait(5)

    chat_with_us = chrome_browser.find_element(By.XPATH, "//*[contains(text(), 'Chat with us')]")
    assert chat_with_us == "Chat with us"


    I have tried to change the order of the ActionChains so it will enter the email and then Your name

    The results is only Email input field get the "Email Adress" and then write over by "your name"

    email_input = chrome_browser.find_element(By.ID, "customer-email")
    email_input.click()
    email_input.send_keys("test@gmail.com")
    ActionChains(chrome_browser) \
    .key_down(Keys.SHIFT) \
    .send_keys("test@gmail.com") \
    .perform()
    chrome_browser.implicitly_wait(5)
    your_name = chrome_browser.find_element(By.ID, "customer-name")
    your_name.click()

    ActionChains(chrome_browser) \
    .key_down(Keys.SHIFT) \
    .send_keys("Test Testsson") \
    .perform()


    enter image description here


    I want to have Your Name "Test Testsson"

    Email Adress test@gmail.com
    ​

    Continue reading...

Compartilhe esta Página