package com.utility;
import com.Bam.SeleniumSigleInstance;
import com.myexception.MyException;
import com.thoughtworks.selenium.Selenium;
public class CheckXpath
{
private static Selenium selenium;
static int count = 1;
public static boolean checkXpathIsValid(String xpath) throws MyException,
InterruptedException
{
selenium = SeleniumSigleInstance.getInstance();
if (!selenium.isElementPresent(xpath))
{
Thread.sleep(3000);
System.out.println("wait for " + count * 3000
+ "s for the target...");
//find the targets for three times
if (count == 3)
{
throw new MyException("can not find the xpath: " + xpath);
}
count++;
// recurrence the method checkXpathIsValid.
checkXpathIsValid(xpath);
}
return true;
}
}