-
Notifications
You must be signed in to change notification settings - Fork 24
text_field
text_field api should be used as below in screen objects.
text_field(:logical_name,Locator)
logical_name is a name to uniquely represent a button.
locator could be name, id, accessibility id ,xpath etc.. locators are assigned to object by developers during design.
####Below methods are automatically created by using the above command
Below method is used to get the text from text field
logical_name
Below method checks for the existence of the text field. returns true or false
logical_name?
Below method is used to enter value in text field
logical_name=argument
Below method is used to clear the value in the text field
clear_logical_name
Below method returns the value on the screen for this text field
logical_name_value
####Example:
If I have a 'username' text field on the screen/page, I would define as below
text_field(:username,"xpath~//UITextField")
Below methods are automatically created
username
username_text?
username=argument
clear_username
username_value
Usage example in a screen object
class Login
text_field(:username,"xpath~//UITextField")
# DSL to retrieve text of the attribute text for username text field.
def get_username_text_field
username # This will return text of attribute 'text' for username text field.
end
# DSL to check existence of username text_field
def check_username_text_field
username? # This will return true or false based on existence of username text field.
end
# DSL for entering text in username text field.
def set_username_text_field(username)
self.username=username # This method will enter text into username text field.
end
# DSL to clear pre populated text from username text field.
def clear_username_text_field
clear_username # This will clear the text of username text field.
end
# DSL to retrieve text for value attribute.
def value_username_text_field
username_value # This will return the text of 'value' attribute.
end
end