|
Late reply !
selenium.isElementPresent - seems the best way!
I wrote a function like this (though not related to verify a text present in a page) :
// this the case to jump to this below username related code.
case username:
//Verifies whether the field with id=user_123 existis using the ---- verifyExistence()
if (av.verifyExistence(("id=user_123"), pagename,"","",excelrc)) {
//If exists, then Enter data which is passed via this array fnamearr[ ]
driver.findElement(By.id(UserName)).sendKeys(fnamearr[rc+1]);
//once succeeded, then write the success result to XLS using Apache POI
av.writePOI(passflag,pagename,fnamearr[rc],fnamearr[rc+1],excelrc,"c:\\resultsall.xls",passdescription); }
break;
In the verifyExistence() method, I do more things. I will verify enabled disabled etc.
If disabled, I write discrepancy into XLS as Fail - Anyway, the test run will continue.
If want to verify the text is present in an edit box, I would write a reusable function which takes 2 parameters; One is id/name of the edit box. Second one is the text to be present.
|