<commit_before>require 'selenium-webdriver'

require './cyber_dojo_main_page'
require './cyber_dojo_setup_default_start_point_show_languages_page'
require './cyber_dojo_setup_default_start_point_show_exercises_page'

class CyberDojoBrowser

  def initialize
    @driver = Selenium::WebDriver.for :firefox if ENV['browser'] == 'firefox'
    @driver = Selenium::WebDriver.for :chrome if ENV['browser'] == 'chrome' || @driver == nil
    @wait = Selenium::WebDriver::Wait.new(:timeout => 4)

    @mainPage = CyberDojoMainPage.new(@driver, @wait)
    @setupDefaultStartPointPageShowLanugages = CyberDojoSetupDefaultStartPointShowLanguagesPage.new(@driver, @wait)
    @setupDefaultStartPointPageShowExercises = CyberDojoSetupDefaultStartPointShowExercisesPage.new(@driver, @wait)

    @driver.manage.window.resize_to 1920, 1080
  end

  def close
    @driver.quit
  end

  def navigate_home
    @driver.navigate.to "http://cyber-dojo.org"
  end

  def title
    @driver.title
  end

  def save_screenshot(filename)
    # Not keen on this sleep but Firefox will take a screen shot before completing
    # the previous action if it's not present.
    # TODO: Find a better way to complete actions before taking a screen shot
    sleep 1
    @driver.save_screenshot(filename + ".png")
  end

  def page_url
    url = @driver.current_url
    url.slice! "http://cyber-dojo.org/"

    url.split("/")
  end

  def home_page
    @wait.until { page_url == [] }
    @mainPage
  end

  def setup_default_start_point_show_languages_page
    @wait.until { page_url[0] == "setup_default_start_point" && page_url[1] == "show_languages" }
    @setupDefaultStartPointPageShowLanugages
  end

  def setup_default_start_point_show_exercises_page
    @wait.until { page_url[0] == "setup_default_start_point" && page_url[1] == "show_exercises" }
    @setupDefaultStartPointPageShowExercises
  end

end<commit_msg>Changed the tests to target remote web driver, needs improving!<commit_after>require 'selenium-webdriver'

require './cyber_dojo_main_page'
require './cyber_dojo_setup_default_start_point_show_languages_page'
require './cyber_dojo_setup_default_start_point_show_exercises_page'

class CyberDojoBrowser

  def initialize
#    @driver = Selenium::WebDriver.for :firefox if ENV['browser'] == 'firefox'
#    @driver = Selenium::WebDriver.for :chrome if ENV['browser'] == 'chrome' || @driver == nil
    @driver = Selenium::WebDriver.for :remote, :url => "http://localhost:4444/wd/hub", :desired_capabilities => :firefox
    @wait = Selenium::WebDriver::Wait.new(:timeout => 4)

    @mainPage = CyberDojoMainPage.new(@driver, @wait)
    @setupDefaultStartPointPageShowLanugages = CyberDojoSetupDefaultStartPointShowLanguagesPage.new(@driver, @wait)
    @setupDefaultStartPointPageShowExercises = CyberDojoSetupDefaultStartPointShowExercisesPage.new(@driver, @wait)

    @driver.manage.window.resize_to 1920, 1080
  end

  def close
    @driver.quit
  end

  def navigate_home
    @driver.navigate.to "http://cyber-dojo.org"
  end

  def title
    @driver.title
  end

  def save_screenshot(filename)
    # Not keen on this sleep but Firefox will take a screen shot before completing
    # the previous action if it's not present.
    # TODO: Find a better way to complete actions before taking a screen shot
    sleep 1
    @driver.save_screenshot(filename + ".png")
  end

  def page_url
    url = @driver.current_url
    url.slice! "http://cyber-dojo.org/"

    url.split("/")
  end

  def home_page
    @wait.until { page_url == [] }
    @mainPage
  end

  def setup_default_start_point_show_languages_page
    @wait.until { page_url[0] == "setup_default_start_point" && page_url[1] == "show_languages" }
    @setupDefaultStartPointPageShowLanugages
  end

  def setup_default_start_point_show_exercises_page
    @wait.until { page_url[0] == "setup_default_start_point" && page_url[1] == "show_exercises" }
    @setupDefaultStartPointPageShowExercises
  end

end
{'fraction_non_alphanumeric': 0.10215462610899874, 'fraction_numerical': 0.008111533586818757, 'mean_word_length': 4.503486750348675, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '3617981', 'n_tokens_mistral': 1361, 'n_tokens_neox': 1289, 'n_words': 273}