Example #1
0
        public TestCase(Uri endpoint, DesiredCapabilities capabilities, PCloudyAppiumSession sessionCloser)
        {
            this.endpoint = endpoint;

            this.capabilities         = capabilities;
            this.pCloudyDeviceSession = sessionCloser;
        }
Example #2
0
 public TestCase(Uri appiumEndpoint, DesiredCapabilities capabilities, PCloudyAppiumSession session)
 {
     this.appiumEndpoint = appiumEndpoint;
     this.capabilities   = capabilities;
     this.session        = session;
 }
        static void Main(string[] args)
        {
            log("Welcome to pCloudy c# Sample Project");
            var    con       = new ssts.util.pCloudy.pCloudyClient("https://device.pcloudy.com");
            String authToken = con.authenticateUser(yourEmailId, yourApiKey);

            log("AuthToken: " + authToken);

            log("-------------------------------");


            var selectedDevices = con.chooseMultipleDevices(authToken, "android");

            log("Total Devices Booked: " + selectedDevices.Count);
            String sessionName = "AppiumNative-" + selectedDevices.First().display_name;

            if (selectedDevices.Count > 1)
            {
                sessionName += " and " + (selectedDevices.Count - 1) + " others";
            }


            log("-------------------------------");
            var bookedDevices = con.bookDevicesForAppium(authToken, selectedDevices, TimeSpan.FromMinutes(BOOKINGDURAITON), sessionName);

            log("Devices Booked....");
            log("-------------------------------");


            FileInfo fileToBeuploaded = new FileInfo(appPath);

            var alreadyUploadedApp = con.getApplicationIfUploaded(authToken, fileToBeuploaded.Name);

            if (alreadyUploadedApp == null)
            {
                Console.Out.WriteLine("Uploading App :  " + appPath);
                var uploadedApp = con.uploadApp(authToken, fileToBeuploaded,
                                                x =>
                {
                    log("Uploaded: " + x + "%");
                }
                                                );

                log("App uploaded...");
                alreadyUploadedApp      = new ssts.util.pCloudy.DTO.pDriveFileDTO();
                alreadyUploadedApp.file = uploadedApp.File;
            }
            else
            {
                log("App already present in Cloud Drive. Not uploading...");
            }
            con.initAppiumHubForApp(authToken, alreadyUploadedApp);
            var endpoint = con.getAppiumEndpoint(authToken);

            log("Appium Endpoint: " + endpoint);
            log("Result Folder Path: " + con.getAppiumReportFolder(authToken));


            List <Thread> threadPool = new List <Thread>();

            for (int i = 0; i < bookedDevices.Length; i++)
            {
                var    aDevice        = bookedDevices[i];
                String bookedDeviceID = aDevice.capabilities.deviceName;

                var capabilities = new DesiredCapabilities();

                capabilities.SetCapability("deviceName", bookedDeviceID);
                capabilities.SetCapability("platformName", "Android");
                capabilities.SetCapability("appActivity", "com.ba.mobile.LaunchActivity");
                capabilities.SetCapability("appPackage", "com.ba.mobile");

                PCloudyAppiumSession session = new PCloudyAppiumSession(con, authToken, aDevice);

                TestCase tc = new TestCase(endpoint, capabilities, session);

                var t = new Thread(new ThreadStart(tc.run));
                t.Start();
                threadPool.Add(t);
            }

            foreach (Thread t in threadPool)
            {
                t.Join();
            }

            log("Press any key to exit..");
            Console.In.ReadLine();
        }
        public static ITestDataSource[] init()
        {
            if (isRunningInTestDiagnosticMode())
            {
                return(pCloudyDeviceList());
            }
            else
            {
                log("Called init");
                var    pCloudySessions = new List <PCloudyAppiumSession>();
                var    con             = new ssts.util.pCloudy.pCloudyClient("https://device.pcloudy.com");
                String authToken       = con.authenticateUser("*****@*****.**", "3vngzzzghz267t5b2qqz3r5r");
                log("AuthToken: " + authToken);


                printDeviceFullNames(authToken, con);

                #region autoselectDevices
                //   log("maxDeviceCount:" + maxDeviceCount);
                //   var selectedDevices = con.getAvailableDevices(authToken, BOOKINGDURATION, "android", minimumVersion, maximumVersion, maxDeviceCount).ToList();
                #endregion

                var deviceFullNameArray = (from itm in pCloudyDeviceList() select itm.getDeviceName()).ToArray();
                var selectedDevices     = con.getAvailableDevicesByArrayOfFullNames(authToken, BOOKINGDURATION, "android", deviceFullNameArray).ToList();

                String sessionName = "NUnit Appium-" + System.DateTime.Now.ToString("u");

                FileInfo fileToBeuploaded = new FileInfo(appPath);

                var alreadyUploadedApp = con.getApplicationIfUploaded(authToken, fileToBeuploaded.Name);
                if (alreadyUploadedApp == null)
                {
                    Console.Out.WriteLine("Uploading App :  " + appPath);
                    var uploadedApp = con.uploadApp(authToken, fileToBeuploaded,
                                                    x =>
                    {
                        log("Uploaded: " + x + "%");
                    }
                                                    );

                    log("App uploaded...");
                    alreadyUploadedApp      = new ssts.util.pCloudy.DTO.pDriveFileDTO();
                    alreadyUploadedApp.file = uploadedApp.File;
                }

                log("-------------------------------");
                var bookedDevices = con.bookDevicesForAppium(authToken, selectedDevices, BOOKINGDURATION, sessionName);
                log("Total Devices Booked: " + bookedDevices.Count());
                log("-------------------------------");


                con.initAppiumHubForApp(authToken, alreadyUploadedApp);
                var endpoint = con.getAppiumEndpoint(authToken);
                log("Appium Endpoint: " + endpoint);
                log("Result Folder Path: " + con.getAppiumReportFolder(authToken));


                foreach (BookingDtoDevice itm in bookedDevices)
                {
                    PCloudyAppiumSession appiumSession = new PCloudyAppiumSession(con, authToken, itm);
                    pCloudySessions.Add(appiumSession);
                }


                return((from itm in pCloudySessions select new TestCaseDataSource(itm)).ToArray());
            }
        }
 public TestCaseDataSource(PCloudyAppiumSession appiumSession)
 {
     this.appiumSession = appiumSession;
 }
        private static void init_pCloudyAppiumDriver(string apiEndpoint, string email_id, string apiKey)
        {
            Console.Out.WriteLine(" Connecting to pCloudy Real Device Cloud.....");
            var con = new ssts.util.pCloudy.pCloudyClient(apiEndpoint);


            String authToken = con.authenticateUser(email_id, apiKey);

            Console.Out.WriteLine("-----------------------");
            Console.Out.WriteLine("pcloudy UserAPI Authenticated");
            Console.Out.WriteLine("-----------------------");

            var selectedDevices = con.chooseMultipleDevices(authToken, PLATFORM);

            string sessionName = "AppiumNative-" + selectedDevices.First().display_name;

            if (selectedDevices.Count > 1)
            {
                sessionName += " and" + (selectedDevices.Count - 1) + "others";
            }
            Console.Out.WriteLine("Total Devices Booked : " + selectedDevices.Count);
            var bookedDevices = con.bookDevicesForAppium(authToken, selectedDevices, TimeSpan.FromMinutes(BOOKINGDURATION), sessionName);

            Console.Out.WriteLine("Devices Booked....");


            log("-------------------------------");
            con.initAppiumHubForBrowser(authToken, BROWSER);
            log("-----------------------------");


            var endpoint = con.getAppiumEndpoint(authToken);

            log("Appium Endpoint: " + endpoint);



            List <Thread> threadPool = new List <Thread>();

            for (int i = 0; i < bookedDevices.Length; i++)
            {
                var aDevice      = bookedDevices[i];
                var capabilities = new DesiredCapabilities();

                capabilities.SetCapability("browserName", BROWSER);
                capabilities.SetCapability("deviceName", aDevice.capabilities.deviceName);
                capabilities.SetCapability("platformName", aDevice.capabilities.platformName);
                capabilities.SetCapability("platformVersion", aDevice.version);

                if (PLATFORM.Equals("ios"))
                {
                    if (aDevice.version.CompareTo(new Version("9.3")) >= 0)
                    {
                        capabilities.SetCapability("automationName", "XCUITst");
                    }
                    else
                    {
                        Console.Error.WriteLine("Ios Safari automation based on Instruments is not supported. Pleaserun on newer devices with XUITest ");
                    }

                    capabilities.SetCapability("usePrebuiltWDA", true);
                    capabilities.SetCapability("acceptAlerts", true);
                }



                PCloudyAppiumSession session = new PCloudyAppiumSession(con, authToken, aDevice);

                TestCase tc = new TestCase(endpoint, capabilities, session);

                var t = new Thread(new ThreadStart(tc.run));
                t.Start();
                threadPool.Add(t);
            }

            foreach (Thread t in threadPool)
            {
                t.Join();
            }

            log("Press any key to exit..");
            Console.In.ReadLine();
        }
Example #7
0
 public Keywords(PCloudyAppiumSession pCloudySession)
 {
     this.pCloudySession = pCloudySession;
 }
Example #8
0
 public Keywords(RemoteWebDriver driver, PCloudyAppiumSession pCloudySession)
 {
     this.driver         = driver;
     this.pCloudySession = pCloudySession;
 }