0 votes
1 view
in Devops and Agile by (19.8k points)

I want to delete a default value of a textbox to enter the new value, but I am not getting how to do that.

I was thinking to use CTRL+a and then Delete but I'm not sure how to do this.

I even used WebDriver's comm and driver.findElement("locator").clear();

1 Answer

0 votes
by (63.4k points)

For page object model -

 @FindBy(xpath="//foo")

   public WebElement textBox;

now in your function

 public void clearExistingText(String newText){

    textBox.clear();

    textBox.sendKeys(newText);

  }

for general selenium architecture -

driver.findElement(By.xpath("//yourxpath")).clear();

driver.findElement(By.xpath("//yourxpath")).sendKeys("newText");

Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...