def button(name, locator)

        # generates method for clicking button.
        # this method will not return any value.
        # @example click on 'Submit' button.
        # button(:login_button,"xpath~//UIButtonField")
        # def click_login_button
        #  login_button # This will click on the button.
        # end
        define_method(name) do
          ScreenObject::AppElements::Button.new(locator).tap
        end

        # generates method for checking the existence of the button.
        # this method will return true or false based on object displayed or not.
        # @example check if 'Submit' button exists on the screen.
        # button(:login_button,"xpath~//UIButtonField")
        # DSL to check existence of login button
        # def check_login_button
        #  login_button?  # This will return true or false based on existence of button.
        # end
        define_method("#{name}?") do
          ScreenObject::AppElements::Button.new(locator).exists?
        end

        # generates method for checking if button is enabled.
        # this method will return true if button is enabled otherwise false.
        # @example check if 'Submit' button enabled on the screen.
        # button(:login_button,"xpath~//UIButtonField")
        # DSL to check if button is enabled or not
        # def enable_login_button
        # login_button_enabled? # This will return true or false if button is enabled or disabled.
        # end
        define_method("#{name}_enabled?") do
          ScreenObject::AppElements::Button.new(locator).enabled?
        end

        # generates method for getting text for value attribute.
        # this method will return the text containing into value attribute.
        # @example To retrieve text from value attribute of the defined object i.e. 'Submit' button.
        # button(:login_button,"xpath~//UIButtonField")
        # DSL to retrieve text for value attribute.
        # def value_login_button
        #  login_button_value  # This will return the text of the value attribute of the 'Submit' button object.
        # end
        define_method("#{name}_value") do
          ScreenObject::AppElements::Button.new(locator).value
        end

        # generates method for scrolling on the screen and click on the button.
        # this should be used for iOS platform.
        # scroll to the first element with exact target static text or name.
        # this method will not return any value.
        # button(:login_button,"xpath~//UIButtonField")
        # def scroll_button
        #  login_button_scroll # This will not return any value. It will scroll on the screen until object found and click
        #                        on the object i.e. button. This is iOS specific method and should not be used for android application
        # end
        define_method("#{name}_scroll") do
          # direction = options[:direction] || 'down'
          ScreenObject::AppElements::Button.new(locator).scroll_for_element_click
        end

        # generates method for scrolling on iOS application screen and click on button. This method should be used when button text is dynamic..
        # this should be used for iOS platform.
        # scroll to the first element with exact target dynamic text or name.
        # this method will not return any value.
        # @param [text] is the actual text of the button containing.
        # DSL to scroll on iOS application screen and click on button. This method should be used when button text is dynamic..
        # button(:login_button,"UIButtonField")  # button API should have class name as shown in this example.
        # OR
        # button(:login_button,"UIButtonField/UIButtonFieldtext")  # button API should have class name as shown in this example.
        # def scroll_button
        #   login_button_scroll_dynamic(text)    # This will not return any value. we need to pass button text or name as parameter.
        #                                          It will scroll on the screen until object with same name found and click on
        #                                          the object i.e. button. This is iOS specific method and should not be used
        #                                          for android application.
        # end
        define_method("#{name}_scroll_dynamic") do |text|
          # direction = options[:direction] || 'down'
          ScreenObject::AppElements::Button.new(locator).scroll_for_dynamic_element_click(text)
        end

        # generates method for scrolling on Android application screen and click on button. This method should be used when button text is static...
        # this should be used for Android platform.
        # scroll to the first element containing target static text or name.
        # this method will not return any value.
        # DSL to scroll on Android application screen and click on button. This method should be used when button text is static...
        # @param [text] is the actual text of the button containing.
        # button(:login_button,"xpath~//UIButtonField")
        # def scroll_button
        #   login_button_scroll_(text)  # This will not return any value. we need to pass button text or
        #                                 name[containing targeted text or name] as parameter.It will scroll on the
        #                                 screen until object with same name found and click on the
        #                                 object i.e. button. This is Android specific method and should not be used
        #                                 for iOS application. This method matches with containing text for the
        #                                 button on the screen and click on it.
        # end
        define_method("#{name}_scroll_") do |text|
          ScreenObject::AppElements::Button.new(locator).click_text(text)
        end

        # generates method for scrolling on Android application screen and click on button. This method should be used when button text is dynamic......
        # this should be used for Android platform.
        # scroll to the first element containing target dynamic text or name.
        # this method will not return any value.
        # DSL to scroll on Android application screen and click on button. This method should be used when button text is dynamic......
        # @param [text] is the actual text of the button containing.
        # button(:login_button,"UIButtonField")  # button API should have class name as shown in this example.
        # OR
        # button(:login_button,"UIButtonField/UIButtonFieldtext")  # button API should have class name as shown in this example.
        #
        # def scroll_button
        #   login_button_scroll_dynamic_(text) # This will not return any value. we need to pass button text or name
        #                                        [containing targeted text or name] as parameter.It will scroll on the screen
        #                                        until object with same name found and click on the object i.e. button.
        #                                        This is Android specific method and should not be used for iOS application.
        #                                        This method matches with containing text for the button on the screen and click on it.
        #
        # end
        define_method("#{name}_scroll_dynamic_") do |text|
          ScreenObject::AppElements::Button.new(locator).click_dynamic_text(text)
        end

        # generates method for scrolling on the screen and click on the button.
        # this should be used for Android platform.
        # scroll to the first element with exact target static text or name.
        # this method will not return any value.
        # DSL to scroll on Android application screen and click on button. This method should be used when button text is static. it matches with exact text.
        # @param [text] is the actual text of the button containing.
        # button(:login_button,"xpath~//UIButtonField")
        # def scroll_button
        #   login_button_scroll_exact_(text)       # This will not return any value. we need to pass button text or name
        #                                            [EXACT text or name] as parameter. It will scroll on the screen until
        #                                            object with same name found and click on the object i.e. button.
        #                                            This is Android specific method and should not be used for iOS application.
        #                                            This method matches with exact text for the button on the screen and click on it.
        #
        # end
        define_method("#{name}_scroll_exact_") do |text|
          ScreenObject::AppElements::Button.new(locator).click_exact_text(text)
        end

        #generates method for scrolling on the screen and click on the button.
        #This should be used for Android platform.
        # Scroll to the first element with exact target dynamic text or name.
        # this method will not return any value.
        # DSL to scroll on Android application screen and click on button. This method should be used when button text is dynamic. it matches with exact text.
        # @param [text] is the actual text of the button containing.
        # button(:login_button,"UIButtonField")  # button API should have class name as shown in this example.
        # OR
        # button(:login_button,"UIButtonField/UIButtonFieldtext")  # button API should have class name as shown in this example.
        # def scroll_button
        #   login_button_scroll_dynamic_exact_(text) # This will not return any value. we need to pass button text or name
        #                                             [EXACT text or name] as parameter. It will scroll on the screen until object
        #                                             with same name found and click on the object i.e. button. This is Android specific
        #                                             method and should not be used for iOS application. This method matches with exact
        #                                             text for the button on the screen and click on it.
        #
        # end
        define_method("#{name}_scroll_dynamic_exact_") do |text|
          ScreenObject::AppElements::Button.new(locator).click_dynamic_exact_text(text)
        end

    end
