I have the div with classname 'okrSelectorSelect__value-container' in DOM.
<div class="okrSelectorSelect__value-container"><div>
This div is optional. I want to click on it and do some additional tests with block that appears after that IF IT EXIST. I'm trying this.
cy.get('.okrSelectorSelect__value-container').then(($higherObjectivePick) => {
if ($higherObjectivePick.length > 0) {
$higherObjectivePick.click();
}
});
But got this when block is not on the page
Here is my solution, but looks like there is much more beautiful ways to do that.
cy.get('body').then($body => {
if ($body.find('.okrSelectorSelect__value-container').length > 0) {
cy.get('.okrSelectorSelect__value-container').click();
cy.get('.okrSelectorSelect__option').eq(higherOrderObjectiveNumber).click();
}
});
