The below code is getting into an infinite search when running via TestNG, otherwise giving correct results when executed directly in Main method via Java Application.

```
Boolean iselementpresent = driver.findElements(By.linkText("Foreign exchange1")).size()!= 0;

```

Infinite search-->

```
public boolean checkLinkPresence(String linkName){
    Boolean iselementpresent = driver.findElements(By.linkText("Foreign exchange1")).size()!= 0;
    if (iselementpresent == true)
        return true;
    else{
        System.out.print("Element " + linkName + " not Present");
        APP_LOGS.debug("Element " + linkName + " not Present");
        return false;
    }
}

```