Reputation: 13
I want to enter a value into a field
I find the element by:
driver.find_element_by_xpath('//*[@id="cell--gE-Ez1qtyIA"]')
And I do this to display the text and click:
driver.find_element_by_xpath('//*[@id="cell--gE-Ez1qtyIA"]').click()
driver.find_element_by_xpath('//*[@id="cell--gE-Ez1qtyIA"]').text
So far so good, but I use this code when I want to send a value to this field:
driver.find_element_by_xpath('//*[@id="cell--gE-Ez1qtyIA"]').send_keys('test')
Nothing happens and the field value does not change
Upvotes: 0
Views: 630
Reputation: 41
Try to use javascriptexecutor
instead of sendkeys
WebDriver driver = new ChromeDriver();
JavascriptExecutor je = (JavascriptExecutor)driver;
je.executeScript("document.getElementById('IDofElement').setAttribute('value', 'your value here')");
Upvotes: 0
Reputation: 127
Since we are unaware about the nature of the text box you are trying to access, there are some possibilities because of which you are facing this situation. The send_keys()
works on all the text box which ever you use. Look for the points below and try applying it on the element:
A sample code can be using explicit wait:
wait = WebDriverWait(driver, 10)
element = wait.until(EC.presence_of_all_elements_located(("xpath", "//*[@id='cell--gE-Ez1qtyIA']")))
element.send_keys("test")
Upvotes: 1