0

I'm currently having to venture into Selenium due to a project. I'm supposed to load a page automatically, log in, click and then fill in a table.

Everything works until I fill out the table. My Code:

public void inputGross(String gross){
inputGross.sendKeys(Keys.DELETE, gros);

The problem is that the input field already contains the amount "0.00 €". With the Clear command, the field empties, but since it first leaves the cell and then enters again, the default value "0.00 €" is created again.

What I have already tried:

inputGross.clear()
inputGross.sendKeys(gross)

inputGriss.sendKeys(Keys.chord(Keyes.CONTROLL, "a"), Keys.DELETE, gross));

inputGriss.sendKeys(Keys.chord(Keys.CONTROLL, "a"), Keys.DELETE, gross, Keys.RETURN));

inputGriss.sendKeys(Keys.DELETE, Keys.DELETE, Keys.DELETE, Keys.DELETE, gross, Keys.RETURN));

I have no more ideas.

I also tried using Keys.ARROW_LEFT to go to the left side and then delete everything. But that doesn't work either.

I really need help

Albina
  • 1,901
  • 3
  • 7
  • 19
Killig
  • 21
  • 5
  • Does this answer your question? [Selenium Java clear method will not clear the input field?](https://stackoverflow.com/questions/69666100/selenium-java-clear-method-will-not-clear-the-input-field) – Rolandas Ulevicius Jul 24 '23 at 09:58

1 Answers1

1

Try to use Actions.

This code should solve your problem:

public void inputGross(String gross){
  Actions actions = new Actions(driver);
  inputGross.click();
  for (char ch: gross.toCharArray()) {
            actions.sendKeys(Keys.BACK_SPACE).perform();
        }
  actions.sendKeys(inputGross, gross).perform();
}
Yaroslavm
  • 1,762
  • 2
  • 7
  • 15