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
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();
}