Several of my tests refer to importBrokerCheckBox. But not all tests have to find it, because he must be absent. That is, if the element is on the page, then we must click on it, and if it is not there, we must go further through the code.But below code doesn't work and throws exception - xpath not found
importBrokerCheckBox = $x(".//div[text()='Брокер']/../../../preceding-sibling::span//span[@aria-label=\"caret-down\"]"),
if (importBrokerCheckBox.isDisplayed());
{
importBrokerCheckBox.click();
}
if (importBrokerSettingsCheckbox.isDisplayed());
{
importBrokerSettingsCheckbox.click();
}