<commit_before># encoding: utf-8
require File.expand_path("../spec_helper", __FILE__)

describe "Button" do

  before :each do
    browser.goto(WatirSpec.url_for("forms_with_input_elements.html"))
  end

  # Exists method
  describe "#exists?" do
    it "returns true if the button exists (tag = :input)" do
      browser.button(:id, "new_user_submit").should exist
      browser.button(:id, /new_user_submit/).should exist
      browser.button(:name, "new_user_reset").should exist
      browser.button(:name, /new_user_reset/).should exist
      browser.button(:value, "Button 2").should exist
      browser.button(:value, /Button 2/).should exist
      not_compliant_on :internet_explorer do
        browser.button(:src, "images/button.png").should exist
      end
      browser.button(:src, /button\.png/).should exist
      browser.button(:text, "Button 2").should exist
      browser.button(:text, /Button 2/).should exist
      browser.button(:class, "image").should exist
      browser.button(:class, /image/).should exist
      browser.button(:index, 0).should exist
      browser.button(:xpath, "//input[@id='new_user_submit']").should exist
      browser.button(:alt, "Create a new user").should exist
      browser.button(:alt, /Create a/).should exist
    end

    bug "https://github.com/watir/watir-webdriver/issues/208" do
      it "returns true if the button exists (tag = :button)" do
        browser.button(:name, "new_user_button_2").should exist
        browser.button(:name, /new_user_button_2/).should exist
        browser.button(:value, "button_2").should exist
        browser.button(:value, /button_2/).should exist
        browser.button(:text, 'Button 2').should exist
        browser.button(:text, /Button 2/).should exist
      end
    end

    it "returns true if the button exists (how = :caption)" do
      browser.button(:caption, "Button 2").should exist
      browser.button(:caption, /Button 2/).should exist
    end

    it "returns the first button if given no args" do
      browser.button.should exist
    end

    it "returns true for element with upper case type" do
      browser.button(:id, "new_user_button_preview").should exist
    end

    it "returns false if the button doesn't exist" do
      browser.button(:id, "no_such_id").should_not exist
      browser.button(:id, /no_such_id/).should_not exist
      browser.button(:name, "no_such_name").should_not exist
      browser.button(:name, /no_such_name/).should_not exist
      browser.button(:value, "no_such_value").should_not exist
      browser.button(:value, /no_such_value/).should_not exist
      browser.button(:src, "no_such_src").should_not exist
      browser.button(:src, /no_such_src/).should_not exist<commit_msg>buttons are properly located with :value<commit_after># encoding: utf-8
require File.expand_path("../spec_helper", __FILE__)

describe "Button" do

  before :each do
    browser.goto(WatirSpec.url_for("forms_with_input_elements.html"))
  end

  # Exists method
  describe "#exists?" do
    it "returns true if the button exists (tag = :input)" do
      browser.button(:id, "new_user_submit").should exist
      browser.button(:id, /new_user_submit/).should exist
      browser.button(:name, "new_user_reset").should exist
      browser.button(:name, /new_user_reset/).should exist
      browser.button(:value, "Button").should exist
      browser.button(:value, /Button/).should exist
      not_compliant_on :internet_explorer do
        browser.button(:src, "images/button.png").should exist
      end
      browser.button(:src, /button\.png/).should exist
      browser.button(:text, "Button 2").should exist
      browser.button(:text, /Button 2/).should exist
      browser.button(:class, "image").should exist
      browser.button(:class, /image/).should exist
      browser.button(:index, 0).should exist
      browser.button(:xpath, "//input[@id='new_user_submit']").should exist
      browser.button(:alt, "Create a new user").should exist
      browser.button(:alt, /Create a/).should exist
    end

    it "returns true if the button exists (tag = :button)" do
      browser.button(:name, "new_user_button_2").should exist
      browser.button(:name, /new_user_button_2/).should exist
      browser.button(:value, "button_2").should exist
      browser.button(:value, /button_2/).should exist
      browser.button(:text, 'Button 2').should exist
      browser.button(:text, /Button 2/).should exist
    end

    it "returns true if the button exists (how = :caption)" do
      browser.button(:caption, "Button 2").should exist
      browser.button(:caption, /Button 2/).should exist
    end

    it "returns the first button if given no args" do
      browser.button.should exist
    end

    it "returns true for element with upper case type" do
      browser.button(:id, "new_user_button_preview").should exist
    end

    it "returns false if the button doesn't exist" do
      browser.button(:id, "no_such_id").should_not exist
      browser.button(:id, /no_such_id/).should_not exist
      browser.button(:name, "no_such_name").should_not exist
      browser.button(:name, /no_such_name/).should_not exist
      browser.button(:value, "no_such_value").should_not exist
      browser.button(:value, /no_such_value/).should_not exist
      browser.button(:src, "no_such_src").should_not exist
      browser.button(:src, /no_such_src/).should_not exist
{'fraction_non_alphanumeric': 0.12601927353595255, 'fraction_numerical': 0.005374351371386212, 'mean_word_length': 3.373581847649919, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 1, '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': '3895626', 'n_tokens_mistral': 1626, 'n_tokens_neox': 1581, 'n_words': 406}