How to send keys to a form with no id and or name in selenium (Python)

selenium send_keys python
selenium webelement python
how to enter text without using sendkeys() in selenium
selenium submit form
selenium input text value
selenium set value of input field
selenium click button
how to enter value in textbox using selenium webdriver

i am working on getting data from a website and any time i click on a link to get phone number, a modal form is opened to ask for my phone number first and the phone number is shown to me.

The challenge i have now is, i want to send keys to the input field, so because the input field has no name or id, i located the input field using xpath:

xxx = driver.find_element_by_xpath("//input[@placeholder='081xxxxxxxx']")

I printed this and it returned some selenium objects, but when i try sending keys like:


Here is a snippet of the html code:

<div class="row">
<div class="medium-12 columns">
    <div class="guest-text">
        One step closer! <br />
        <span>Please provide your contact number to view business contact details</span>

    <form action="" data-abide="ajax" novalidate="novalidate">
        <div id="txtUserPhoneNumber" ng-show="!isLoggedIn && collectUserPhone == ''" class="guest-no">
                <div class="guest-label">Phone Number</div>
                <input type="text" placeholder="081xxxxxxxx" ng-model="UserPhoneNew" required data-invalid="" aria-invalid="true" maxlength="11">


I have tried:

xxx = driver.find_element_by_xpath("//input[@placeholder='081xxxxxxxx']")

dummy_number = driver.find_element_by_xpath("//div[contains(@class, 'modal small guest')]/div[contains(@class, 'guest-modal-wrapper')]//form[1]//input[1]")

I got error saying:

Traceback (most recent call last):
File "Dropbox/automation/", line 76, in <module>
  File "Dropbox/automation/", line 61, in instantiatechrome
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/", line 479, in send_keys
    'value': keys_to_typing(value)})
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/", line 628, in _execute
    return self._parent.execute(command, params)
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/", line 312, in execute
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/", line 237, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.ElementNotVisibleException: Message: element not visible
  (Session info: chrome=66.0.3359.139)
  (Driver info: chromedriver=2.35.528139 (47ead77cb35ad2a9a83248b292151462a66cd881),platform=Linux 4.13.0-39-generic x86_64)

Your opinion is welcomed.

The error messgae says the element is not visible. So you have to explicitly wait until it becomes visible. Use an ExpectedCondition as described here.

In the end your code might look like this (waiting up to 120 seconds):

from import expected_conditions as EC


wait = WebDriverWait(driver, 120)
element = wait.until(EC.visibility_of_element_located((By.XPATH, "//input[@placeholder='081xxxxxxxx']")))

Send keys not working selenium webdriver python, Send keys not working selenium webdriver python <textarea id="​manage_description" class="eTextArea" name="e.description" cols=""  Hence these is No Functional or Operational difference while working with either sendKeys(Keys.ENTER); or WebElement.sendKeys(Keys.RETURN); through Selenium. Enter Key and Return Key : On computer keyboards, the Enter (or the Return on Mac OSX) in most cases causes a command line, window form, or dialog box to operate its default function.

About the error, you need to wait the element be displayed and enabled to interact with. You can learn it reading about "Implicity and Explicity waits in Selenium".

Here you can find some extra info abot that:

Also an extra tip.

Generally we use XPath just whena element is very hard, or even impossible to find with a ID or a CssSelector. It is because XPath is not common as CssSelector and it harder to understand depending how it is written.

When we need to find some element using XPath or CssSelector, first of all we need to check what values will not change after a interaction with the page, and also what provide us a unique value (when we need only one element, ofc).

Since your html has only one element with id txtUserPhoneNumber, and your desired element is inside it, let's start selecting it. After, look the tag name of the wanted element. There is only one input element inside it? Nice! So we can reach the element using only these few infos.


#txtUserPhoneNumber input



//*[@id='txtUserPhoneNumber ']//input

Selenium Form WebElement: TextBox, Submit Button, sendkeys , The method findElement() takes one parameter which is a locator to the element. Different locators like,, By.xpath(), By. In that file it has the account name, account ID, and address. I have to put that in manually for each new account. Selenium can fix that. Let’s start with something simple and automate logging into Instagram. Logging into any site is basically a small form that we send over.

3. Navigating, <input type="text" name="passwd" id="passwd-id" /> you hit your IDE's auto-​complete key combination, not all of them will make sense or be valid. If you call this on an element within a form, WebDriver will walk up the DOM until it finds the  Submit Buttons. Submit buttons are used to submit the entire form to the server. We can either use the click () method on the web element like a normal button as we have done above or use the submit () method on any web element in the form or on the submit button itself.

SendKeys in Selenium WebDriver, Selenium sendkeys help QAs automate test cases for form that can be identified using locators like element id, name, class name, etc. Besides teams do not need to worry about maintaining any on-site device labs. One can uniquely identify the name field by using ID user_full_name. Add these lines after username = browser.find_element_by_id('user_full_name') username.send_keys('John Doe') The user should be able to see the name in the first field of the signup page.

Selenium - sendKeys() not inserting value into textbox, popular browser automation tools. It is not dependent on a particular programming language and supports Java, Python, C#, Ruby, PHP, Perl, etc. We can use the HTML attributes of an element like id , class , and name to locate an element. If there are no such attributes newsletterEmail.sendkeys("billy@​");  The following are code examples for showing how to use selenium.webdriver.common.keys.Keys.RETURN().They are from open source Python projects. You can vote up the examples you like or vote down the ones you don't like.

Web Browser Automation with Selenium and Java, Using multiple sendkeys to a particular field, selenium appends all of the text one by one findElement(By.xpath("//input[@id='textbar']")).clear(); //send text to the same CharSequence csString2 = "com"; // send the string to search bar without Sendkeys method will add all the strings by iterating them and forms into one  Some sample codes for using selenium in Python just for fun. - BaseMax/FirstSelenium

  • Share the relevant HTML and your code trials
  • I have edited the question and added the HTML code
  • Are you sure the value for placeholder is stable? Looks a bit like a generated value. And what is the exact error type and message?
  • the placeholder does not change, and i have added the exact error type @Würgspaß
  • This really helped...Thanks
  • @molecules Nice to hear. The Stackoverflow way of marking helpful answers is to upvote and/or accept the answer using the arrow at the left.
  • This is really helpful...Thanks