How to know text is present or not in selenium , we have to validate it
I visited man website , for validate , but few are asking with assert/verify , include some library file and etc .
but when i tired from my end , i got this working code for validation without include any jar file
for validate we will use following code :
// Validate text is present or not
if(driver.getPageSource().contains("text")){
System.out.println("Text is present");
}else{
System.out.println("Text is absent");
}
you dont need to add path and all , as a step you have to copy and paste this code.
if(driver.getPageSource().contains("text")) in this instead of "text", enter text which you want to verify.
so , if your text is present it will print " Text is Present" else it will print "Text is absent"
Comments
Post a Comment