Created
January 22, 2018 11:07
-
-
Save isnifer/70c86499a32308a6a322e0a72928ac1d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import helper from 'tipsi-appium-helper' | |
import twoFieldsScenario from './twoFieldsScenario' | |
import oneByOneFieldScenario from './oneByOneFieldScenario' | |
import hideKeyboard from '../hideKeyboard' | |
export default async function loginViaFacebook(username, password, t) { | |
const { driver, idFromXPath, select, platform } = helper | |
const usernameId = select({ | |
ios: idFromXPath('//XCUIElementTypeTextField[1]'), | |
android: idFromXPath('//android.widget.EditText[1]'), | |
}) | |
const passwordId = select({ | |
ios: idFromXPath('//XCUIElementTypeSecureTextField[1]'), | |
android: idFromXPath('//android.widget.EditText[1][@password="true"]'), | |
}) | |
// TYPE USERNAME | |
await driver.waitForVisible(usernameId, 60000).click(usernameId).setValue(usernameId, username) | |
t.pass('User should fill username') | |
// HIDE KEYBOARD | |
await hideKeyboard() | |
t.pass(`User should click on ${platform('ios') ? 'GO' : '✓'} button`) | |
try { | |
// FIRST OF ALL WE NEED TO CHECK IS THAT FORM CONTAINS "TWO FIELDS" OR "ONE-BY-ONE" | |
await driver.waitForVisible(passwordId, 10000, platform('ios')) | |
return oneByOneFieldScenario(username, password, t) | |
} catch (error) { | |
return twoFieldsScenario(username, password, t) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import helper from 'tipsi-appium-helper' | |
import hideKeyboard from '../hideKeyboard' | |
export default async function oneByOneFieldScenario(username, password, t) { | |
const { driver, idFromXPath, select, platform } = helper | |
t.comment('Login via Facebook: One-By-One Scenario') | |
const passwordId = select({ | |
ios: idFromXPath('//XCUIElementTypeSecureTextField[1]'), | |
android: idFromXPath('//android.widget.EditText[1][@password="true"]'), | |
}) | |
const continueButtonId = select({ | |
ios: idFromXPath('//XCUIElementTypeOther[4]/XCUIElementTypeButton[1]'), | |
android: idFromXPath('//android.widget.Button[1]'), | |
}) | |
// TYPE PASSWORD | |
await driver.waitForVisible(passwordId, 5000).click(passwordId).setValue(passwordId, password) | |
t.pass('User should fill password') | |
// SUBMIT FORM | |
await hideKeyboard() | |
t.pass(`User should click on ${platform('ios') ? 'GO' : '✓'} button`) | |
// WAIT WHEN SCREEN HAS CHANGED | |
await driver.waitForVisible(passwordId, 10000, true) | |
t.pass('User should wait when the next screen finish loading') | |
// WAIT AND TAP ON CONTINUE | |
await driver.waitForVisible(continueButtonId, 10000).click(continueButtonId) | |
t.pass('User should wait and tap on continue button') | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import helper from 'tipsi-appium-helper' | |
import hideKeyboard from '../hideKeyboard' | |
export default async function twoFieldsScenario(username, password, t) { | |
const { driver, idFromXPath, select, platform } = helper | |
t.comment('Login via Facebook: Two Fields Scenario') | |
const passwordId = select({ | |
ios: idFromXPath('//XCUIElementTypeSecureTextField[1]'), | |
android: idFromXPath('//android.widget.EditText[2][@password="true"]'), | |
}) | |
const continueButtonId = select({ | |
ios: idFromXPath('//XCUIElementTypeOther[4]/XCUIElementTypeButton[1]'), | |
android: idFromXPath('//android.widget.Button[1]'), | |
}) | |
// TYPE PASSWORD | |
await driver.waitForVisible(passwordId, 5000).click(passwordId).setValue(passwordId, password) | |
t.pass('User should fill password') | |
// SUBMIT FORM | |
await hideKeyboard() | |
t.pass(`User should click on ${platform('ios') ? 'GO' : '✓'} button`) | |
// WAIT WHEN SCREEN HAS CHANGED | |
await driver.waitForVisible(passwordId, 10000, true) | |
t.pass('User should wait when the next screen finish loading') | |
// WAIT AND TAP ON CONTINUE | |
await driver.waitForVisible(continueButtonId, 10000).click(continueButtonId) | |
t.pass('User should wait and tap on continue button') | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment