package integration;

import com.codeborne.selenide.Configuration;
import com.codeborne.selenide.WebDriverProvider;
import com.codeborne.selenide.WebDriverRunner;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.remote.DesiredCapabilities;

import static com.codeborne.selenide.Selenide.close;
import static com.codeborne.selenide.WebDriverRunner.isFirefox;
import static org.junit.Assert.assertTrue;
import static org.junit.Assume.assumeTrue;

public class CustomWebDriverProviderTest extends IntegrationTest {
  private String originalWebdriver;
  
  @Before
  public void setUp() {
    originalWebdriver = Configuration.browser;

    assumeTrue(isFirefox());
    close();
  }

  @After
  public void tearDown() {
    close();
    Configuration.browser = originalWebdriver;
  }

  @Test
  public void userCanImplementAnyCustomWebdriverProvider() {
    Configuration.browser = CustomWebDriverProvider.class.getName();
    
    openFile("autocomplete.html");
    
    assertTrue(WebDriverRunner.getWebDriver() instanceof CustomFirefoxDriver);
  }

  private static class CustomFirefoxDriver extends FirefoxDriver {
  }
  
  private static class CustomWebDriverProvider implements WebDriverProvider {
    @Override
    public WebDriver createDriver(DesiredCapabilities desiredCapabilities) {
      return new CustomFirefoxDriver();
    }
  }
}

@@ -297,23 +297,21 @@
 ium.
-firefox.Firefox
+chrome.Chrome
 Driv
@@ -478,23 +478,22 @@
 unner.is
-Firefox
+Chrome
 ;%0Aimport
@@ -778,23 +778,22 @@
 eTrue(is
-Firefox
+Chrome
 ());%0A   
@@ -1150,31 +1150,30 @@
 nceof Custom
-Firefox
+Chrome
 Driver);%0A  %7D
@@ -1199,31 +1199,30 @@
 class Custom
-Firefox
+Chrome
 Driver exten
@@ -1224,23 +1224,22 @@
 extends 
-Firefox
+Chrome
 Driver %7B
@@ -1442,15 +1442,14 @@
 stom
-Firefox
+Chrome
 Driv

use chrome instead of firefox