Forum Discussion

Archana_72's avatar
Archana_72
Contributor
7 years ago
Solved

Is it possible to have same script for Android and iOS apps?

Hi,   We have an app developed in android and now we are developing same app in iOS.   Is there any way I can re-use the same scripts for Android and iOS apps?   If so what is the approach?  
  • shankar_r's avatar
    7 years ago

    If your flow is same for both iOS and Android then the best option would be like below,

     

    function test()
    {
    testiOSLogin(Aliases.iOS.txtUserName,Aliases.iOS.txtPWD,Aliases.iOS.btnLogin,v_username,v_password);
    testAndriodLogin(Aliases.Andriod.txtUserName,Aliases.Andriod.txtPWD,Aliases.Andriod.btnLogin,v_username,v_password);
    }

     

    //common function for login
    function loginApp(obj_usrName,obj_passWord,objLoginButton,txt_userName,txt_Password)
    {
               enterFiled(obj_usrName,txt_userName);      
               enterFiled(obj_passWord,txt_Password);
               
               if(objLoginButton.Exists)
               {
                      objLoginButton.Click();
               }
               
               //do the necessary check to know the login succesful and return true
               return true;
    }
    
    //common function for entering
    function enterFiled(objecttoEnter,value)
    {
          if(objecttoEnter.Exists)
         {
                 objecttoEnter.Keys(value);
         }
    }