require_relative 'methods/required_files' Given(/^I have App running with appium$/) do # Make sure you have started appium server end # Wait for the specific time When /^I wait for (\d+) seconds$/ do |second| sleep(second.to_i) end And /^I input text "(.*)" on "(.*)"$/ do |text,object| execute_settext(object,text) end And /^I click on "(.*)"$/ do |object| execute_click object end Then /^I verify property "(.*)" with "(.*)" has( | not)? value "(.*)"$/ do |object, property, negate, value| sleep(0.5) value = var_collect(value) execute_checkproperty(object, property, negate, value) end Given /^I click on element with x: "(.*)", y: "(.*)"$/ do |x,y| click_by_coordinate x,y end And /^I scroll the screen from startX (\d+) startY (\d+) to endX (\d+) endY (\d+) and millisecond timeout is (\d+)$/ do |startX, startY, endX, endY, timeout| selenium.swipe(start_x: startX, start_y: startY, end_x: endX, end_y: endY, duration: timeout) end Given /^I get attribute of element "(.*)"$/ do |element| found_element = find_object element actual_value = found_element.attribute("name") puts actual_value end # And /^I rotate device to (landscape|portrait)$/ do |type| # case type.to_sym # when :landscape # $driver.rotate :landscape # when :portrait # $driver.rotate :portrait # else # raise "ERROR: *** unknown rotate type" # end # end And /^I accept alert$/ do selenium.alert_accept end And /^I dismiss alert$/ do selenium.alert_dismiss end And /^I hide the keyboard$/ do selenium.hide_keyboard end Then(/^I tap on back button of device$/) do navigate('back') end Then(/^I tap on forward button of device$/) do navigate('forward') end # #---------- Swipe with direction # Then(/^I swipe left$/) do # swipe_direction("left") # end # # Then(/^I swipe right$/) do # swipe_direction("right") # end # # Then(/^I swipe up$/) do # swipe_direction("up") # end # # Then(/^I swipe down$/) do # swipe_direction("down") # end Then(/^I long tap on element having "(.*?)"$/) do |element| long_press_on_element_default_duration(element) end Then(/^I long tap on element having (.+) "(.*?)" for "(.*?)" sec$/) do |element, duration| long_press_on_element_with_duration(element, duration) end Then(/^I long tap on co\-ordinate "(.*?)","(.*?)"$/) do |x, y| long_press_on_coordinates(x, y) end Then(/^I long tap on co\-ordinate "(.*?)","(.*?)" for "(.*?)" sec$/) do |x, y, duration| long_press_on_coordinates_with_duration(x, y, duration) end Then(/^I close app$/) do close_app end Then(/^I launch app$/) do launch_app end Then(/^I reset app$/) do reset_app end And /^I set app to run background within (\d+)$/ do |seconds| selenium.background_app seconds end And /^I press button (\d+)$/ do |button_index| # Find a button by index button(button_index.to_i).click end Given /^I set text "(.*)" on filed index (\d+)$/ do |value, field| # Get a textfield by index textfield(field.to_i).type value end ################## List of Steps support Android only##################### Given /^I scroll to text "(.*)" Android$/ do |text| scroll_to(text) end And /^I go home screen Android$/ do move_home end And /^I delete an character on Android$/ do delete_an_character_android end And /^I take a photo on Android$/ do take_photo_android end