Skip to content

Commit

Permalink
Add appium tests
Browse files Browse the repository at this point in the history
  • Loading branch information
HazAT committed Jul 27, 2017
1 parent dbb5bca commit 4311ca1
Show file tree
Hide file tree
Showing 16 changed files with 352 additions and 3 deletions.
15 changes: 12 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,15 @@ Carthage/Checkouts
**/Pods

# Fastlane
fastlane/test_output/
report.xml
.env
appium/fastlane/test_output/
appium/fastlane/report.xml
appium/.env
appium/fastlane/README.md

# Appium

aws
test_bundle.zip
__pycache__
.cache
wheelhouse
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@
[submodule "ios/KSCrash"]
path = ios/KSCrash
url=https://github.com/kstenerud/KSCrash
[submodule "examples"]
path = examples
url = https://github.com/getsentry/examples
9 changes: 9 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
language: objective-c
osx_image: xcode8.3
cache:
- bundler
- pip
script:
- travis_retry .travis/run.sh
notifications:
email: false
4 changes: 4 additions & 0 deletions .travis/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
cd appium
bundle install
make test
2 changes: 2 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
"files.trimTrailingWhitespace": true,
"files.ensureSingleFinalNewline": true,

"python.linting.pylintEnabled": false,

"prettier.bracketSpacing": false,
"prettier.singleQuote": true,
"prettier.printWidth": 90,
Expand Down
10 changes: 10 additions & 0 deletions appium/Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Autogenerated by fastlane
#
# Ensure this file is checked in to source control!

source "https://rubygems.org"

gem 'fastlane'

