I am using if
block to check if product is in stock or out of stock. but it is not executing the else
block , also I don't want to put else
part in catch block.
I have used isDisplayed
, isEnabled
but still it is not working.
try {
if (driver.findElement(By.xpath("//span[contains(text(),'Currently unavailable.')]"))
.isEnabled()) {
o1.put("STOCK", "Out of Stock");
} else {
o1.put("STOCK", "In Stock");
}
} catch (NoSuchElementException e) {
e.printStackTrace();
}