Skip to content

Instantly share code, notes, and snippets.

@bootstraponline
Forked from jmieleiii/page_helper.rb
Created June 26, 2014 14:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bootstraponline/3687e567b1008a6af944 to your computer and use it in GitHub Desktop.
Save bootstraponline/3687e567b1008a6af944 to your computer and use it in GitHub Desktop.
def desired_caps
{
caps: {
:'appium-version' => '1.1.0',
platformName: 'Android',
platformVersion: '4.2.2',
deviceName: 'Android Emulator',
app: '<path>'
#app: '<alternate_path>'
},
appium_lib: {
wait: 20
}
}
end
def startup(device, screenshot_suffix)
Appium::Driver.new(desired_caps).start_driver
Appium.promote_appium_methods self.class
instantiate_page_objects($driver) # calls a function that instantiates each page class, eg @LandingPage = AndroidLandingPage.new(driver)
end
def teardown
driver_quit
end
def do_swipe
window = $driver.window_size
$driver.swipe(
start_x: window.width - 5,
start_y: window.height/2,
end_x: window.width/2,
end_y: window.height/2,
duration: 1000,
)
end
require "rubygems"
require "bundler/setup"
require "rspec"
require "appium_lib"
require File.expand_path(File.dirname(__FILE__) + "/shared_functions.rb")
Dir[File.expand_path(File.dirname(__FILE__) + "/lib/*.rb")].each { |file| require file } # class files
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe "spec_one" do
before(:all) do
startup
end
after(:all) do
teardown
end
context "context" do
it "should swipe"
do_swipe # succeeds
end
end
end
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe "spec_one" do
before(:all) do
startup
end
after(:all) do
teardown
end
context "context" do
it "should swipe"
do_swipe # fails with NoMethodError
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment