Landing page specs for iCanvas and SpeedGrader for iOS apps
twilson, panda, 4 - added shared examples for iCanvas and SpeedGrader landing page - minor changes to appium environment setup, school_domain now defined in selenium.yml file - to test: comment/uncomment appium init and skip statements in mobile_common, spin up Appium server, create and edit yml file, and run specs Change-Id: Ica180895f167e007cab14cadfe79e554a44f25da Reviewed-on: https://gerrit.instructure.com/61118 Reviewed-by: Heath Hales <hhales@instructure.com> Reviewed-by: Steven Shepherd <sshepherd@instructure.com> Tested-by: Jenkins Product-Review: Ben Bolton <bbolton@instructure.com> QA-Review: Ben Bolton <bbolton@instructure.com>
This commit is contained in:
parent
228408666b
commit
f64a4fe5bd
|
@ -5,6 +5,9 @@ test:
|
|||
paths:
|
||||
# setting path works for opera, chrome, and firefox
|
||||
# firefox: "/Applications/Firefox7.app/Contents/MacOS/firefox"
|
||||
school_domain:
|
||||
# URL to Canvas environment
|
||||
# "twilson"
|
||||
appium_host_url:
|
||||
# setting path for test server
|
||||
# "10.0.15.242"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
require_relative '../../../helpers/landing_page_common'
|
||||
|
||||
describe 'speedgrader landing page' do
|
||||
describe 'speedgrader for android landing page' do
|
||||
include_examples 'in-process server selenium tests'
|
||||
include_context 'appium mobile specs', 'speedgrader_android'
|
||||
let(:default_url){ 'myschool.instructure.com' }
|
||||
|
|
|
@ -17,6 +17,11 @@ module EnvironmentSetup
|
|||
@appium_dev_key
|
||||
end
|
||||
|
||||
# TODO: update when Appium is integrated with Jenkins, append $server_port
|
||||
def school_domain
|
||||
$selenium_config[:school_domain]
|
||||
end
|
||||
|
||||
# Static IP addresses entered into Mobile Verify. Comment/Uncomment to set the url.
|
||||
# Mobile Apps will not connect to local test instances other than these.
|
||||
def host_url
|
||||
|
|
|
@ -0,0 +1,129 @@
|
|||
require_relative '../../mobile_common'
|
||||
|
||||
# ======================================================================================================================
|
||||
# Log In / Out of Mobile App
|
||||
# ======================================================================================================================
|
||||
|
||||
def icanvas_init(username, password, course_name)
|
||||
enter_school
|
||||
login_mobile(username, password)
|
||||
dismiss_user_polling
|
||||
navigate_to_course(course_name)
|
||||
end
|
||||
|
||||
def enter_school
|
||||
find_ele_by_attr('UIATextField', 'value', 'Find your school or district').send_keys(@school)
|
||||
visible_buttons = buttons
|
||||
if visible_buttons.size == 1
|
||||
visible_buttons[0].click
|
||||
else
|
||||
visible_buttons[1].click
|
||||
end
|
||||
wait_true(timeout: 10, interval: 0.100){ tag('UIASecureTextField') }
|
||||
end
|
||||
|
||||
def provide_credentials(username, password)
|
||||
email = tag('UIATextField')
|
||||
email.click
|
||||
email.send_keys(username)
|
||||
pw = tag('UIASecureTextField')
|
||||
pw.click
|
||||
pw.send_keys(password)
|
||||
button_exact('Log In').click
|
||||
end
|
||||
|
||||
def login_mobile(username, password)
|
||||
provide_credentials(username, password)
|
||||
wait_true(timeout: 10, interval: 0.250){ text_exact('Canvas for iOS') }
|
||||
button_exact('Log In').click
|
||||
end
|
||||
|
||||
# ==== Parameters
|
||||
# change_user: App settings for multi-user access must be enabled if change_user is true
|
||||
# If multi-user is disabled, change_user must be false
|
||||
def logout(change_user)
|
||||
if icanvas_app
|
||||
navigate_to('Logout')
|
||||
if change_user
|
||||
find_element(:id, 'Change User').click
|
||||
else
|
||||
find_elements(:id, 'Logout')[1].click
|
||||
end
|
||||
else # speedgrader
|
||||
first_button.click # hamburger
|
||||
find_element(:id, 'Logout').click
|
||||
end
|
||||
end
|
||||
|
||||
# This assumes the app is on the landing page.
|
||||
def logout_all_users
|
||||
while exists{ find_element(:id, 'icon x delete') }
|
||||
find_element(:id, 'icon x delete').click
|
||||
end
|
||||
end
|
||||
|
||||
# ======================================================================================================================
|
||||
# Navigation
|
||||
# ======================================================================================================================
|
||||
|
||||
def goto_courses_root
|
||||
# tap twice to guarantee root view
|
||||
button_exact('Courses').click
|
||||
button_exact('Courses').click
|
||||
end
|
||||
|
||||
# TODO: add support for Speedgrader
|
||||
def navigate_to_course(course_name)
|
||||
if icanvas_app
|
||||
# Double tap should navigate to root courses view
|
||||
wait_true(timeout: 10, interval: 0.250){ button_exact('Courses') }
|
||||
goto_courses_root
|
||||
scroll_to_element(
|
||||
scroll_view: tag('UIACollectionView'),
|
||||
id: course_name,
|
||||
time: 1000,
|
||||
direction: 'down',
|
||||
attempts: 2
|
||||
).click
|
||||
end
|
||||
end
|
||||
|
||||
def navigate_to(location, opts = {course_name: ios_course_name})
|
||||
case location
|
||||
when 'My Files', 'About', 'Help', 'Logout'
|
||||
goto_courses_root
|
||||
find_element(:name, 'Profile').click
|
||||
find_element(:name, location).click
|
||||
when 'Calendar', 'To Do List', 'Notifications', 'Messages'
|
||||
button_exact(location).click
|
||||
else
|
||||
navigate_to_course(opts[:course_name])
|
||||
find_element(:name, location).click
|
||||
end
|
||||
end
|
||||
|
||||
# ======================================================================================================================
|
||||
# General
|
||||
# ======================================================================================================================
|
||||
|
||||
def double_tap(element)
|
||||
element.click
|
||||
element.click
|
||||
end
|
||||
|
||||
def device_is_iphone
|
||||
$selenium_config[:ios_type] == 'iPhone'
|
||||
end
|
||||
|
||||
def device_is_ipad
|
||||
$selenium_config[:ios_type] == 'iPad'
|
||||
end
|
||||
|
||||
def dismiss_user_polling
|
||||
begin
|
||||
find_element(:id, 'How do you like Canvas?')
|
||||
find_element(:id, 'Ask me later').click
|
||||
rescue => ex
|
||||
raise ex unless ex.is_a?(Selenium::WebDriver::Error::NoSuchElementError)
|
||||
end
|
||||
end
|
|
@ -0,0 +1,106 @@
|
|||
require_relative 'ios_common'
|
||||
|
||||
# ======================================================================================================================
|
||||
# Shared Examples for iCanvas and Speedgrader Mobile Apps
|
||||
# ======================================================================================================================
|
||||
|
||||
shared_examples 'icanvas and speedgrader landing page' do |app_name|
|
||||
before(:all) do
|
||||
logout_all_users
|
||||
end
|
||||
|
||||
it 'displays a landing page', priority: "1", test_id: pick_test_id_for_app(app_name, 9779, 303715) do
|
||||
expect(find_ele_by_attr('UIATextField', 'value', 'Find your school or district')).to be_displayed
|
||||
|
||||
help_button = open_help_menu(app_name)
|
||||
verify_help_menu(true)
|
||||
close_help_menu(help_button)
|
||||
verify_help_menu(false)
|
||||
end
|
||||
|
||||
it 'routes to find school domain help page', priority: "1", test_id: pick_test_id_for_app(app_name, 235571, 303716) do
|
||||
open_help_menu(app_name)
|
||||
verify_help_menu(true)
|
||||
button_exact('Find School Domain').click
|
||||
verify_help_menu(false)
|
||||
|
||||
expect(find_element(:id, 'Back')).not_to be_displayed
|
||||
expect(find_element(:id, 'Help')).to be_displayed
|
||||
expect(find_element(:id, 'Done')).to be_displayed
|
||||
|
||||
wait_true(timeout: 10, interval: 0.100){ text_exact('How do I find my institution\'s URL to access Canvas apps on my mobile device?') }
|
||||
|
||||
button_exact('Done').click
|
||||
end
|
||||
|
||||
context 'entering school url' do
|
||||
let(:school_name){ 'Utah Education Network'}
|
||||
let(:school_url){ 'uen.instructure.com'}
|
||||
let(:minimum_list_size){ 4 }
|
||||
|
||||
after(:each) do
|
||||
find_element(:id, 'Cancel').click
|
||||
wait_true(timeout: 10, interval: 0.250){ expect(find_ele_by_attr('UIATextField', 'value', 'Find your school or district')).to be_displayed }
|
||||
end
|
||||
|
||||
it 'lists possible schools when entering url and routes to school', priority: "1", test_id: pick_test_id_for_app(app_name, 235572, 303717) do
|
||||
find_school_text = find_ele_by_attr('UIATextField', 'value', 'Find your school or district')
|
||||
expect(tags('UIATableCell').size).to be 0
|
||||
|
||||
# Sending any key should generate a list of possible school
|
||||
find_school_text.send_keys(school_name.split[0])
|
||||
school_list = tags('UIATableCell')
|
||||
expect(school_list.size).to be > minimum_list_size
|
||||
|
||||
# Click on auto-generated text
|
||||
text_exact(school_name).click
|
||||
wait_true(timeout: 10, interval: 0.250){ find_element(:id, school_url) }
|
||||
end
|
||||
|
||||
it 'routes to school login page when school is typed in', priority: "1", test_id: pick_test_id_for_app(app_name, 235573, 303718) do
|
||||
enter_school
|
||||
verify_empty_login_view
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# ======================================================================================================================
|
||||
# Helper Methods
|
||||
# ======================================================================================================================
|
||||
|
||||
# TODO: fix when SpeedGrader Landing Page is updated
|
||||
def open_help_menu(app_name)
|
||||
if app_name == 'icanvas'
|
||||
help_button = find_element(:id, 'Open help menu.')
|
||||
else
|
||||
help_button = buttons[0]
|
||||
end
|
||||
help_button.click
|
||||
help_button
|
||||
end
|
||||
|
||||
# Help menu closes differently between iPhone and iPad devices
|
||||
def close_help_menu(help_button)
|
||||
if device_is_iphone
|
||||
button_exact('Cancel').click
|
||||
else
|
||||
Appium::TouchAction.new.tap(x: help_button.location.x, y: help_button.location.y).perform
|
||||
end
|
||||
end
|
||||
|
||||
def verify_help_menu(displayed)
|
||||
expect(exists{ text_exact('Help Menu') }).to be displayed
|
||||
expect(exists{ button_exact('Report a Problem') }).to be displayed
|
||||
expect(exists{ button_exact('Request a Feature') }).to be displayed
|
||||
expect(exists{ button_exact('Find School Domain') }).to be displayed
|
||||
expect(exists{ button_exact('Cancel') }).to be displayed if device_is_iphone # not displayed on iPads
|
||||
end
|
||||
|
||||
def verify_empty_login_view
|
||||
wait(timeout: 10, interval: 0.250){ tag('UIASecureTextField') }
|
||||
expect(tag('UIATextField')).to be_displayed
|
||||
expect(tag('UIASecureTextField')).to be_displayed
|
||||
expect(button_exact('Log In')).to be_displayed
|
||||
expect(text_exact('I don\'t know my password')).to be_displayed
|
||||
expect(find_element(:id, 'Cancel')).to be_displayed
|
||||
end
|
|
@ -0,0 +1,8 @@
|
|||
require_relative '../../../helpers/landing_page_common'
|
||||
|
||||
describe 'icanvas landing page' do
|
||||
include_examples 'in-process server selenium tests'
|
||||
include_examples 'appium mobile specs', 'icanvas'
|
||||
|
||||
it_behaves_like 'icanvas and speedgrader landing page', 'icanvas'
|
||||
end
|
|
@ -0,0 +1,8 @@
|
|||
require_relative '../../../helpers/landing_page_common'
|
||||
|
||||
describe 'speedgrader for ios landing page' do
|
||||
include_examples 'in-process server selenium tests'
|
||||
include_examples 'appium mobile specs', 'speedgrader_ios'
|
||||
|
||||
it_behaves_like 'icanvas and speedgrader landing page', 'speedgrader_ios'
|
||||
end
|
|
@ -4,6 +4,9 @@ require_relative 'environment_setup'
|
|||
|
||||
include EnvironmentSetup
|
||||
|
||||
# Mobile canvas and speedgrader apps have features that behave the same in both apps.
|
||||
# Because each app still has its own test case in TestRails, this method chooses
|
||||
# the proper test_id for examples that can be shared between app specs.
|
||||
def pick_test_id_for_app(app_name, canvas, speedgrader)
|
||||
app_name =~ /(speedgrader)/ ? speedgrader : canvas
|
||||
end
|
||||
|
@ -146,8 +149,7 @@ def appium_init_ios
|
|||
end
|
||||
|
||||
def appium_init(app_name)
|
||||
# @school = "#{host_url}:#{$server_port}"
|
||||
@school = 'twilson' # TODO: REMOVE WHEN MOBILE VERIFY SUPPORTS LOCAL ENVIRONMENT
|
||||
@school = school_domain
|
||||
@appium_lib = { server_url: appium_server_url }
|
||||
case app_name
|
||||
when 'candroid', 'speedgrader_android'
|
||||
|
|
Loading…
Reference in New Issue