def button(name, locator)

        # generates method for clicking button.
        # this method will not return any value.
        # @example click on 'Submit' button.
        # button(:login_button,"xpath~//UIButtonField")
        # def click_login_button
        #  login_button # This will click on the button.
        # end
        define_method(name) do
          ScreenObject::AppElements::Button.new(locator).tap
        end

        # generates method for checking the existence of the button.
        # this method will return true or false based on object displayed or not.
        # @example check if 'Submit' button exists on the screen.
        # button(:login_button,"xpath~//UIButtonField")
        # DSL to check existence of login button
        # def check_login_button
        #  login_button?  # This will return true or false based on existence of button.
        # end
        define_method("#{name}?") do
          ScreenObject::AppElements::Button.new(locator).exists?
        end

        # generates method for checking if button is enabled.
        # this method will return true if button is enabled otherwise false.
        # @example check if 'Submit' button enabled on the screen.
        # button(:login_button,"xpath~//UIButtonField")
        # DSL to check if button is enabled or not
        # def enable_login_button
        # login_button_enabled? # This will return true or false if button is enabled or disabled.
        # end
        define_method("#{name}_enabled?") do
          ScreenObject::AppElements::Button.new(locator).enabled?
        end

        # generates method for getting text for value attribute.
        # this method will return the text containing into value attribute.
        # @example To retrieve text from value attribute of the defined object i.e. 'Submit' button.
        # button(:login_button,"xpath~//UIButtonField")
        # DSL to retrieve text for value attribute.
        # def value_login_button
        #  login_button_value  # This will return the text of the value attribute of the 'Submit' button object.
        # end
        define_method("#{name}_value") do
          ScreenObject::AppElements::Button.new(locator).value
        end

        # generates method for scrolling on the screen and click on the button.
        # this should be used for iOS platform.
        # scroll to the first element with exact target static text or name.
        # this method will not return any value.
        # button(:login_button,"xpath~//UIButtonField")
        # def scroll_button
        #  login_button_scroll # This will not return any value. It will scroll on the screen until object found and click
        #                        on the object i.e. button. This is iOS specific method and should not be used for android application
        # end
        define_method("#{name}_scroll") do
          # direction = options[:direction] || 'down'
          ScreenObject::AppElements::Button.new(locator).scroll_for_element_click
        end

        # generates method for scrolling on iOS application screen and click on button. This method should be used when button text is dynamic..
        # this should be used for iOS platform.
        # scroll to the first element with exact target dynamic text or name.
        # this method will not return any value.
        # @param [text] is the actual text of the button containing.
        # DSL to scroll on iOS application screen and click on button. This method should be used when button text is dynamic..
        # button(:login_button,"UIButtonField")  # button API should have class name as shown in this example.
        # OR
        # button(:login_button,"UIButtonField/UIButtonFieldtext")  # button API should have class name as shown in this example.
        # def scroll_button
        #   login_button_scroll_dynamic(text)    # This will not return any value. we need to pass button text or name as parameter.
        #                                          It will scroll on the screen until object with same name found and click on
        #                                          the object i.e. button. This is iOS specific method and should not be used
        #                                          for android application.
        # end
        define_method("#{name}_scroll_dynamic") do |text|
          # direction = options[:direction] || 'down'
          ScreenObject::AppElements::Button.new(locator).scroll_for_dynamic_element_click(text)
        end

        # generates method for scrolling on Android application screen and click on button. This method should be used when button text is static...
        # this should be used for Android platform.
        # scroll to the first element containing target static text or name.
        # this method will not return any value.
        # DSL to scroll on Android application screen and click on button. This method should be used when button text is static...
        # @param [text] is the actual text of the button containing.
        # button(:login_button,"xpath~//UIButtonField")
        # def scroll_button
        #   login_button_scroll_(text)  # This will not return any value. we need to pass button text or
        #                                 name[containing targeted text or name] as parameter.It will scroll on the
        #                                 screen until object with same name found and click on the
        #                                 object i.e. button. This is Android specific method and should not be used
        #                                 for iOS application. This method matches with containing text for the
        #                                 button on the screen and click on it.
        # end
        define_method("#{name}_scroll_") do |text|
          ScreenObject::AppElements::Button.new(locator).click_text(text)
        end

        # generates method for scrolling on Android application screen and click on button. This method should be used when button text is dynamic......
        # this should be used for Android platform.
        # scroll to the first element containing target dynamic text or name.
        # this method will not return any value.
        # DSL to scroll on Android application screen and click on button. This method should be used when button text is dynamic......
        # @param [text] is the actual text of the button containing.
        # button(:login_button,"UIButtonField")  # button API should have class name as shown in this example.
        # OR
        # button(:login_button,"UIButtonField/UIButtonFieldtext")  # button API should have class name as shown in this example.
        #
        # def scroll_button
        #   login_button_scroll_dynamic_(text) # This will not return any value. we need to pass button text or name
        #                                        [containing targeted text or name] as parameter.It will scroll on the screen
        #                                        until object with same name found and click on the object i.e. button.
        #                                        This is Android specific method and should not be used for iOS application.
        #                                        This method matches with containing text for the button on the screen and click on it.
        #
        # end
        define_method("#{name}_scroll_dynamic_") do |text|
          ScreenObject::AppElements::Button.new(locator).click_dynamic_text(text)
        end

        # generates method for scrolling on the screen and click on the button.
        # this should be used for Android platform.
        # scroll to the first element with exact target static text or name.
        # this method will not return any value.
        # DSL to scroll on Android application screen and click on button. This method should be used when button text is static. it matches with exact text.
        # @param [text] is the actual text of the button containing.
        # button(:login_button,"xpath~//UIButtonField")
        # def scroll_button
        #   login_button_scroll_exact_(text)       # This will not return any value. we need to pass button text or name
        #                                            [EXACT text or name] as parameter. It will scroll on the screen until
        #                                            object with same name found and click on the object i.e. button.
        #                                            This is Android specific method and should not be used for iOS application.
        #                                            This method matches with exact text for the button on the screen and click on it.
        #
        # end
        define_method("#{name}_scroll_exact_") do |text|
          ScreenObject::AppElements::Button.new(locator).click_exact_text(text)
        end

        #generates method for scrolling on the screen and click on the button.
        #This should be used for Android platform.
        # Scroll to the first element with exact target dynamic text or name.
        # this method will not return any value.
        # DSL to scroll on Android application screen and click on button. This method should be used when button text is dynamic. it matches with exact text.
        # @param [text] is the actual text of the button containing.
        # button(:login_button,"UIButtonField")  # button API should have class name as shown in this example.
        # OR
        # button(:login_button,"UIButtonField/UIButtonFieldtext")  # button API should have class name as shown in this example.
        # def scroll_button
        #   login_button_scroll_dynamic_exact_(text) # This will not return any value. we need to pass button text or name
        #                                             [EXACT text or name] as parameter. It will scroll on the screen until object
        #                                             with same name found and click on the object i.e. button. This is Android specific
        #                                             method and should not be used for iOS application. This method matches with exact
        #                                             text for the button on the screen and click on it.
        #
        # end
        define_method("#{name}_scroll_dynamic_exact_") do |text|
          ScreenObject::AppElements::Button.new(locator).click_dynamic_exact_text(text)
        end

    end
Button class generates all the methods related to different operations that can be performed on the button.