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
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.
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']")
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.