1

I use the following code using eclipse to initialize a form

WebElement e1 = KD.findElement(By.name("name"));
e1.sendKeys("Srajan ");

But in the form the first character 'S' does not get displayed. It starts from 'r' only. Is the issue be in the coding or the website?

Weather Vane
  • 33,872
  • 7
  • 36
  • 56
Rajan.M
  • 15
  • 4

3 Answers3

1

Looking at the test code and without knowing about the page source, I think it is a character limit issue. Check if that field has a character limit and trimming the initial S

Also, try using clear() before sending new ones if not the character limit issue

WebElement e1 = KD.findElement(By.name("name"));
e1.clear();
e1.sendKeys("Srajan");
Saifur
  • 16,081
  • 6
  • 49
  • 73
0

One more way to solve this by putting a sleep duration before typing, I fixed this in my project like:

WebElement e1 = KD.findElement(By.name("name"));
Thread.sleep(1000);
e1.sendKeys("Srajan");
Thread.sleep(500);

This should work, you may not need Thread.sleep(500);

phts
  • 3,889
  • 1
  • 19
  • 31
Pankaj Kumar Katiyar
  • 1,474
  • 1
  • 20
  • 36
0

Yeah it happens sometimes , because the element is not loaded yet. You can try to use wait for that element

WebDriverWait wait = new WebDriverWait(driver, 20); 
      wait.until(ExpectedConditions.presenceOfElementLocated(By.name("name")));

You can also try Thread.sleep(500) but its not recommended. And its also a good practice to use clear() method before sending some input.

Juhi Saxena
  • 1,197
  • 11
  • 17