Reputation: 49
I am trying to pass some content in the textbox using the following:
driver.find_element_by_xpath('path').send_keys(value)
Apparently nothing is getting passes. Similar issue with clicking button:
driver.find_element_by_xpath('path').click()
This is also not working, in the code i could see
display:none:
<li style="display:none">
</li>
</ul></div>
<div class="row form-group">
<div class="col-sm-12 form-group">
<label for="Username">Username</label>
<input autocomplete="off" class="form-control" data-val="true" data-val-
required="User name is Required" id="Username" name="Username" type="text" value="">
Upvotes: 1
Views: 844
Reputation: 31
I was having a similar issue not to long ago, try this:
js= "document.getElementById('Username').value = '" + str(YOURVALUE) + "';"
driver.execute_script(js)
It worked for me, hope this helps.
Upvotes: 0
Reputation: 91
Use explicit wait statement before you use sendkeys or click. As per my understanding element is not visible while click or sendkeys.
For your reference visit Explicit and Implicit Wait Docs
Upvotes: 0
Reputation: 193108
As per the HTML you have shared and @Sighil pointed out the style attribute display: none is part of the previous <li>
tag which must not affect the Username field. To pass some text to the Username field you can use the following line of code :
driver.find_element_by_xpath("//input[@class='form-control' and @id='Username']").send_keys("Dimple Mathew")
It may be possible you have to induce a waiter for the Username field to be interactable and in that case you have to induce WebDriverWait as follows :
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//input[@class='form-control' and @id='Username']"))).send_keys("Dimple Mathew")
Upvotes: 1