Ejemplo n.º 1
0
    def Basic_Call(self, platform, orig_id, orig_pass, term_id, term_pass):
        func = inspect.stack()[1].function
        log_print(
            "info", "TestCase::[{0}] - ".format(func) +
            "Starting test case Basic_Call")
        Platform = platform.split("-")
        VERSION_1, UDID_1 = BaseSetup.getDevice(self, Platform[0])
        log_print(
            "info", "{0} Mobile picked[UDID: {1}, VERSION: {2}]".format(
                Platform[0].capitalize(), UDID_1, VERSION_1))
        user1 = Action_funcs(VERSION_1, UDID_1, Platform[0])
        VERSION_2, UDID_2 = BaseSetup.getDevice(self, Platform[1])
        log_print(
            "info", "{0} Mobile picked[UDID: {1}, VERSION: {2}]".format(
                Platform[1].capitalize(), UDID_2, VERSION_2))
        user2 = Action_funcs(VERSION_2, UDID_2, Platform[1])
        orig_number = user1.LogIn(orig_id, orig_pass)
        log_print(
            "info", "Active number for the Orig user:[{0}] is [{1}]".format(
                orig_id, orig_number))
        sleep(2)
        term_number = user2.LogIn(term_id, term_pass)
        log_print(
            "info", "Active number for the Term user:[{0}] is [{1}]".format(
                term_id, term_number))
        sleep(5)
        user1.Call(str(term_number))
        sleep(5)
        user2.Answer()
        sleep(20)
        user1.Disconnect()
        sleep(5)
        user1.Logout()
        sleep(4)
        user2.Logout()

        if Platform[0] == Platform[1]:
            BaseSetup.addDevice(self, Platform[0])
        else:
            BaseSetup.addDevice(self, Platform[0])
            BaseSetup.addDevice(self, Platform[1])
        return True
    def setUp(self):
        self.Android_devices_dict = {}
        self.Android_devices_list = []
        self.Android_devices_used = []
        if platform.system().lower() == "windows":
            adb_path = ""
        else:
            adb_path = "~/Library/Android/sdk/platform-tools/"
        #result_out = subprocess.check_output(adb_path+'adb devices', shell=True, stderr=subprocess.STDOUT).decode().split('\n')
        result_out = remote_command(adb_path + 'adb devices',
                                    Appium_IP).split('\n')
        print(result_out)
        for s in result_out:
            s = s.rstrip()
            if s != "List of devices attached" and s != "":
                # script to get android or ios version of each device
                log_print("INFO", str(s.split('\t')[0]))
                #self.Android_devices_dict[s.split('\t')[0]] = subprocess.check_output(adb_path+'adb -s ' + s.split('\t')[0] + ' shell getprop ro.build.version.release', shell=True, stderr=subprocess.STDOUT).decode().rstrip()
                self.Android_devices_dict[s.split('\t')[0]] = remote_command(
                    adb_path + 'adb -s ' + s.split('\t')[0] +
                    ' shell getprop ro.build.version.release',
                    Appium_IP).rstrip()
                # below command to Avoid below error
                # Error: An unknown server-side error occurred while processing the command.
                # Original error: Could not proxy command to remote server. Original error: Error: read ECONNRESET
                try:
                    #print(subprocess.check_output(adb_path+'adb -s ' + s.split('\t')[0] + ' uninstall io.appium.uiautomator2.server', shell=True, stderr=subprocess.STDOUT).decode().rstrip())
                    #print(subprocess.check_output(adb_path+'adb -s ' + s.split('\t')[0] +' uninstall io.appium.uiautomator2.server.test', shell=True, stderr=subprocess.STDOUT).decode().rstrip())
                    log_print(
                        "INFO",
                        remote_command(
                            adb_path + 'adb -s ' + s.split('\t')[0] +
                            ' uninstall io.appium.uiautomator2.server').rstrip(
                            ))
                    log_print(
                        "INFO",
                        remote_command(
                            adb_path + 'adb -s ' + s.split('\t')[0] +
                            ' uninstall io.appium.uiautomator2.server.test').
                        rstrip())
                except:
                    log_print("INFO", "Already Uninstalled")

        self.Android_devices_list = self.Android_devices_list + list(
            self.Android_devices_dict.keys())

        ####
        self.ios_devices_dict = {}
        self.ios_devices_list = []
        self.ios_devices_used = []
