博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Frank-Cucumber - Step Definition compendium (转载)
阅读量:5329 次
发布时间:2019-06-14

本文共 3358 字,大约阅读时间需要 11 分钟。

What's this?

This page is intended to act as a place for useful Frank step definitions which aren't quite standard enough to add to the core frank steps. Please feel free to contribute your own useful codez.

Counting specific items displayed on the App

This works for Waseem:

Then /^I should see (.*) apples$/ do |count|  apples = frankly_map( "label marked:'red apples'", 'tag' )  apples.count.should == count.to_iend

Editing a text field using the keyboard

(see for details)

This works for Pete's team:

When /^I use the keyboard to fill in the textfield marked "([^\\"]*)" with "([^\\"]*)"$/ do |text_field_mark, text_to_type|      text_field_selector =  "view marked:'#{
text_field_mark}'" check_element_exists( text_field_selector ) touch( text_field_selector ) frankly_map( text_field_selector, 'setText:', text_to_type ) frankly_map( text_field_selector, 'endEditing:', true ) end

This works for Martin:

When /^I use the keyboard to fill in the textfield marked "([^\\"]*)" with "([^\\"]*)"$/ do |text_field_mark, text_to_type|      text_field_selector =  "view marked:'#{
text_field_mark}'" check_element_exists( text_field_selector ) frankly_map( text_field_selector, 'becomeFirstResponder' ) frankly_map( text_field_selector, 'setText:', text_to_type ) frankly_map( text_field_selector, 'endEditing:', true ) end

Simulating sending text and hitting return on the keyboard

This can be a useful workaround when dealing with the iOS keyboard. Thanks to and James Moore for this one!

def send_command ( command )  %x{osascript<

Resetting the app to first launch state

Given /^I reset the (iphone|ipad) app$/ do |device|  steps "When I quit the simulator"  SDK    = "4.3"  APPLICATIONS_DIR = "/Users/#{
ENV['USER']}/Library/Application Support/iPhone Simulator/#{
SDK}/Applications" USERDEFAULTS_PLIST = "Library/Preferences/com.yourcompany.#{
APPNAME}.dist.plist" Dir.foreach(APPLICATIONS_DIR) do |item| next if item == '.' or item == '..' if File::exists?( "#{
APPLICATIONS_DIR}/#{
item}/#{
USERDEFAULTS_PLIST}") FileUtils.rm "#{
APPLICATIONS_DIR}/#{
item}/#{
USERDEFAULTS_PLIST}" end end steps "Given I launch the #{
device} app"end

Taking a screenshot of the app

Then /^I save a screenshot with prefix (\w+)$/ do |prefix| filename = prefix + Time.now.to_i.to_s %x[screencapture #{
filename}.png]end

Deleting a table view cell

(see for details)

When /^I delete the table view cell marked "([^"]*)"$/ do |mark|  raise "no table view cell marked '#{
mark}' could be found to delete" unless element_exists("tableViewCell label marked:'#{
mark}'") frankly_map( "tableViewCell label marked:'#{
mark}' parent tableViewCell delete", "tag" ) end

Selecting from a UIPickerView

From

When /^I select (\d*)(?:st|nd|rd|th)? row in picker "([^\"]*)"$/ do | row_ordinal, theview|   selector = "view:'UIPickerView' marked:'#{
theview}'" row_index = row_ordinal.to_i - 1 views_switched = frankly_map( selector, 'selectRow:inComponent:animated:', row_index, 0, false ) raise "could not find anything matching [#{
row_ordinal}] to switch" if views_switched.empty? end 转自:https://github.com/moredip/Frank/wiki/Step-Definition-compendium

转载于:https://www.cnblogs.com/simonshi2012/archive/2011/08/31/2160695.html

你可能感兴趣的文章
微软职位内部推荐-Sr. SE - Office incubation
查看>>
微软职位内部推荐-SOFTWARE ENGINEER II
查看>>
centos系统python2.7更新到3.5
查看>>
C#类与结构体究竟谁快——各种函数调用模式速度评测
查看>>
我到底要选择一种什么样的生活方式,度过这一辈子呢:人生自由与职业发展方向(下)...
查看>>
poj 题目分类
查看>>
windows 安装yaml支持和pytest支持等
查看>>
读书笔记:季羡林关于如何做研究学问的心得
查看>>
面向对象的优点
查看>>
套接口和I/O通信
查看>>
阿里巴巴面试之利用两个int值实现读写锁
查看>>
浅谈性能测试
查看>>
Winform 菜单和工具栏控件
查看>>
CDH版本大数据集群下搭建的Hue详细启动步骤(图文详解)
查看>>
巧用Win+R
查看>>
浅析原生js模仿addclass和removeclass
查看>>
Python中的greenlet包实现并发编程的入门教程
查看>>
java中遍历属性字段及值(常见方法)
查看>>
深入理解jQuery框架-框架结构
查看>>
YUI3自动加载树实现
查看>>