How to insert text in text field of model window using selenium webdriver ?

package SeleniumLearn.Com;
import org.testng.annotations.Test;
import org.openqa.selenium.Alert;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.BeforeTest;

public class SendTextAlertWindow {
public WebDriver driver;
  
  @Test
            public void Entertext()throws Exception {
           driver.get("http://kalamshastra.com/prompt-dialog-box");
           Thread.sleep(9000);
           driver.findElement(By.xpath("//*[@id='node-103']/div/div[1]/div/div/button")).click();
           Alert alert = driver.switchTo().alert();
           alert.sendKeys("Welcome to Selenium World");

  
        Thread.sleep(5000);
           alert.accept();
           }
       
     @BeforeTest
           public void beforeTest() {
           driver= new FirefoxDriver();
           driver.manage().window().maximize();
           }
}

Tags: