<commit_before>package com.codeborne.selenide;

import org.openqa.selenium.*;
import org.openqa.selenium.support.ui.Select;

import java.util.List;

import static com.codeborne.selenide.Condition.visible;
import static com.codeborne.selenide.Navigation.sleep;
import static com.codeborne.selenide.WebDriverRunner.fail;
import static com.codeborne.selenide.WebDriverRunner.getWebDriver;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.junit.Assert.*;

public class DOM {
  public static long defaultWaitingTimeout = Long.getLong("timeout", 4000);

  public static WebElement getElement(By by) {
    try {
      return getWebDriver().findElement(by);
    } catch (WebDriverException e) {
      return fail("Cannot get element " + by + ", caused by: " + e);
    }
  }

  public static WebElement getElement(By by, int index) {
    try {
      return getWebDriver().findElements(by).get(index);
    } catch (WebDriverException e) {
      return fail("Cannot get element " + by + ", caused by: " + e);
    }
  }

  public static List<WebElement> getElements(By by) {
    try {
      return getWebDriver().findElements(by);
    } catch (WebDriverException e) {
      return fail("Cannot get element " + by + ", caused by: " + e);
    }
  }
  
  public static void setValue(By by, String value) {
    try {
      WebElement element = getElement(by);
      setValue(element, value);
      triggerChangeEvent(by);
    } catch (WebDriverException e) {<commit_msg>Added methods $ and $$ as synonyms for getElement(By.cssSelector())<commit_after>package com.codeborne.selenide;

import org.openqa.selenium.*;
import org.openqa.selenium.support.ui.Select;

import java.util.List;

import static com.codeborne.selenide.Condition.visible;
import static com.codeborne.selenide.Navigation.sleep;
import static com.codeborne.selenide.WebDriverRunner.fail;
import static com.codeborne.selenide.WebDriverRunner.getWebDriver;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.junit.Assert.*;

public class DOM {
  public static long defaultWaitingTimeout = Long.getLong("timeout", 4000);

  /**
   * Find the first element matching given CSS selector
   * @param cssSelector any CSS selector like "input[name='first_name']" or "#messages .new_message"
   * @return null if element was no found
   */
  public static WebElement $(String cssSelector) {
    return getElement(By.cssSelector(cssSelector));
  }

  /**
   * Find all elements matching given CSS selector
   * @param cssSelector any CSS selector like "input[name='first_name']" or "#messages .new_message"
   * @return null if element was no found
   */
  public static List<WebElement> $$(String cssSelector) {
    return getElements(By.cssSelector(cssSelector));
  }

  /**
   * Find the first element matching given criteria
   * @param criteria instance of By: By.id(), By.className() etc.
   * @return null if element was no found
   */
  public static WebElement getElement(By criteria) {
    try {
      return getWebDriver().findElement(criteria);
    } catch (WebDriverException e) {
      return fail("Cannot get element " + criteria + ", caused criteria: " + e);
    }
  }

  /**
   * Find the Nth element matching given criteria
   * @param criteria instance of By: By.id(), By.className() etc.
   * @param index 1..N
   * @return null if element was no found
   */
  public static WebElement getElement(By criteria, int index) {
    try {
      return getWebDriver().findElements(criteria).get(index);
    } catch (WebDriverException e) {
      return fail("Cannot get element " + criteria + ", caused criteria: " + e);
    }
  }

  /**
   * Find all elements matching given CSS selector
   * @param criteria instance of By: By.id(), By.className() etc.
   * @return null if element was no found
   */
  public static List<WebElement> getElements(By criteria) {
    try {
      return getWebDriver().findElements(criteria);
    } catch (WebDriverException e) {
      return fail("Cannot get element " + criteria + ", caused criteria: " + e);
    }
  }
  
  public static void setValue(By by, String value) {
    try {
      WebElement element = getElement(by);
      setValue(element, value);
      triggerChangeEvent(by);
    } catch (WebDriverException e) {
{'fraction_non_alphanumeric': 0.11113727336943725, 'fraction_numerical': 0.0021191429244172355, 'mean_word_length': 3.617391304347826, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, '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': '5822224', 'n_tokens_mistral': 1254, 'n_tokens_neox': 1231, 'n_words': 360}