Some times y'all involve to verify the presence of element earlier taking roughly activeness on software spider web application page. As y'all know, Selenium IDE has many built inwards commands to perform dissimilar types of actions on your software spider web application page. You tin rank the axe verify presence of element past times using "verifyElementPresent" ascendancy in selenium IDE software testing tool. Also y'all tin rank the axe thought illustration of selenium IDE software testing tool's "verifyElementNotPresent" command. Web driver conduct keep non whatever built inwards method or interface past times which nosotros tin rank the axe verify presence of chemical subdivision on the page of software spider web application.
Yes nosotros tin rank the axe produce it really easily inwards WebDriver also using bellow given syntax.
Boolean iselementpresent = driver.findElements(By.xpath("//input[@id='text2']")).size()!= 0;
We conduct keep to use findElements() method for this purpose. Above syntax volition supply truthful if chemical subdivision is acquaint on page of software spider web application. Else it volition supply false. You tin rank the axe seat if status to conduct keep activeness based on presence of chemical subdivision on page of software spider web application.
Bellow given illustration volition banking concern fit the presence of dissimilar text box on page. It volition impress message inwards console based on presence of element.
@Test world void exam () throws InterruptedException { for (int i=1; i<6; i++) { //To verify chemical subdivision is acquaint on page or not. String XPath = "//input[@id='text"+i+"']"; Boolean iselementpresent = driver.findElements(By.xpath(XPath)).size()!= 0; if (iselementpresent == true) { System.out.print("\nTargeted TextBox"+i+" Is Present On The Page"); } else { System.out.print("\nTargeted Text Box"+i+" Is Not Present On The Page"); } } }