plugins_path = File.join(File.dirname(__FILE__), 'fastlane', 'Pluginfile')
eval_gemfile(plugins_path) if File.exist?(plugins_path)
150 changes: 150 additions & 0 deletions appium/Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
GEM
remote: https://rubygems.org/
specs:
CFPropertyList (2.3.5)
addressable (2.5.1)
public_suffix (~> 2.0, >= 2.0.2)
aws-sdk (2.10.17)
aws-sdk-resources (= 2.10.17)
aws-sdk-core (2.10.17)
aws-sigv4 (~> 1.0)
jmespath (~> 1.0)
aws-sdk-resources (2.10.17)
aws-sdk-core (= 2.10.17)
aws-sigv4 (1.0.1)
babosa (1.0.2)
claide (1.0.2)
colored (1.2)
colored2 (3.1.2)
commander-fastlane (4.4.5)
highline (~> 1.7.2)
declarative (0.0.9)
declarative-option (0.1.0)
domain_name (0.5.20170404)
unf (>= 0.0.5, < 1.0.0)
dotenv (2.2.1)
excon (0.57.1)
faraday (0.12.2)
multipart-post (>= 1.2, < 3)
faraday-cookie_jar (0.0.6)
faraday (>= 0.7.4)
http-cookie (~> 1.0.0)
faraday_middleware (0.11.0.1)
faraday (>= 0.7.4, < 1.0)
fastimage (2.1.0)
fastlane (2.49.0)
CFPropertyList (>= 2.3, < 3.0.0)
addressable (>= 2.3, < 3.0.0)
babosa (>= 1.0.2, < 2.0.0)
bundler (>= 1.12.0, < 2.0.0)
colored
commander-fastlane (>= 4.4.5, < 5.0.0)
dotenv (>= 2.1.1, < 3.0.0)
excon (>= 0.45.0, < 1.0.0)
faraday (~> 0.9)
faraday-cookie_jar (~> 0.0.6)
faraday_middleware (~> 0.9)
fastimage (>= 2.1.0, < 3.0.0)
gh_inspector (>= 1.0.1, < 2.0.0)
google-api-client (>= 0.12.0, < 0.13.0)
highline (>= 1.7.2, < 2.0.0)
json (< 3.0.0)
mini_magick (~> 4.5.1)
multi_json
multi_xml (~> 0.5)
multipart-post (~> 2.0.0)
plist (>= 3.1.0, < 4.0.0)
rubyzip (>= 1.1.0, < 2.0.0)
security (= 0.1.3)
slack-notifier (>= 1.3, < 2.0.0)
terminal-notifier (>= 1.6.2, < 2.0.0)
terminal-table (>= 1.4.5, < 2.0.0)
tty-screen (~> 0.5.0)
word_wrap (~> 1.0.0)
xcodeproj (>= 1.4.4, < 2.0.0)
xcpretty (>= 0.2.4, < 1.0.0)
xcpretty-travis-formatter (>= 0.0.3)
fastlane-plugin-aws_device_farm (0.3.0)
aws-sdk
gh_inspector (1.0.3)
google-api-client (0.12.0)
addressable (~> 2.5, >= 2.5.1)
googleauth (~> 0.5)
httpclient (>= 2.8.1, < 3.0)
mime-types (~> 3.0)
representable (~> 3.0)
retriable (>= 2.0, < 4.0)
googleauth (0.5.3)
faraday (~> 0.12)
jwt (~> 1.4)
logging (~> 2.0)
memoist (~> 0.12)
multi_json (~> 1.11)
os (~> 0.9)
signet (~> 0.7)
highline (1.7.8)
http-cookie (1.0.3)
domain_name (~> 0.5)
httpclient (2.8.3)
jmespath (1.3.1)
json (2.1.0)
jwt (1.5.6)
little-plugger (1.1.4)
logging (2.2.2)
little-plugger (~> 1.1)
multi_json (~> 1.10)
memoist (0.16.0)
mime-types (3.1)
mime-types-data (~> 3.2015)
mime-types-data (3.2016.0521)
mini_magick (4.5.1)
multi_json (1.12.1)
multi_xml (0.6.0)
multipart-post (2.0.0)
nanaimo (0.2.3)
os (0.9.6)
plist (3.3.0)
public_suffix (2.0.5)
representable (3.0.4)
declarative (< 0.1.0)
declarative-option (< 0.2.0)
uber (< 0.2.0)
retriable (3.0.2)
rouge (2.0.7)
rubyzip (1.2.1)
security (0.1.3)
signet (0.7.3)
addressable (~> 2.3)
faraday (~> 0.9)
jwt (~> 1.5)
multi_json (~> 1.10)
slack-notifier (1.5.1)
terminal-notifier (1.8.0)
terminal-table (1.8.0)
unicode-display_width (~> 1.1, >= 1.1.1)
tty-screen (0.5.0)
uber (0.1.0)
unf (0.1.4)
unf_ext
unf_ext (0.0.7.4)
unicode-display_width (1.3.0)
word_wrap (1.0.0)
xcodeproj (1.5.1)
CFPropertyList (~> 2.3.3)
claide (>= 1.0.2, < 2.0)
colored2 (~> 3.1)
nanaimo (~> 0.2.3)
xcpretty (0.2.8)
rouge (~> 2.0.7)
xcpretty-travis-formatter (0.0.4)
xcpretty (~> 0.2, >= 0.0.7)

PLATFORMS
ruby

DEPENDENCIES
fastlane
fastlane-plugin-aws_device_farm (>= 0.3.0)

BUNDLED WITH
1.15.3
10 changes: 10 additions & 0 deletions appium/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
create-test-bundle:
rm test_bundle.zip | true
zip -r test_bundle.zip tests/ wheelhouse/ requirements.txt conftest.py

install:
cd example; yarn install

test: create-test-bundle install
fastlane aws_device_run_ios
fastlane aws_ios_upload_and_run
26 changes: 26 additions & 0 deletions appium/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import os
import pytest

from appium import webdriver


@pytest.fixture(scope='function')
def driver(request):
app = os.path.abspath('/Users/haza/Library/Developer/Xcode/DerivedData/AwesomeProject-gviruxuketsiseechzzeiucbzkzk/Build/Products/Debug-iphonesimulator/AwesomeProject.app')

screenshot_folder = os.getenv('SCREENSHOT_PATH', '')

desired_caps = {}
if screenshot_folder == '':
desired_caps['platformName'] = 'iOS'
desired_caps['platformVersion'] = '10.3'
desired_caps['deviceName'] = 'iPhone Simulator'
desired_caps['app'] = app

