I want to check if "X" element is visible, if it is not visible, then click button "Y" that will display button "X"
I tried the following examples
This first example, breaks due to "driver" is unable to find this locator. What is the best approach to check if this element is Not visible and then click the other button in order to display it?
if (!(driver.findelement(XBUTTONlocator).Displayed))
{
driver.Navigate().GoToUrl(VariablesConstants.ManageWizardURL);
Thread.Sleep(2000);
YBUTTONlocator.Click();
Assert.IsTrue(driver.FindElement(By.CssSelector("")).Displayed);
}
I also have this Expected condition but I do not know of how to implement it in a IF, and then make an action.
public static Func<IWebDriver, bool> InvisibilityOfElementLocated(By locator)
{
return (driver) =>
{
try
{
var element = driver.FindElement(locator);
return !element.Displayed;
}
catch (NoSuchElementException)
{
return true;
}
catch (StaleElementReferenceException)
{
return true;
}
};
HTML of button I want to verify it's displayed:
<span translate="" class="ng-scope ng-binding">Create Distribution Group</span>
Aucun commentaire:
Enregistrer un commentaire