I am getting following error
no such element: Unable to locate element: {"method":"xpath","selector":"//input[@placeholder='User ID']"}
(Session info: chrome=78.0.3904.70). Let me know how can i pass user id here
Without additional context, I can only recommend that you wait on the element before sending keys to it:
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
input = WebDriverWait(driver, 30).until(
EC.visibility_of_element_located((By.XPATH, "//input[@placeholder='User ID']")))
input.send_keys("userId")
Full working sample as requested by asker:
from selenium import webdriver
from time import sleep
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
driver = webdriver.Chrome()
driver.get("https://kite.zerodha.com/connect/login?api_key=b8w63qg9m4c3zubd&sess_id=bW3U1OwidO97o11scfeTbyfX4j5tViNp")
input = WebDriverWait(driver, 30).until(
EC.visibility_of_element_located((By.XPATH, "//input[@placeholder='User ID']")))
input.send_keys("userId")
sleep(10) # this sleep is here so you can visually verify the text was sent.
driver.close()
driver.quit()
The above code has succeeded every time I have run it.
WebDriverWait(browser, 30) that should do the trick! good answer.presence_of_element_located to visibility_of_element_located and, as @MosheSlavin has mentioned, increasing the wait time. After looking at your page HTML, there are no other special cases interfering with the element, so the wait.until should be all you need. I've updated my solution with a different wait for you to try.presence_of_element_located to visibility_of_element_located helped.
inputelements located by the XPath -- if you are just usingfind_element, this may cause an issue. Another issue is the element being nested in aniframeelement higher up in the DOM. Without the URL or full HTML for the page you are testing, this problem will be difficult to solve.