'Unable to Locate Textbox Element using selenium
I am having trouble to send text to textbox present in the given image as I have tried by passing the xpath of that textbox but its generates an error mentioned below. Anyone that can help me out of that.
from selenium import webdriver
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.keys import Keys
import time
path=r"path to your chrome driver.exe"
driver = webdriver.Chrome(path)
driver.get("https://www4.sii.cl/mapasui/internet/#/contenido/index.html")
try:
element = WebDriverWait(driver, 1000).until(
EC.presence_of_element_located((By.XPATH, '//*[@id="ng-app"]/body/div[5]/div/div/div[3]/div/button'))
)
element.click()
print("prints its working fine now ..")
element = WebDriverWait(driver, 1000).until(
EC.presence_of_element_located((By.XPATH,'//*[@id="titulo"]/div[8]/i'))
)
element.click()
search = driver.find_element_by_xpath('//*[@id="rolsearch"]/div[2]/div[1]/input').click()
search.send_keys("somehting in text")
search.send_keys(Keys.RETURN)
time.sleep(3)
search_1 = driver.find_element_by_xpath('//*[@id="rolsearch"]/div[2]/div[2]/input')
search_1.send_keys("somehting in text")
search_1.send_keys(Keys.RETURN)
search_2 = driver.find_element_by_xpath('//*[@id="rolsearch"]/div[2]/div[3]/input')
search_2.send_keys("somehting in text")
search_2.send_keys(Keys.RETURN)
print("Its also working now ......")
time.sleep(3)
except Exception as e:
print(e)
driver.quit()
Solution 1:[1]
For the Comuna input, there are some rules, since it has autocomplete functionality.
1 You have to define some specific value, which present in the list.
Some random text will not work!
2 You have to confirm the input with Keys.ENTER(Keys.RETURN on Mac).
# explicit wait for visibility (max timeout - 60 seconds)
search = WebDriverWait(driver, 60).until(
EC.visibility_of_element_located((By.XPATH, '//*[@id="rolsearch"]/div[2]/div[1]/input'))
)
search.send_keys("EL MONTE" + Keys.ENTER)
time.sleep(3)
search_1 = driver.find_element_by_xpath('//*[@id="rolsearch"]/div[2]/div[2]/input')
search_1.send_keys("somehting in text")
search_2 = driver.find_element_by_xpath('//*[@id="rolsearch"]/div[2]/div[3]/input')
search_2.send_keys("somehting in text")
print("Its also working now ......")
time.sleep(3)
For other inputs, any text will be applied with send_keys without extra actions.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |


