Custom keyword for numeric keyboard

hi
I have a screen on the app , where the phone number field cannot be filled by any send text commands .
I should tap on each button which each one. therefore I am trying to create a custom keyword to pass a phone number in global variables and on the method it will check each number from left to right and on switch will tap on its related locator

how can I divide the phone number as mentioned ?

Maybe something like below? It just does the phone number. You will have to insert what references it has to tap for each number. If there is a GO button, then add that after this procedure or insert it at the very bottom. The case: default even allows you to have formatting of the phone number (the procedure ignores it).

Parse Phone Number
	@Keyword
	def void ParseTelephone(String telephone) {
		def ref = ""
		int max = telephone.length()
		for (int cnt = 0; cnt < max; cnt++) {
			ref = telephone.substring(cnt, cnt + 1)
			switch (ref) {
				case "0":
					Mobile.tap()
					break;
				case "1":
					Mobile.tap()
					break;
				case "2":
					Mobile.tap()
					break;
				case "3":
					Mobile.tap()
					break;
				case "4":
					Mobile.tap()
					break;
				case "5":
					Mobile.tap()
					break;
				case "6":
					Mobile.tap()
					break;
				case "7":
					Mobile.tap()
					break;
				case "8":
					Mobile.tap()
					break;
				case "9":
					Mobile.tap()
					break;
				default:
					break;
			}
		}
	}
1 Like

worked this way :

def void enterPhoneNumber(a){
	def ref = ""
	String max = a.length()-1
	int maxInt = Integer.valueOf(max)
	for(int i=0; i<= maxInt; i++){
		ref = a.substring(i, i+1 )
		switch (ref) {
			case "0":
				Mobile.tap(findTestObject('Object Repository/Onboarding/001-Startup page/001-Phone number fields/002-Numeric Keyboard/Button - 0') , 5);
				break;
			case "1":
				Mobile.tap(findTestObject('Object Repository/Onboarding/001-Startup page/001-Phone number fields/002-Numeric Keyboard/Button - 1') , 5);
				break;
			case "2":
				Mobile.tap(findTestObject('Object Repository/Onboarding/001-Startup page/001-Phone number fields/002-Numeric Keyboard/Button - 2') , 5);
				break;
			case "3":
				Mobile.tap(findTestObject('Object Repository/Onboarding/001-Startup page/001-Phone number fields/002-Numeric Keyboard/Button - 3') , 5);
				break;
			case "4":
				Mobile.tap(findTestObject('Object Repository/Onboarding/001-Startup page/001-Phone number fields/002-Numeric Keyboard/Button - 4') , 5);
				break;
			case "5":
				Mobile.tap(findTestObject('Object Repository/Onboarding/001-Startup page/001-Phone number fields/002-Numeric Keyboard/Button - 5') , 5);
				break;
			case "6":
				Mobile.tap(findTestObject('Object Repository/Onboarding/001-Startup page/001-Phone number fields/002-Numeric Keyboard/Button - 6') , 5);
				break;
			case "7":
				Mobile.tap(findTestObject('Object Repository/Onboarding/001-Startup page/001-Phone number fields/002-Numeric Keyboard/Button - 7') , 5);
				break;
			case "8":
				Mobile.tap(findTestObject('Object Repository/Onboarding/001-Startup page/001-Phone number fields/002-Numeric Keyboard/Button - 8') , 5);
				break;
			case "9":
				Mobile.tap(findTestObject('Object Repository/Onboarding/001-Startup page/001-Phone number fields/002-Numeric Keyboard/Button - 9') , 5);
				break;
			default:
				break;
		}
	}
}