search_input = WebDriverWait(driv" /> search_input = WebDriverWait(driv" /> search_input = WebDriverWait(driv"/>

How Can I send_keys to this search input field. Getting TimeOut Exception

36 Views Asked by At

Error:

Traceback (most recent call last):
  File "c:\Users\rana\OneDrive - \Desktop\auto\new.py", line 49, in <module>
    search_input = WebDriverWait(driver,20).until(EC.element_to_be_clickable((By.XPATH, '/html/body/div[2]/div/div/div/div[2]/div[2]/div/div[1]/div[1]/div[1]/div[2]/input')))
  File "C:\Users\rana\AppData\Local\Programs\Python\Python310\lib\site-packages\selenium\webdriver\support\wait.py", line 95, in until
    raise TimeoutException(message, screen, stacktrace)
selenium.common.exceptions.TimeoutException: Message:
Stacktrace:
        GetHandleVerifier [0x006137C3+48947]
        (No symbol) [0x005A8551]
        (No symbol) [0x004AC92D]
        (No symbol) [0x004D9E38]
        (No symbol) [0x004D9EFB]
        (No symbol) [0x00508EF2]
        (No symbol) [0x004F50D4]
        (No symbol) [0x005075DA]
        (No symbol) [0x004F4E86]
        (No symbol) [0x004D16C7]
        (No symbol) [0x004D284D]
        GetHandleVerifier [0x0085FDF9+2458985]
        GetHandleVerifier [0x008A744F+2751423]
        GetHandleVerifier [0x008A1361+2726609]
        GetHandleVerifier [0x00690680+560624]
        (No symbol) [0x005B238C]
        (No symbol) [0x005AE268]
        (No symbol) [0x005AE392]
        (No symbol) [0x005A10B7]
        BaseThreadInitThunk [0x762400C9+25]
        RtlGetAppContainerNamedObjectPath [0x77157B1E+286]
        RtlGetAppContainerNamedObjectPath [0x77157AEE+238]

CODE:

from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.action_chains import ActionChains

from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
import time

options = Options()
options.add_experimental_option("detach",True)
driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()),
options=options)


driver.maximize_window()
driver.get('https://10.225.244.12/mito/webpage/mito/home#no-back-button')

actions = ActionChains(driver)
WebDriverWait(driver,10).until(EC.element_to_be_clickable((By.ID,'details-button'))).click()
driver.find_element(By.ID,'proceed-link').click()
if driver.title == "MITO":
    WebDriverWait(driver,10).until(EC.presence_of_element_located((By.CSS_SELECTOR, 'div.modal-body')))
    js = 'return document.querySelector("div[class=modal-body]").textContent.includes("Session Expired")'
    if driver.execute_script(js):
        print('success')
        WebDriverWait(driver,10).until(EC.element_to_be_clickable((By.XPATH,'/html/body/div[3]/div/div/div[2]/button'))).click()
    else:
        print("session expired message not found")
    username = WebDriverWait(driver,10).until(EC.presence_of_element_located((By.ID, 'username')))
    passwd = WebDriverWait(driver,10).until(EC.presence_of_element_located((By.ID, 'password')))
    loginBtn = WebDriverWait(driver,10).until(EC.presence_of_element_located((By.ID, 'btnLogin')))
    time.sleep(3)
    username.send_keys("username")
    passwd.send_keys("password")
    loginBtn.click()
    WebDriverWait(driver,10).until(EC.presence_of_element_located((By.CSS_SELECTOR, '#tree > ul > li:nth-child(9)'))).click()
    WebDriverWait(driver,10).until(EC.presence_of_element_located((By.CSS_SELECTOR, '#tree > ul > li:nth-child(14)'))).click()
  
    driver.implicitly_wait(10)
 
        
    WebDriverWait(driver,10).until(EC.presence_of_element_located((By.CSS_SELECTOR, '#tree > ul > li:nth-child(9)')))
    WebDriverWait(driver,10).until(EC.presence_of_element_located((By.CSS_SELECTOR, '#tree > ul > li:nth-child(14)')))
    time.sleep(10)
    search_input = WebDriverWait(driver,20).until(EC.element_to_be_clickable((By.XPATH, '/html/body/div[2]/div/div/div/div[2]/div[2]/div/div[1]/div[1]/div[1]/div[2]/input')))

    driver.execute_script("arguments[0].scrollIntoView().click();", search_input)
    print(f"Element  found, attempting to send keys {search_input}")
    search_input.send_keys("hello")
        
    
print("End of script")


I am expecting the code to send text to search input field field . But it gives me a timeout exception. I tried multiple times but still not working.I searched by using CSS_SELECTOR, XPATH,TAGNAME.I find it strange that when i move to the page where that input field is console return null when i tried to find the element on console: Before clicking on the input field using select element of browser enter image description here But after inspecting the element manually and clicking on it, the browser console gives the exact element. After clicking on the input field using select element of browser : enter image description here enter image description here

0

There are 0 best solutions below