[Python] Selecting and inputting text in an element by using selenium

Discussão em 'Python' iniciado por Stack, Setembro 28, 2024.

  1. Stack

    Stack Membro Participativo

    I'm trying to automate zoom joining process using selenium.

    Screenshot of the element

    Here's the HTML code for the input element:

    <input id="input-for-name" type="text" class="preview-meeting-info-field-input"
    autocomplete="off" required="" aria-invalid="false" aria-describedby="error-for-name"
    value="">


    It's mandatory to input name there in order to proceed further.

    I can't select and input my name on the above element. I tried by using XPATH

    //*[@id="input-for-name"]


    I've also tried CSS SELECTOR and nothing worked. It gives an error that the xpath id was not found in the given time frame. (I already increased time frame till 1 min, It didn't work).

    My code:

    from selenium import webdriver
    from selenium.webdriver.edge.service import Service
    from selenium.common.exceptions import NoSuchElementException
    from selenium.webdriver.common.keys import Keys
    from selenium.webdriver.common.by import By
    from selenium.webdriver.support.ui import WebDriverWait
    from selenium.webdriver.support import expected_conditions as EC


    service = Service("msedgedriver.exe")
    driver = webdriver.Edge(service=service)

    try:
    driver.get("https://app.zoom.us xxxxxx")

    wait = WebDriverWait(driver, 10)
    name_field = wait.until(EC.visibility_of_element_located((By.ID, "input-for-name")))

    name_field.click()
    name_field.send_keys("ENTER NAME HERE")

    except NoSuchElementException:
    print("Name input field not found. Website may have changed structure.")
    finally:
    driver.quit()

    Continue reading...

Compartilhe esta Página