I am new to this run keyword if method.
I wanted to enter different number based on specific page.
e.g. if page1 element is detected then input number 1, if page2 then input number 2.
*** Settings ***
Library Selenium2Library
Library Collections
Resource ../Resources/nine-res-work.robot
*** Variables ***
${LOGIN-BUTTON-NUMBER-1} ${ANDROID-WIDGET-TEXT-VIEW}\[@resource-id="com.test.abc.work.cac:id/btn_number" and @text="1"]
${LOGIN-BUTTON-NUMBER-2} ${ANDROID-WIDGET-TEXT-VIEW}\[@resource-id="com.test.abc.work.cac:id/btn_number" and @text="2"]
${LOGIN-BUTTON-NUMBER-3} ${ANDROID-WIDGET-TEXT-VIEW}\[@resource-id="com.test.abc.work.cac:id/btn_number" and @text="3"]
${LOGIN-PAGE-HEARDER-page1} ${ANDROID-WIDGET-TEXT-VIEW}\[@resource-id="com.test.abc.work.cac:id/headerText" and @text="Enter your PIN."]
${LOGIN-PAGE-HEARDER-page2} ${ANDROID-WIDGET-TEXT-VIEW}\[@resource-id="com.test.abc.work.cac:id/headerText" and @text="Enter your passcode."]
*** Keywords ***
Smart Card Login
Run Keyword If ${LOGIN-PAGE-HEARDER-page1} == 'PASS' Tap ${LOGIN-BUTTON-NUMBER-1}
Run Keyword If ${LOGIN-PAGE-HEARDER-page2} == 'PASS' Tap ${LOGIN-BUTTON-NUMBER-2}
*** Test Cases ***
Test 1
Launch Application
Smart Card Login
error
Test 1 | FAIL |
Evaluating expression '//android.widget.TextView[@resource-id="com.test.abc.work.cac:id/headerText" and @text="Enter your PIN."] == 'PASS'' failed: SyntaxError: invalid syntax (<string>, line 1)
I have tried another way, this time no error but the tap action isn't execute.
*** Variables ***
${LOGIN-BUTTON-NUMBER-1} ${ANDROID-WIDGET-TEXT-VIEW}\[@resource-id="com.test.abc.work.cac:id/btn_number" and @text="1"]
${LOGIN-BUTTON-NUMBER-2} ${ANDROID-WIDGET-TEXT-VIEW}\[@resource-id="com.test.abc.work.cac:id/btn_number" and @text="2"]
${LOGIN-BUTTON-NUMBER-3} ${ANDROID-WIDGET-TEXT-VIEW}\[@resource-id="com.test.abc.work.cac:id/btn_number" and @text="3"]
${LOGIN-PAGE-HEARDER-page1} ${ANDROID-WIDGET-TEXT-VIEW}\[@text="Enter your PIN."]
${LOGIN-PAGE-HEARDER-page2} ${ANDROID-WIDGET-TEXT-VIEW}\[@text="Enter your passcode."]
*** Keywords ***
Input App Passcode
Tap ${LOGIN-BUTTON-NUMBER-2}
*** Test Cases ***
Launch App
Open Nine Folders Application
Sleep 5s
Input Password
${Page1} = Page Should Contain Element ${LOGIN-PAGE-HEARDER-page1}
Run Keyword If '${Page1}' == 'PASS' Input App Passcode