<commit_before>require 'watir-webdriver/extensions/alerts'
require 'page-object/elements'
require 'page-object/core_ext/string'


module PageObject
  #
  # Watir implementation of the page object platform driver.  You should not use the
  # class directly.  Instead you should include the PageObject module in your page object
  # and use the methods dynamically added from the PageObject::Accessors module.
  #
  class WatirPageObject
    attr_reader :browser

    def initialize(browser)
      @browser = browser
    end

    #
    # platform method to navigate to a provided url
    # See PageObject#navigate_to
    #
    def navigate_to(url)
      @browser.goto url
    end

    #
    # platform method to retrieve the text from the current page
    # See PageObject#text
    #
    def text
      @browser.text
    end

    #
    # platform method to retrieve the html for the current page
    # See PageObject#html
    #
    def html
      @browser.html
    end

    #
    # platform method to retrieve the title for the current page
    # See PageObject#title
    #
    def title
      @browser.title
    end

    #
    # platform method to wait for a block to return true
    # See PageObject#wait_until
    def wait_until(timeout, message = nil, &block)
      @browser.wait_until(timeout, message, &block)
    end

    #
    # platform method to handle an alert popup
    # See PageObject#alert
    #
    def alert(&block)
      @browser.alert(&block)
    end

    #
    # platform method to handle a confirm popup
    # See PageObject#confirm
    #
    def confirm(response, &block)
      @browser.confirm(response, &block)
    end

    #
    # platform method to handle a prompt popup
    # See PageObject#prompt
    #
    def prompt(answer, &block)
      @browser.prompt(answer, &block)
    end
    
    #
    # platform method to handle attaching to a running window
    # See PageObject#attach_to_window
    #
    def attach_to_window(identifier, &block)
      win_id = {identifier.keys.first => /#{Regexp.escape(identifier.values.first)}/}
      @browser.window(win_id, &block).use
    end
    
    #
    # platform method to refresh the page
    # See PageObject#refresh
    #
    def refresh
      @browser.refresh
    end<commit_msg>fixed problem with block passed to attach_to_window using Watir<commit_after>require 'watir-webdriver/extensions/alerts'
require 'page-object/elements'
require 'page-object/core_ext/string'


module PageObject
  #
  # Watir implementation of the page object platform driver.  You should not use the
  # class directly.  Instead you should include the PageObject module in your page object
  # and use the methods dynamically added from the PageObject::Accessors module.
  #
  class WatirPageObject
    attr_reader :browser

    def initialize(browser)
      @browser = browser
    end

    #
    # platform method to navigate to a provided url
    # See PageObject#navigate_to
    #
    def navigate_to(url)
      @browser.goto url
    end

    #
    # platform method to retrieve the text from the current page
    # See PageObject#text
    #
    def text
      @browser.text
    end

    #
    # platform method to retrieve the html for the current page
    # See PageObject#html
    #
    def html
      @browser.html
    end

    #
    # platform method to retrieve the title for the current page
    # See PageObject#title
    #
    def title
      @browser.title
    end

    #
    # platform method to wait for a block to return true
    # See PageObject#wait_until
    def wait_until(timeout, message = nil, &block)
      @browser.wait_until(timeout, message, &block)
    end

    #
    # platform method to handle an alert popup
    # See PageObject#alert
    #
    def alert(&block)
      @browser.alert(&block)
    end

    #
    # platform method to handle a confirm popup
    # See PageObject#confirm
    #
    def confirm(response, &block)
      @browser.confirm(response, &block)
    end

    #
    # platform method to handle a prompt popup
    # See PageObject#prompt
    #
    def prompt(answer, &block)
      @browser.prompt(answer, &block)
    end
    
    #
    # platform method to handle attaching to a running window
    # See PageObject#attach_to_window
    #
    def attach_to_window(identifier, &block)
      win_id = {identifier.keys.first => /#{Regexp.escape(identifier.values.first)}/}
      @browser.window(win_id).use &block
    end
    
    #
    # platform method to refresh the page
    # See PageObject#refresh
    #
    def refresh
      @browser.refresh
    end
{'fraction_non_alphanumeric': 0.07100461639920862, 'fraction_numerical': 0.0, 'mean_word_length': 2.5135135135135136, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '6880042', 'n_tokens_mistral': 1327, 'n_tokens_neox': 1292, 'n_words': 431}