0

I'm trying to use .sendKeys(…) to fill out an input field in a form.

HTML I'm working with:

<tr>
   <td class="multi-line required" style="min-width:120px;">Name:</td>
   <td>
      <div style="position:relative">
         <span style="display:inline-block">
            <input type="text" id="_96a1fa0eccfaf628" size="40" maxlength="64" placeholder="" name="96a1fa0eccfaf628" value="">
         </span>
         <font class="error">*</font>
      </div>
   </td>
</tr>

The code I'm using:

driver.findElement(By.id("_96a1fa0eccfaf628")).sendKeys("Test Org 002");

I have also tried By.name("96a1fa0eccfaf628"), but nope.

The error Im getting: http://pastebin.com/tZ8FSwqx

3
  • 2
    No error message the text input just remains blank? You've double checked that there isn't another element with the same id/name on the page? This isn't in a frame is it? It if were in a frame you would need to switchTo the frame first. Commented Sep 23, 2015 at 20:20
  • 3
    Is this dynamically generated? If so, does the ID get set to the same value every time? Commented Sep 23, 2015 at 20:26
  • 1
    What exception are you getting? If you are not getting any exception then there is another input field with the same id. Commented Sep 23, 2015 at 20:54

3 Answers 3

1

It seems problem with your locator (Id & name both has some dynamic & random values). Try with below locator

By.xpath("//td[contains(text(),'Name')]/following-sibling::td//input[@type='text']")
Sign up to request clarification or add additional context in comments.

Comments

1

I have a similar problem. First click in input element, then clear and finally sendkeys.

driver.findElement(By.XX("your_selector")).click();
driver.findElement(By.XX("your_selector")).clear();

Then write your sendKeys function.

2 Comments

Why find the element more than once? You should scrape it and store it in a variable... then .click(), clear(), and sendKeys().
My point of view ia to tell logic of solution. As you can see, i didn't determine any "By" selector.so, however you write your script, i suggest a click and clear function steps
0

Is the element ID Dynamically named "_96a1fa0eccfaf628" or is this always the name of the ID? If it's dynamically named for example the name changes each session then that may be your issue. If the element is always called "_96a1fa0eccfaf628" then I would try using the "type" command or using a click command to click the field and then do the sendKeys command with a small pause of say 400 ms in between each step and see if that works.

1 Comment

changing the command used to put data into an element won't make a blind bit of difference when the OP is suffering from a NoSuchElementException. The OP either needs to identify the element correctly, or wait for the element to render.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.