1

Hi i am trying to send input value using the sendkey command however it isn't changing.

HTML:

<div class="SimpleAutocomplete_autocompleteContent AutocompleteOverrides_autocompleteContent SimpleAutocomplete_opened AutocompleteOverrides_opened"><div class="SimpleAutocomplete_selectedWords AutocompleteOverrides_selectedWords"><input placeholder="" required="" value=""></div></div>

I have tried:

text = WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//div[@class='SimpleAutocomplete_autocompleteContent AutocompleteOverrides_autocompleteContent']"))).sendkeys("aa")

and

text = driver.find_element_by_id("placeholder").send_keys("aa")

all failed

snippets of the screen :

enter image description here

enter image description here

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
Djinn
  • 23
  • 2
  • Target the input and not the div. – Arundeep Chohan Nov 18 '20 at 01:21
  • care to elaborate. on that? i have tried : #text = driver.find_element_by_id("placeholder").send_keys("aa") text = WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//input[@value='']"))).sendKeys("value", "aa") and other abbreviations – Djinn Nov 18 '20 at 07:54

2 Answers2

0

Target the input tag and not the div.

WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "div.SimpleAutocomplete_selectedWords.AutocompleteOverrides_selectedWords>input"))).sendKeys("aaa")
Arundeep Chohan
  • 9,779
  • 5
  • 15
  • 32
0

You don't change the value of placeholder, rather you send a character sequence to the <input> tag which replaces the placeholder text.

To send a character sequence to the element you have to induce WebDriverWait for the element_to_be_clickable() and you can use either of the following Locator Strategies:

  • Using CSS_SELECTOR:

    WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "div.SimpleAutocomplete_autocompleteContent.AutocompleteOverrides_autocompleteContent.SimpleAutocomplete_opened.AutocompleteOverrides_opened > div.SimpleAutocomplete_selectedWords.AutocompleteOverrides_selectedWords > input"))).send_keys("Djinn")
    
  • Using XPATH:

    WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//div[@class='SimpleAutocomplete_autocompleteContent AutocompleteOverrides_autocompleteContent SimpleAutocomplete_opened AutocompleteOverrides_opened']/div[@class='SimpleAutocomplete_selectedWords AutocompleteOverrides_selectedWords']/input"))).send_keys("Djinn")
    
  • Note: You have to add the following imports :

    from selenium.webdriver.support.ui import WebDriverWait
    from selenium.webdriver.common.by import By
    from selenium.webdriver.support import expected_conditions as EC
    
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352