<commit_before>package helpers

import org.openqa.selenium.remote.DesiredCapabilities
import org.openqa.selenium.WebDriver
import org.openqa.selenium.phantomjs.{PhantomJSDriver, PhantomJSDriverService}
import org.openqa.selenium.chrome.ChromeDriver
import org.openqa.selenium.ie.InternetExplorerDriver
import org.openqa.selenium.safari.SafariDriver
import org.openqa.selenium.htmlunit.HtmlUnitDriver
import org.openqa.selenium.firefox.{FirefoxDriver, FirefoxProfile}
import java.util.concurrent.TimeUnit
import com.typesafe.config.ConfigFactory

class Config {
  private val systemProperties = System.getProperties()
  private val conf = ConfigFactory.load()

  val baseUrl: String = conf.getString("base_url")

  val webDriver: WebDriver = {
    var selectedDriver: WebDriver = null

    if (conf.hasPath("browser")) {
      val targetBrowser = conf.getString("browser")

      if (targetBrowser.equalsIgnoreCase("chrome")) {
        if (conf.hasPath("webdriver.chrome.driver")) {
          systemProperties.setProperty("webdriver.chrome.driver", conf.getString("webdriver.chrome.driver"))
        }
        else {
          systemProperties.setProperty("webdriver.chrome.driver", "drivers/chromedriver-2.9_macosx")
        }
        selectedDriver = new ChromeDriver()
      }
      else if (targetBrowser.equalsIgnoreCase("ie") || targetBrowser.equalsIgnoreCase("internetexplorer")) {
        selectedDriver = new InternetExplorerDriver()
      }
      else if (targetBrowser.equalsIgnoreCase("safari")) {
        selectedDriver = new SafariDriver()
      }
      else if (targetBrowser.equalsIgnoreCase("htmlunit")) {
        selectedDriver = new HtmlUnitDriver()
        // Disable javascript as jQuery crashes HtmlUnit!!
        selectedDriver.asInstanceOf[HtmlUnitDriver].setJavascriptEnabled(false)
      }
      else if (targetBrowser.equalsIgnoreCase("phantomjs")) {

        if (conf.hasPath("webdriver.phantomjs.binary")) {
          systemProperties.setProperty("webdriver.phantomjs.binary", conf.getString("webdriver.phantomjs.binary"))
        }
        else {
          systemProperties.setProperty("webdriver.phantomjs.binary", "drivers/phantomjs-1.9.7_macosx")
        }

        val capabilities = new DesiredCapabilities
        capabilities.setJavascriptEnabled(true)
        capabilities.setCapability("takesScreenshot", false)
        capabilities.setCapability(
          PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY,
          systemProperties.getProperty("webdriver.phantomjs.binary"))
        capabilities.setCapability(PhantomJSDriverService.PHANTOMJS_CLI_ARGS, Array("--ignore-ssl-errors=yes", "--web-security=false", "--ssl-protocol=any"));

        selectedDriver = new PhantomJSDriver(capabilities)
      }
    }

    if (selectedDriver == null ) {
      val firefoxProfile = new FirefoxProfile()
      firefoxProfile.setAcceptUntrustedCertificates(true)
      selectedDriver = new FirefoxDriver(firefoxProfile)
    }

    // TODO probably should make the timeout configurable
    selectedDriver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS)

    selectedDriver
  }
}

object Config extends Config
<commit_msg>convert Config to object and disable phantomjs for now<commit_after>package helpers

import org.openqa.selenium.WebDriver
//import org.openqa.selenium.phantomjs.{PhantomJSDriver, PhantomJSDriverService}
//import org.openqa.selenium.remote.DesiredCapabilities
import org.openqa.selenium.firefox.{FirefoxDriver, FirefoxProfile}
import java.util.concurrent.TimeUnit
import com.typesafe.config.ConfigFactory
import org.scalatest.selenium._

object Config {
  private val systemProperties = System.getProperties()
  private val conf = ConfigFactory.load()

  val baseUrl: String = conf.getString("base_url")

  def webDriver: WebDriver = {

    val selectedDriver: WebDriver =
      if (conf.hasPath("browser")) {
        val targetBrowser = conf.getString("browser")

        if (targetBrowser.equalsIgnoreCase("chrome")) { // TODO replace the if-elseif with a match
          if (conf.hasPath("webdriver.chrome.driver")) {
            systemProperties.setProperty("webdriver.chrome.driver", conf.getString("webdriver.chrome.driver"))
          }
          else {
            systemProperties.setProperty("webdriver.chrome.driver", "drivers/chromedriver-2.9_macosx")
          }
          Chrome.webDriver
        }
        else if (targetBrowser.equalsIgnoreCase("ie") || targetBrowser.equalsIgnoreCase("internetexplorer")) {
          InternetExplorer.webDriver
        }
        else if (targetBrowser.equalsIgnoreCase("safari")) {
          Safari.webDriver
        }
        else if (targetBrowser.equalsIgnoreCase("htmlunit")) {
          HtmlUnit.webDriver
        }
        /*else if (targetBrowser.equalsIgnoreCase("phantomjs")) {

          if (conf.hasPath("webdriver.phantomjs.binary")) {
            systemProperties.setProperty("webdriver.phantomjs.binary", conf.getString("webdriver.phantomjs.driver"))
          }
          else {
            systemProperties.setProperty("webdriver.phantomjs.binary", "drivers/phantomjs-1.9.7_macosx")
          }

          val capabilities = new DesiredCapabilities
          capabilities.setJavascriptEnabled(true)
          capabilities.setCapability("takesScreenshot", false)
          capabilities.setCapability(
            PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY,
            systemProperties.getProperty("webdriver.phantomjs.binary"))
          capabilities.setCapability(PhantomJSDriverService.PHANTOMJS_CLI_ARGS, Array("--ignore-ssl-errors=yes", "--web-security=false", "--ssl-protocol=any"));

          PhantomJSDriverObject(capabilities)
        }*/
        else { // Default
          Firefox.firefoxProfile.setAcceptUntrustedCertificates(true)
          Firefox.webDriver
        }
      }
      else { // Default
        Firefox.firefoxProfile.setAcceptUntrustedCertificates(true)
        Firefox.webDriver
      }

    // TODO probably should make the timeout configurable
    selectedDriver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS)

    selectedDriver
  }
}

{'fraction_non_alphanumeric': 0.10259761476882863, 'fraction_numerical': 0.001960463976474432, 'mean_word_length': 3.420216606498195, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4367666', 'n_tokens_mistral': 1756, 'n_tokens_neox': 1681, 'n_words': 264}