<commit_before>'use strict';

var webdriver  = require('selenium-webdriver'),
By             = require('selenium-webdriver').By,
expect         = require('chai').expect,
_              = require('underscore'),
Promise        = require("bluebird"),
until          = require('selenium-webdriver').until,
check_elements = require('./check_elements');


var submit_form_func = Promise.promisify( function(args, callback){

  var driver          = args.driver,
      result_callback = callback,
      // Regex to check the message that is shown after form is submitted
      message         = args.message || /.*/,
      // Array of object that have at least two keys: selector - css selector
      // and value - value to be entered
      form_params     = args.form_params || [],

      // Defined how elemts are going to be checked in case of success,
      // if that parameter is omitted - 'form_params' is used instead
      elements_to_check   = args.elements_to_check || form_params,

      // Indicates whether form submission is going to be successful
      should_be_successful = args.should_be_successful || false,

      // Indicate if message to be searched through all messages shown,
      // bu defaul it looks into firts message only
      multi_line_message = args.multi_line_message || false,

      // Indicates if there is a confirmation dialog
      confirm_dialog = args.confirm_dialog || false,

      // CSS selecetor for form submition button
      submit_button_selector = args.submit_button_selector ||'button[type="submit"]';


    driver.call(function(){
      // Enter form parameters
      Promise.all([
          _.map(
              form_params,
              function( test_case ){

                  // Handle case when test case is empty
                  if (Object.keys(test_case).length === 0 ){
                      return Promise.resolve(1);
                  }

                  driver
                  .findElement(By.css( test_case.selector ))
                  .then(function(el){
                      if ( test_case.hasOwnProperty('option_selector') ) {
                          el.click();
                          return el.findElement(By.css( test_case.option_selector ))
                            .then(function(el){ return el.click(); });
                      } else if ( test_case.hasOwnProperty('tick')) {
                          return el.click();
                      } else if (test_case.file) {
                        return Promise.resolve()
                          .then(() => el.sendKeys( test_case.value ));
                      } else if (test_case.hasOwnProperty('dropdown_option')) {
                        return el.click()
                          .then(() => driver.findElement(By.css(test_case.dropdown_option)))
                          .then(dd => dd.click())
                      } else {
                          return el.clear().then(function(){
                              el.sendKeys( test_case.value );
                          });<commit_msg>Trigger closing calendar overlays<commit_after>'use strict';

var webdriver  = require('selenium-webdriver'),
By             = require('selenium-webdriver').By,
Key            = require('selenium-webdriver').Key,
expect         = require('chai').expect,
_              = require('underscore'),
Promise        = require("bluebird"),
until          = require('selenium-webdriver').until,
check_elements = require('./check_elements');


var submit_form_func = Promise.promisify( function(args, callback){

  var driver          = args.driver,
      result_callback = callback,
      // Regex to check the message that is shown after form is submitted
      message         = args.message || /.*/,
      // Array of object that have at least two keys: selector - css selector
      // and value - value to be entered
      form_params     = args.form_params || [],

      // Defined how elemts are going to be checked in case of success,
      // if that parameter is omitted - 'form_params' is used instead
      elements_to_check   = args.elements_to_check || form_params,

      // Indicates whether form submission is going to be successful
      should_be_successful = args.should_be_successful || false,

      // Indicate if message to be searched through all messages shown,
      // bu defaul it looks into firts message only
      multi_line_message = args.multi_line_message || false,

      // Indicates if there is a confirmation dialog
      confirm_dialog = args.confirm_dialog || false,

      // CSS selecetor for form submition button
      submit_button_selector = args.submit_button_selector ||'button[type="submit"]';


    driver.call(function(){
      // Enter form parameters
      Promise.all([
          _.map(
              form_params,
              function( test_case ){

                  // Handle case when test case is empty
                  if (Object.keys(test_case).length === 0 ){
                      return Promise.resolve(1);
                  }

                  driver
                  .findElement(By.css( test_case.selector ))
                  .then(function(el){
                      if ( test_case.hasOwnProperty('option_selector') ) {
                          el.click();
                          return el.findElement(By.css( test_case.option_selector ))
                            .then(function(el){ return el.click(); });
                      } else if ( test_case.hasOwnProperty('tick')) {
                          return el.click();
                      } else if (test_case.file) {
                        return Promise.resolve()
                          .then(() => el.sendKeys( test_case.value ));
                      } else if (test_case.hasOwnProperty('dropdown_option')) {
                        return el.click()
                          .then(() => driver.findElement(By.css(test_case.dropdown_option)))
                          .then(dd => dd.click())
                      } else {
                          return el.clear().then(function(){
                              el.sendKeys( test_case.value );
                              // Tabs to trigger the calendars overlays
                              // to close so the modal submit button can be clicked
                              el.sendKeys(Key.TAB)
                          });
{'fraction_non_alphanumeric': 0.09841219933972646, 'fraction_numerical': 0.0006288319446627889, 'mean_word_length': 1.614878750513769, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5355548', 'n_tokens_mistral': 1571, 'n_tokens_neox': 1516, 'n_words': 416}