I am having trouble selecting and entering a number into the input text box of this form. I have used both ActionChains and standard webdriver commands to try this, but still no success. This is my current code:
input_box = ActionChains(driver)
input_box.move_to_element(driver.find_element(By.XPATH, '//input[@id="outlined-error-text"]')).click()
input_box.sendkeys(input_number)
input_box.perform()
The error text displays, instead of entering the value.
This is the snippet of HTML page. I condensed the classes and such.
<form class="box css1" novalidate="" autocomplete="off">
<div>
<div class="FormControl TextField css2">
<div class="InputBase marginDense">
::before
<input aria-invalid="false" id="outlined-error-text" type="text" class="inputBase marginDense" value="">
::after
</div>
</div>
</div>
</form>
I have tried selecting the div's before it, but still no success. I have no errors, so that tells me that Selenium is able to find the input box, and the text popping up tells me that it is sending the keys. Is there something I'm missing to be able to enter the text into the input box? What else can I do?
I am using Selenium 4.15.2, Python 3.11
Answering my own question. The website I was working in REQUIRES you to select an option from a drop down menu, before this step. I was properly filling in the text of the menu, but I needed to press ENTER for some AJAX to allow input in the textbox. When I finally realized this, I just had to complete the code with input_box.send_keys(Keys.RETURN)
and then perform()
the operations.
There was nothing wrong with my code at all.