IDP自动化项目
-pageObject
--mobileLoginPage
import { adbInput } from "../../../utils/adbHelper"
import { UiSelector } from "../../../utils/andriodSelector"
import { ocr } from "../../../utils/ocrService/ocr"
import ProfilePage from "./profilePage"
class MobileLoginPage {
get SignInButton() { return android.$(UiSelector('text','Sign in')()) }
//get SignInWithEmailButton() { return android.$(UiSelector('text','Sign in with email')()) }
//get SignInWithEmailButton() {return android.$(new UiSelector().className("android.widget.RelativeLayout").index(2)())}
get SignInWithEmailButton() { return android.$(UiSelector('className','android.widget.RelativeLayout')('index','2')())}
get EmailInput() { return android.$(UiSelector('resourceId','email')()) }
get PasswordInput() { return android.$(UiSelector('resourceId','password')()) }
get SignInWithGoogleButton() { return android.$(UiSelector('text','Sign in with Google')()) }
get SignInWithMicrosoftButton() { return android.$(UiSelector('text','Sign in with Microsoft')()) }
get YesButton() { return android.$(UiSelector('text','Yes')()) }
async signInWithEmail(email,password) {
await this.SignInButton.waitForExist({timeout: 10000})
await this.SignInButton.click()
await browser.pause(10000)
await this.SignInWithEmailButton.waitForDisplayed()
await this.SignInWithEmailButton.click()
await this.EmailInput.setValue(email)
await this.PasswordInput.setValue(password)
await this.SignInButton.click()
await ProfilePage.ProfileButton.waitForExist({timeout: 20000})
}
async googleSignInFlow(email, password){
await ocr.waitUntilTextInScreen('android','prometheanproduct.com',{top:400,height:200})
adbInput.text(androidID, email)
adbInput.keyevent(androidID, 'KEYCODE_ENTER')
await ocr.waitUntilTextInScreen('android',email,{top:400,height:200})
adbInput.text(androidID, password)
adbInput.keyevent(androidID, 'KEYCODE_ENTER')
await ProfilePage.ProfileButton.waitForExist({timeout: 20000})
}
async signInWithGoogle(email,password) {
await this.SignInButton.waitForExist({timeout: 10000})
await this.SignInButton.click()
await this.SignInWithGoogleButton.waitForDisplayed()
await browser.pause(3000)
await this.SignInWithGoogleButton.click()
await this.googleSignInFlow(email,password)
}
async googleSSOSignIn(email,password){
await this.SignInButton.waitForExist({timeout: 10000})
await this.SignInButton.click()
await this.SignInWithGoogleButton.waitForDisplayed()
await browser.pause(3000)
await this.SignInWithGoogleButton.click()
try {
await ocr.waitUntilTextInScreen('android','ActivPanel',{height:700})
} catch (error) {
await this.googleSignInFlow(email,password)
}
}
async microsoftSignInFlow(email,password){
await ocr.waitUntilTextInScreen('android','Microsoft',{area:['top']})
adbInput.text(androidID, email)
adbInput.keyevent(androidID, 'KEYCODE_ENTER')
await ocr.waitUntilTextInScreen('android',email,{top:300,height:200})
adbInput.text(androidID, password)
adbInput.keyevent(androidID, 'KEYCODE_ENTER')
await this.YesButton.waitForExist()
await this.YesButton.click()
await ProfilePage.ProfileButton.waitForExist({timeout: 20000})
}
async signInWithMicrosoft(email,password) {
await this.SignInButton.waitForExist({timeout: 10000})
await this.SignInButton.click()
await this.SignInWithMicrosoftButton.waitForDisplayed()
await browser.pause(3000)
await this.SignInWithMicrosoftButton.click()
await this.microsoftSignInFlow(email,password)
}
async checkSignedIn(){
if (await this.SignInButton.isExisting()){
return false
}else{
return true
}
}
}
export default new MobileLoginPage()
声明 欢迎转载,但请保留文章原始出处:) 博客园:https://www.cnblogs.com/chenxiaomeng/
如出现转载未声明 将追究法律责任~谢谢合作

浙公网安备 33010602011771号