This code is working fine if saleIdValueIs is correct but same is not working when saleIdValueIs data is not correct. Then it's showing a error message " org.openqa.selenium.NoSuchElementException: Unable to locate element"
driver.manage().timeouts().implicitlyWait(50, TimeUnit.SECONDS);
driver.findElement(By.xpath("//html/body/div/div/div[2]/div[2]/div/div/div/div/div/div/div/div/div[2]/div/div/div/div/div/fieldset/div/div/div/div[2]/div[2]/input")).sendKeys(saleIdValueIs);
search_transaction_bt.click();
boolean saleIdVisible=driver.findElementByXPath("/html/body/div/div/div[2]/div[2]/div/div/div/div/div/div/div/div/div/div/div").isDisplayed();
String searchedSaleIdValue=saleIdValue.getText();
System.out.println(saleIdVisible);
if (saleIdVisible==true){
System.out.println("sale id is - "+saleIdValueIs+ "output is "+searchedSaleIdValue);
}
else{
System.out.println("error message is coming ");
boolean errorMessageDisplayTest= driver.findElement(By.xpath("/html/body/div[2]/div/div")).isDisplayed();
System.out.println(errorMessageDisplayTest);
boolean errorMessageVisible= driver.findElement(By.xpath("/html/body/div[2]/div/div")).isDisplayed();
System.out.println(errorMessageVisible);
driver.close();
}