Selenium IDE - Placeholder

Asked

Viewed 1,161 times

-1

I’m having trouble automating a test where I fill a field (placeholder) and save. When consulting what I saved, I see that the information entered in the field was not made.

<input id="nomeCliente" class="form-control ng-pristine ng-valid ng-touched" _ngcontent-c8="" maxlength="150" placeholder="Nome Cliente" type="text" style="background-color: rgb(255, 255, 255);">
  • Fill the field and want to test the value? I don’t understand the placeholder.

  • @Aline That’s right. I want to fill in the field with value. The field is filled in. However, when consulting later, the field does not have the value. Is there any other command than "Type"?

  • Add your code with Selenium for us to see.

  • @Aline I got it with the "Sendkeys" command. However, now I can’t replace one word with another in the field. It is only inserted in front of the already inserted one. Follow the command (this is not a placeholder, but the same thing happens): <tr> <td>Sendkeys</td> <td>xpath=(/input[@type='text'])[10]</td> <td>test</td> </tr> <tr> <td>Sendkeys</td> <td>xpath=(//input[@type='text'])[10]</td> <td>test</td> </tr> On hold! Thank you very much from now.

2 answers

1


Placeholder has nothing to do with the field type, what you need to work with is input, placeholder is just a property of an input, I suggest you read more about it in the following link

Regarding your real problem, it’s the way you’re trying to send information to the field. Whenever you need to enter data into a text field (input) you should use the Sendkeys() method, if you need to clean the data before inserting (so that no values are concatenated) just use the clear command().

driver.findElement(By.id("nomeCliente")).clear();
driver.findElement(By.id("nomeCliente")).sendKeys("Nome Cliente");

1

You may be picking up the wrong field to facilitate , you can pick up this field from the way down:

driver.findElement(By.id("nomeCliente")).sendKeys("Nome Cliente");

in this way you will find the element via ID and pass what you want to fill with the Sendkeys

Browser other questions tagged

You are not signed in. Login or sign up in order to post.