Home > database >  ElementNotInteractableException while using selenium and python
ElementNotInteractableException while using selenium and python

Time:10-08

I am trying to automate login to a website (http://www.primecbdatabase.com/). It's source code is as follows

<p><label for="username">User ID</label> <input type="text" name="user_id" value=""   onchange="javascript:replcodeid()"; size="6" maxlength="50"></p>
<p><label for="Password">Password</label><input type="password" name="password" id="password" value=""   size="6" onkeypress="return SplChar1(event);"  onchange="javascript:replcodepwd()" maxlength="16" ></p>
<p class="btn" style="margin-bottom:0;"><a onm ouseover="self.status='PRIME Database';return true" href="javascript:submit1()"><img src="images_NSE/login-btn1.png"></a></p>
<p class="password"><a href="forgotpr.asp" class="lightbox forget" rel="content-page">Forgot Password?</a></p>

It works correctly when dealing with the username input as shown below

inputElement = driver.find_element_by_name('user_id')
inputElement.send_keys(username)

But when I am trying to do the same for password (as shown below) it throws the ElementNotInteractableException. Looks like I am having trouble with send_keys to transfer the password to the input box.

inputElement = driver.find_element_by_name('password')
inputElement.send_keys(password)

I tried changing find_element_by_name to find_element_by_id, it still doesn't work. Kindly help me with it.

CodePudding user response:

You need to click on the textbox before type.

driver.find_element_by_id("password").click()
driver.find_element_by_id("password").send_keys("123")

I have tried and am able to type a password using a script.

  • Related