<commit_before>from lxml.cssselect import CSSSelector
from splinter.driver import DriverAPI, ElementAPI
from splinter.element_list import ElementList
from selenium.webdriver.common.exceptions import WebDriverException, NoSuchElementException

import time 

class BaseWebDriver(DriverAPI):

    def __init__(self):
        self.wait_time = 2

    @property
    def title(self):
        return self.driver.title

    @property
    def html(self):
        return self.driver.get_page_source()

    @property
    def url(self):
        return self.driver.current_url

    def visit(self, url):
        self.driver.get(url)

    def execute_script(self, script):
        self.driver.execute_script(script)

    def evaluate_script(self, script):
        return self.driver.execute_script("return %s" % script)
        
    def is_element_present(self, finder, selector):
        timeout = 25
        interval = 0.5
        end_time = time.time() + timeout
            
        while time.time() < end_time:
            if finder(selector):
                return True
            time.sleep(interval)
        return False

    def is_element_not_present(self, finder, selector):
        timeout = 25
        interval = 0.5
        end_time = time.time() + timeout
            
        while time.time() < end_time:
            if not finder(selector):
                return True
            time.sleep(interval)
        return False
        
    def is_element_present_by_css_selector(self, css_selector):
        return self.is_element_present(self.find_by_css_selector, css_selector)

    def is_element_not_present_by_css_selector(self, css_selector):
        return self.is_element_not_present(self.find_by_css_selector, css_selector)

    def is_element_present_by_xpath(self, xpath):
        return self.is_element_present(self.find_by_xpath, xpath)
        
    def is_element_not_present_by_xpath(self, xpath):
        return self.is_element_not_present(self.find_by_xpath, xpath)

    def is_element_present_by_tag(self, tag):
        return self.is_element_present(self.find_by_tag, tag)
        
    def is_element_not_present_by_tag(self, tag):
        return self.is_element_present(self.find_by_tag, tag)

    def is_element_present_by_name(self, name):
        return self.is_element_present(self.find_by_name, name)

    def is_element_not_present_by_name(self, name):
        return self.is_element_not_present(self.find_by_name, name)

    def is_element_present_by_id(self, id):
        timeout = 25
        interval = 0.5
        end_time = time.time() + timeout
            
        while time.time() < end_time:
            try:
                self.find_by_id(id)
                return True
            except NoSuchElementException:
                pass
            time.sleep(interval)
        return False

    def is_element_not_present_by_id(self, id):
        timeout = 25
        interval = 0.5
        end_time = time.time() + timeout
            
        while time.time() < end_time:
            try:
                self.find_by_id(id)
            except NoSuchElementException:
                return True
            time.sleep(interval)
        return False
            
    def find_option_by_value(self, value):
        return self.find_by_xpath('//option[@value="%s"]' % value)

    def find_option_by_text(self, text):
        return self.find_by_xpath('//option[normalize-space(text())="%s"]' % text)

    def find_link_by_href(self, href):
        return self.find_by_xpath('//a[@href="%s"]' % href)

    def find_link_by_text(self, text):
        return ElementList([self.element_class(element) for element in self.driver.find_elements_by_link_text(text)])
        
    def find_by_css_selector(self, css_selector):
        selector = CSSSelector(css_selector)
        return ElementList([self.element_class(element) for element in self.driver.find_elements_by_xpath(selector.path)])

    def find_by_xpath(self, xpath):
        return ElementList([self.element_class(element) for element in self.driver.find_elements_by_xpath(xpath)])

    def find_by_name(self, name):
        return ElementList([self.element_class(element) for element in self.driver.find_elements_by_name(name)])

    def find_by_id(self, id):
        return ElementList([self.element_class(self.driver.find_element_by_id(id))])

    def find_by_tag(self, tag):
        return ElementList([self.element_class(element) for element in self.driver.find_elements_by_tag_name(tag)])
