package org.selenide.examples;

import com.codeborne.selenide.CollectionCondition;
import com.codeborne.selenide.SelenideElement;
import com.codeborne.selenide.WebDriverRunner;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.testcontainers.containers.BrowserWebDriverContainer;

import java.io.File;

import static com.codeborne.selenide.Selenide.*;

public class GoogleTestWithFirefox {
  @Rule
  public BrowserWebDriverContainer browser =
      new BrowserWebDriverContainer("selenium/standalone-firefox-debug:3.3.0")
          .withRecordingMode(BrowserWebDriverContainer.VncRecordingMode.RECORD_ALL, new File("build"))
          .withDesiredCapabilities(DesiredCapabilities.firefox());

  @Before
  public void setUp() {
    RemoteWebDriver driver = browser.getWebDriver();
    System.out.println(browser.getVncAddress());
    WebDriverRunner.setWebDriver(driver);
  }

  @After
  public void tearDown() {
    WebDriverRunner.closeWebDriver();
  }

  @Test
  public void search() {
    open("https://google.com/");
    $(By.name("q")).val("Selenide").pressEnter();
    $$("#ires .g").shouldHave(CollectionCondition.sizeGreaterThan(5));

    for (int i = 0; i < 5; i++) {
      SelenideElement link = $("#ires .g", i).find("a");
      System.out.println(link.attr("href"));
      link.click();
      back();
    }
    sleep(1000);
  }
}

@@ -489,16 +489,90 @@
 .File;%0A%0A
+import static com.codeborne.selenide.CollectionCondition.sizeGreaterThan;%0A
 import s
@@ -1306,23 +1306,24 @@
 )).val(%22
-Selenid
+codeborn
 e%22).pres
@@ -1366,240 +1366,26 @@
 ave(
-CollectionCondition.sizeGreaterThan(5));%0A%0A    for (int i = 0; i %3C 5; i++) %7B%0A      SelenideElement link = $(%22#ires .g%22, i).find(%22a%22);%0A      System.out.println(link.attr(%22href%22));%0A      link.click();%0A      back();%0A    %7D%0A    sleep(1000
+sizeGreaterThan(5)
 );%0A 

simplify the test: selenide.org failed in Firefox 52 inside docker (for unknown reason)