Индуцируйте WebDriverWait
и ElementExists
и используйте ниже xpath.
Вам необходимо установить SeleniumExtras.WaitHelpers
pakage из Manage Nuget Packages
.
WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));
string strText=wait.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementExists(By.XPath("//center[@id='genelUyariCenterTag' and contains(.,'BULUNAMAMIŞTIR')]"))).Text;
if (strText.Contains("LİSTELENECEK VERİ BULUNAMAMIŞTIR."))
{
Console.WriteLine("madde15 there is no Excel");
}
else
{
Console.WriteLine("madde 15 there is an Excel");
}
Попробуйте обновить один без WebDriverWait
string strText=driver.FindElement(By.XPath("//center[@id='genelUyariCenterTag' and contains(.,'BULUNAMAMIŞTIR')]")).Text;
if (strText.Contains("LİSTELENECEK VERİ BULUNAMAMIŞTIR."))
{
Console.WriteLine("madde15 there is no Excel");
}
else
{
Console.WriteLine("madde 15 there is an Excel");
}