[Python] Selenium Python - sending keys from an array to a different array starting from index...

Discussão em 'Python' iniciado por Stack, Julho 24, 2025.

  1. Stack

    Stack Membro Participativo

    I'm doing some UI testing and ran into an issue

    All of the headers are just plain text and the textboxes are elements with a placeholder to send keys in. The only way to locate them is by CLASS_NAME so I can not distinguish from the subject and desc which I have no interest in to the picks, therefore, I need to create an array based on the CLASSNAME all 5 textboxes have in common and insert the values as written below.

    Voting subject

    -------textbox1-------

    Voting description

    ----textbox2-----

    VotingPick1

    -----textbox3----

    VotingPick2

    -----------textbox4---------

    VotingPick3

    -----textbox5----

    Example:

    emptyOptions = ['textbox1', 'textbox2', 'textbox3', 'textbox4', 'textbox5']

    votingOptions = ['YES', 'NO', 'IDK' ]
    i wish to start the emptyOptions array from index 2 so textbox3 will get YES
    textbox4 will get NO and textbot5 will get IDK



    ```
    for option in votingOptions:
    emptyOptions = driver.find_elements(By.CLASS_NAME, 'formCTRL')
    i = 10
    for o in emptyOptions:
    o.send_keys(option)
    i += 1

    i += 1


    this isn't the full code I've tried. I messed it up and some parts are missing but I don't think even then it would make this work.

    Continue reading...

Compartilhe esta Página