[Python] Selenium click menu item

Discussão em 'Python' iniciado por Stack, Fevereiro 22, 2025.

  1. Stack

    Stack Membro Participativo

    Does anyone know how to click a menu item? To reproduce go to this nike link then click join us and enter a random email. You should see the menu. Im tryna have the driver click "Mens". I tried clicking it using Xpath, using a Select, and executing some script. None have worked (I do click the menu first to show the options btw). I'd appreciate some help. Attempted code:

    menu = await driver.find_element(By.XPATH, '//*[@id="l7r-shopping-preference"]', timeout=20)
    select = await Select(menu)
    await select.select_by_value("MENS")


    await driver.execute_script("document.getElementById('l7r-shopping-preference').value = 'MENS';")
    await sendChars(driver, '//*[@id="l7r-shopping-preference"]', "\n")


    [​IMG]

    Continue reading...

Compartilhe esta Página