Im trying to achieve checking for the text "In stock.", via a XPath query, however my XPath variable elementInStock returns a ID, and it looks like its not finding the text "In stock.", from the URL https://www.amazon.co.uk/dp/B08H96W864/ref=twister_B08J4RCVXW?_encoding=UTF8&th=1
Would appreciate some help how to find the text "In stock." and do the Console.WriteLine("HEYYYY");
if text "In stock." not found then keep go to the while loop in mu code, my logic does not even go to the while loop if XPATH is null.
Please advise.
class Program
{
static void Main(string[] args)
{
IWebDriver driver = new ChromeDriver();
//Navigate to
driver.Navigate().GoToUrl("https://www.amazon.co.uk/dp/B08H96W864/ref=twister_B08J4RCVXW?_encoding=UTF8&th=1");
driver.Manage().Window.Maximize();
IWebElement elementInStock = driver.FindElement(By.XPath("/html/body/div[2]/div[2]/div[5]/div[4]/div[4]/div[18]"));
if (elementInStock != null)
{
Console.WriteLine("HEYYYY");
}
else if (elementInStock == null)
{
int counter = 0;
while (counter < 10)
{
Thread.Sleep(2500);
driver.Navigate().Refresh();
}
}
}
}
}