Field Validation for Alert Box when passing invalid inputs using Selenium
 class name text
{
public static void main(String[] args)
{  
WebDriver z=new FirefoxDriver();     
z.manage().window().maximize();     
z.get("");
    
z.findElement(By.id("FIRSTNAME")).sendKeys("!@#$%^&*");
    
z.findElement(By.id("Button1")).click(); 
String
at=z.switchTo().alert().getText();     
System.out.println(at);     
if(at.equals("First name Should
not contain Special Characters"))  
{  
System.out.println("pass");  
z.switchTo().alert().dismiss();  
}  
else  
System.out.println("false"); 
z.findElement(By.id("FIRSTNAME")).clear();
    
z.findElement(By.id("FIRSTNAME")).sendKeys("TESTING");
    
z.findElement(By.id("Button1")).click(); 
String
at1=z.switchTo().alert().getText();     
System.out.println(at1);     
if(at1.equals("First name Should
not contain Special Characters"))  
{  
System.out.println("pass");  
  
}  
else  
System.out.println("false"); 
   
z.switchTo().alert().dismiss();     
}     
} 

 
No comments:
Post a Comment