Ejemplo n.º 3
0
    def Basic_Messaging(self, platform, orig_id, orig_pass, term_id,
                        term_pass):
        func = inspect.stack()[1].function
        try:
            log_print(
                "info", "TestCase::[{0}] - ".format(func) +
                "Starting test case Basic_Messaging")
            Platform = platform.split("-")
            VERSION_1, UDID_1 = BaseSetup.getDevice(self, Platform[0])
            user1 = Action_funcs(VERSION_1, UDID_1, Platform[0])
            log_print(
                "info", "{0} Mobile picked[UDID: {1}, VERSION: {2}]".format(
                    Platform[0].capitalize(), UDID_1, VERSION_1))
            # VERSION_2, UDID_2 = BaseSetup.getDevice(self, Platform[1])
            # user2 = Action_funcs(VERSION_2, UDID_2, Platform[1])
            #log_print("info", "{0} Mobile picked[UDID: {1}, VERSION: {2}]".format(Platform[1].capitalize(), UDID_2, VERSION_2))
            orig_number = user1.LogIn(orig_id, orig_pass)
            log_print(
                "info",
                "Active number for the Orig user:[{0}] is [{1}]".format(
                    orig_id, orig_number))
            # sleep(2)
            # term_number = user2.LogIn(term_id, term_pass)
            # print(term_number)
            sleep(10)
            user1.Send_Msg("+917022943949")
            sleep(5)
            return True

        except Exception as e:
            log_print("error", "Exception: {}".format(e))
            return False

        finally:
            user1.Logout()
            sleep(5)
            # user2.Logout()

            if Platform[0] == Platform[1]:
                BaseSetup.addDevice(self, Platform[0])
            else:
                BaseSetup.addDevice(self, Platform[0])
                BaseSetup.addDevice(self, Platform[1])
            return True
Ejemplo n.º 4
0
 def __init__(self, VERSION, UDID, PLATFORM):
     self.VERSION = VERSION
     self.UDID = UDID
     self.PLATFORM = PLATFORM
     log_print("info", "initialization done in Action_funcs")
Ejemplo n.º 5
0
 def Login_out(self, platform, user_id, user_pass):
     func = inspect.stack()[1].function
     try:
         log_print(
             "info", "TestCase::[{0}] - ".format(func) +
             "Starting test case Basic_Messaging")
         VERSION, UDID = BaseSetup.getDevice(self, platform)
         log_print(
             "info", "{0} Mobile picked[UDID: {1}, VERSION: {2}]".format(
                 platform.capitalize(), UDID, VERSION))
         user = Action_funcs(VERSION, UDID, platform)
         #user.Login_Logout(user_id, user_pass)
         user_number = user.LogIn(user_id, user_pass)
         log_print(
             "info",
             "Login is successful and Active number for the user:[{0}] is [{1}]"
             .format(user_id, user_number))
         sleep(30)
         user.Logout()
         log_print(
             "info",
             "Login and Logout test is successful for user:[{}]".format(
                 user_id))
         return True
     except IndexError as e:
         log_print("error", "IndexError: " + str(e))
         log_print(
             "error",
             "Login and Logout test is failed for user:[{}]".format(
                 user_id))
         return False
     except Exception as e:
         log_print("error", str(e))
         log_print(
             "error",
             "Login and Logout test is failed for user:[{}]".format(
                 user_id))
         return False
     finally:
         BaseSetup.addDevice(self, platform)
Ejemplo n.º 6
0
        self.assertTrue(
            TestFlow.Basic_Messaging(self,
                                     platform=Android - Android,
                                     orig_id=orig_id,
                                     orig_pass=orig_pass,
                                     term_id=term_id,
                                     term_pass=term_pass))


if __name__ == "__main__":
    template = "src/template/report_template.html"
    report_title = "Test Report"
    html_report_dir = r"../report/"
    #if not path.isdir(html_report_dir):
    #    os.mkdir(html_report_dir)

    test_suite = unittest.TestSuite()
    test = unittest.makeSuite(OTT_Client)
    test_suite.addTest(test)
    test_runner = HtmlTestRunner.HTMLTestRunner(output=html_report_dir,
                                                verbosity=2,
                                                report_title=report_title,
                                                template=template)
    test_runner.run(test_suite)
    report_status = email_reporter(html_report_dir.split('/', 1)[-1])
    log_print("info", "report_status:: " + str(report_status))
    #email_reporter(html_report_dir)

    #suite = unittest.TestLoader().loadTestsFromTestCase(OTT_Client)
    #unittest.TextTestRunner(verbosity=2).run(suite)
Ejemplo n.º 7
0
                                for i, param in enumerate(test_template):
                                    if i + 2 < len(fdata_list):
                                        if fdata_list[i + 2].rstrip(
                                        ) == "" and param[1] == 'MANDATE':
                                            test_parm_str += ", {}={}".format(
                                                param[0], "\"\"")
                                        elif fdata_list[i + 2].rstrip(
                                        ) == "" and param[1] == 'OPTIONAL':
                                            pass
                                        else:
                                            test_parm_str += ", {}={}".format(
                                                param[0],
                                                fdata_list[i + 2].rstrip())
                                    elif param[1] == 'MANDATE':
                                        log_print(
                                            "WARNING",
                                            "Can not add test case::{}, some parameters are missing\n"
                                            .format(fdata_list[0].rstrip()))
                                        test_parm_str = ""

                                if test_parm_str != "":
                                    add_class_str += "\n{0}def test{1}_{2}(self):\n".format(
                                        " " * 4, test_count, fdata_list[0])
                                    test_count += 1
                                    add_class_str += "{0}warnings.simplefilter('ignore')\n".format(
                                        " " * 8)
                                    add_class_str += "{0}self.assertTrue(TestFlow.{1}(self".format(
                                        " " * 8, fdata_list[1][1:-1].rstrip())
                                    add_class_str += test_parm_str + "))\n"
                            except KeyError:
                                log_print(
                                    "WARNING",