[Python] python automation, can not click on the search box [closed]

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

  1. Stack

    Stack Membro Participativo

    I would like to write an automaton in python, which enters me into google chrome, and within an already manually opened window it searches for the search function and clicks on it... There could be more, but I'm stuck on this part, because the automaton doesn't get further than loading the web page, it can't find the search function.

    The html codes are correct I think. The suspicious thing is that the "div class" classification of the search function might be confusing, and that's why it doesn't click on it for some reason, because if I give it an element with the "span class" classification, for example, it clicks on it without any problem.

    I attach two pictures of the classifications:

    [​IMG]

    [​IMG]

    I tried a lot of things, ofc asked AI tools, but they were not able to help me. Here is my code, and the website which from I would like to make an automation. The search bar at the top of left corner is not clickable by my automation for some reason...while other buttons can be clicked by the automation.

    https://www.tippmixpro.hu/hu

    from selenium import webdriver
    from selenium.webdriver.common.by import By
    from selenium.webdriver.common.keys import Keys
    import time


    options = webdriver.ChromeOptions()
    options.add_experimental_option("debuggerAddress", "127.0.0.1:9222")
    driver = webdriver.Chrome(options=options)


    driver.get("https://www.tippmixpro.hu")


    time.sleep(6)


    try:
    search_icon = driver.find_element(By.CLASS_NAME,"SimpleSearchTrigger")
    search_icon.click() # Kattintás a kereső ikonra
    print("✅ Sikeresen rákattintottunk a kereső ikonra!")
    except Exception as e:
    print("❌ Nem sikerült rákattintani a kereső ikonra:", e)


    time.sleep(4)


    try:
    search_box = driver.find_element(By.XPATH, '//input[@placeholder="Keresés"]') # Keresőmező megtalálása
    search_box.click()
    search_box.send_keys("sportfogadás") # Példa keresési kifejezés
    search_box.send_keys(Keys.RETURN)
    print("✅ Beírtuk a keresési szót és elküldtük a keresést!")
    except Exception as e:
    print("❌ Hiba a keresőmezőbe való beíráskor:", e)


    time.sleep(5)

    Continue reading...

Compartilhe esta Página