<commit_msg>removing interval time for is element (not)? present<commit_after>from lxml.cssselect import CSSSelector
from splinter.driver import DriverAPI, ElementAPI
from splinter.element_list import ElementList
from selenium.webdriver.common.exceptions import WebDriverException, NoSuchElementException

import time 

class BaseWebDriver(DriverAPI):

    def __init__(self):
        self.wait_time = 2

    @property
    def title(self):
        return self.driver.title

    @property
    def html(self):
        return self.driver.get_page_source()

    @property
    def url(self):
        return self.driver.current_url

    def visit(self, url):
        self.driver.get(url)

    def execute_script(self, script):
        self.driver.execute_script(script)

    def evaluate_script(self, script):
        return self.driver.execute_script("return %s" % script)
        
    def is_element_present(self, finder, selector):
        timeout = 25
        end_time = time.time() + timeout
            
        while time.time() < end_time:
            if finder(selector):
                return True
        return False

    def is_element_not_present(self, finder, selector):
        timeout = 25
        end_time = time.time() + timeout
            
        while time.time() < end_time:
            if not finder(selector):
                return True
        return False
        
    def is_element_present_by_css_selector(self, css_selector):
        return self.is_element_present(self.find_by_css_selector, css_selector)

    def is_element_not_present_by_css_selector(self, css_selector):
        return self.is_element_not_present(self.find_by_css_selector, css_selector)

    def is_element_present_by_xpath(self, xpath):
        return self.is_element_present(self.find_by_xpath, xpath)
        
    def is_element_not_present_by_xpath(self, xpath):
        return self.is_element_not_present(self.find_by_xpath, xpath)

    def is_element_present_by_tag(self, tag):
        return self.is_element_present(self.find_by_tag, tag)
        
    def is_element_not_present_by_tag(self, tag):
        return self.is_element_present(self.find_by_tag, tag)

    def is_element_present_by_name(self, name):
        return self.is_element_present(self.find_by_name, name)

    def is_element_not_present_by_name(self, name):
        return self.is_element_not_present(self.find_by_name, name)

    def is_element_present_by_id(self, id):
        timeout = 25
        end_time = time.time() + timeout
            
        while time.time() < end_time:
            try:
                self.find_by_id(id)
                return True
            except NoSuchElementException:
                pass
        return False

    def is_element_not_present_by_id(self, id):
        timeout = 25
        end_time = time.time() + timeout
            
        while time.time() < end_time:
            try:
                self.find_by_id(id)
            except NoSuchElementException:
                return True
        return False
            
    def find_option_by_value(self, value):
        return self.find_by_xpath('//option[@value="%s"]' % value)

    def find_option_by_text(self, text):
        return self.find_by_xpath('//option[normalize-space(text())="%s"]' % text)

    def find_link_by_href(self, href):
        return self.find_by_xpath('//a[@href="%s"]' % href)

    def find_link_by_text(self, text):
        return ElementList([self.element_class(element) for element in self.driver.find_elements_by_link_text(text)])
        
    def find_by_css_selector(self, css_selector):
        selector = CSSSelector(css_selector)
        return ElementList([self.element_class(element) for element in self.driver.find_elements_by_xpath(selector.path)])

    def find_by_xpath(self, xpath):
        return ElementList([self.element_class(element) for element in self.driver.find_elements_by_xpath(xpath)])

    def find_by_name(self, name):
        return ElementList([self.element_class(element) for element in self.driver.find_elements_by_name(name)])

    def find_by_id(self, id):
        return ElementList([self.element_class(self.driver.find_element_by_id(id))])

    def find_by_tag(self, tag):
        return ElementList([self.element_class(element) for element in self.driver.find_elements_by_tag_name(tag)])

{'fraction_non_alphanumeric': 0.08697131194012926, 'fraction_numerical': 0.002948180065767094, 'mean_word_length': 2.7595907928388748, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '2872665', 'n_tokens_mistral': 2739, 'n_tokens_neox': 2644, 'n_words': 519}