@Test
public void canClickIfThereIsSuitableElement() {

    WebElement correctWebElement = mock(WebElement.class);
    when(correctWebElement.getText()).thenReturn("  ATP ");
    when(correctWebElement.isDisplayed()).thenReturn(true);
    WebElement incorrectWebElement1 = mock(WebElement.class);
    when(incorrectWebElement1.getText()).thenReturn("sometATPhing");
    when(incorrectWebElement1.isDisplayed()).thenReturn(true);
    WebElement incorrectWebElement2 = mock(WebElement.class);
    when(incorrectWebElement2.getText()).thenReturn(" ATP ");
    when(incorrectWebElement2.isDisplayed()).thenReturn(false);
    WebElement incorrectWebElement3 = mock(WebElement.class);
    when(incorrectWebElement3.getText()).thenReturn("sometATPhing");
    when(incorrectWebElement3.isDisplayed()).thenReturn(false);
    List<WebElement> webElements = new ArrayList<>();
    webElements.add(incorrectWebElement1);
    webElements.add(incorrectWebElement2);
    webElements.add(incorrectWebElement3);
    webElements.add(correctWebElement);
    By elementsLocator = By.className(initialCollectorClass);
    WebDriver webDriver = mock(WebDriver.class);
    when(webDriver.findElements(elementsLocator)).thenReturn(webElements);
    SearchContextFunction contextProvider = webDriver1 -> webDriver;
    ClickClassByText clickClassByText = new ClickClassByText(initialCollectorClass, text, expectsHttp, contextProvider);
    clickClassByText.executeAfterJSPreconditionHasBeenSatisfied(webDriver, mock(ReplayingState.class), contextProvider);
}