mardi 3 juillet 2018

Using if/else with JS in Appium?

So I'm trying to figure out how to make my Appium login test perform different actions based on whether it is a PIN entry or password but I cant seem to get it to work. Is there another way that I can achieve the intended effect or am I just making a dumb syntax mistake?

This is my current code which gives me an error that states "SyntaxError: Unexpected token ."

it('should check if PIN overlay is displayed', function() {
  return client
    if(.isVisible('android=new UiSelector().resourceId("com.orgname.app:id/img")'){          
      .deviceKeyEvent(input.pin1)
      .deviceKeyEvent(input.pin2)
      .deviceKeyEvent(input.pin1)
      .deviceKeyEvent(input.pin2)
      .deviceKeyEvent(input.pin1)
      .deviceKeyEvent(input.pin2)
    }
    else{
      .click('android=new UiSelector().resourceId("com.orgname.app:id/flxLoginActionContainer")')
      .waitForExist('android=new UiSelector().resourceId("com.orgname.app:id/frmLogin")',10000) 
      .click('android=new UiSelector().resourceId("com.orgname.app:id/flxIndicator")')
      .setValue('android=new UiSelector().resourceId("com.orgname.app:id/tbxPass")', input.pass)
      .hideDeviceKeyboard()
      .click('android=new UiSelector().resourceId("com.orgname.app:id/imgLogin")') 
    }    

    .waitForExist('android=new UiSelector().resourceId("com.orgname.dcpApp:id/frmDashboardSummary")', 10000)  
    .then(function (result){
      assert.equal(result, true)
    })
})

})

Aucun commentaire:

Enregistrer un commentaire