_driver = webdriver.Remote(
command_executor='http://127.0.0.1:4723/wd/hub',
desired_capabilities=desired_caps)

request.addfinalizer(_driver.quit)

return _driver
1 change: 1 addition & 0 deletions appium/example
7 changes: 7 additions & 0 deletions appium/fastlane/Appfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
app_identifier "org.reactjs.native.example.AwesomeProject" # The bundle identifier of your app
apple_id "" # Your Apple email address

team_id "" # Developer Portal Team ID

# you can even provide different app identifiers, Apple IDs and team names per lane:
# More information: https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Appfile.md
65 changes: 65 additions & 0 deletions appium/fastlane/Fastfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
fastlane_version "2.48.0"

default_platform :ios

platform :ios do
before_all do
# ENV["SLACK_URL"] = "https://hooks.slack.com/services/..."

end

desc "Runs all the tests"
lane :test do
scan
end

lane :aws_device_run_ios do
#update_project_team(path: "example/ios/AwesomeProject.xcodeproj")

xcodebuild(
scheme: "AwesomeProject",
project: "example/ios/AwesomeProject.xcodeproj",
destination: "generic/platform=iOS",
configuration: "Release",
derivedDataPath: "aws",
xcargs: "GCC_PREPROCESSOR_DEFINITIONS='AWS_UI_TEST' ENABLE_BITCODE=NO CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO build-for-testing"
)
end

lane :aws_ios_upload_and_run do
# ENV['AWS_ACCESS_KEY_ID'] = ''
# ENV['AWS_SECRET_ACCESS_KEY'] = ''
ENV['AWS_REGION'] = 'us-west-2'

# Transform .app into AWS compatible IPA
aws_device_farm_package(
derrived_data_path: "aws",
configuration: "Release"
)

# RUN tests on AWS Device Farm
aws_device_farm(
name: "react-native",
test_binary_path: "test_bundle.zip",
test_package_type: "APPIUM_PYTHON_TEST_PACKAGE",
test_type: 'APPIUM_PYTHON'
)
end

# You can define as many lanes as you want

after_all do |lane|
# This block is called, only if the executed lane was successful

# slack(
# message: "Successfully deployed new App Update."
# )
end

error do |lane, exception|
# slack(
# message: exception.message,
# success: false
# )
end
end
5 changes: 5 additions & 0 deletions appium/fastlane/Pluginfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Autogenerated by fastlane
#
# Ensure this file is checked in to source control!

gem 'fastlane-plugin-aws_device_farm', '>= 0.3.0'
10 changes: 10 additions & 0 deletions appium/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Appium-Python-Client==0.24
pbr==3.1.1
py==1.4.34
pytest==3.1.3
selenium==3.4.3
six==1.10.0
stevedore==1.24.0
virtualenv==15.1.0
virtualenv-clone==0.2.6
virtualenvwrapper==4.7.2
37 changes: 37 additions & 0 deletions appium/tests/test_ios.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import os
import json

from time import sleep

def test_send_message(driver):
driver.find_element_by_accessibility_id('send message').click()

sleep(1)

value = driver.find_element_by_accessibility_id('textarea').get_attribute("value")
event = json.loads(value)

assert len(event['breadcrumbs']) > 0
assert len(event['contexts']) > 0
assert event['message'] == 'TEST message'
assert event['extra']['react']
assert event['tags']['react'] == '1'
assert len(event['user']) > 0
#assert value == 'button3'

# def test_scroll(self):
# els = self.driver.find_elements_by_class_name('XCUIElementTypeButton')
# els[5].click()

# sleep(1)
# try:
# el = self.driver.find_element_by_accessibility_id('Allow')
# el.click()
# sleep(1)
# except:
# pass

# el = self.driver.find_element_by_xpath('//XCUIElementTypeMap[1]')

# location = el.location
# self.driver.swipe(start_x=location['x'], start_y=location['y'], end_x=0.5, end_y=location['y'], duration=800)
1 change: 1 addition & 0 deletions examples
Submodule examples added at c637c2

0 comments on commit 4311ca1

Please sign in to comment.