public void WebDriverTestMethod()
        {
            Dictionary <String, Object> pars = new Dictionary <String, Object>();

            try
            {
                reportiumClient.testStart("Wikipedia sample", new TestContextTags("sample1", "apples"));

                // write your code here
                reportiumClient.stepStart("Open Wikipedia");
                driver.Navigate().GoToUrl("www.wikipedia.org");
                pars.Clear();
                pars.Add("content", "The Free Encyclopedia");
                pars.Add("timeout", 20);
                String res = (String)driver.ExecuteScript("mobile:checkpoint:text", pars);

                if (!res.ToLower().Equals("true"))
                {
                    reportiumClient.reportiumAssert("homepage loaded", false);
                }
                reportiumClient.stepEnd();

                reportiumClient.stepStart("Looking for term");
                driver.FindElementByXPath("//*[@id='searchInput']").SendKeys("apple");
                System.Threading.Thread.Sleep(2000);

                driver.FindElementByXPath("//*[@class=\"pure-button pure-button-primary-progressive\"]").Click();
                reportiumClient.stepEnd();

                reportiumClient.stepStart("Visual Analysis to verify on right page");
                pars.Clear();
                pars.Add("content", "fruit");
                pars.Add("timeout", 20);
                res = (String)driver.ExecuteScript("mobile:checkpoint:text", pars);
                if (!res.ToLower().Equals("true"))
                {
                    reportiumClient.reportiumAssert("search term loaded", false);
                }
                reportiumClient.stepEnd();

                reportiumClient.testStop(TestResultFactory.createSuccess());
            }
            catch (Exception e)
            {
                reportiumClient.testStop(TestResultFactory.createFailure(e.Message, e));
                Trace.Write(e.StackTrace);
                Trace.WriteLine(" ");
            }
        }
示例#2
0
        public void WebDriverTestMethod()
        {
            //Write your test here
            reportClient.testStart("User Agent test", new TestContextTags("assignment2", "training"));

            Dictionary <String, Object> pars = new Dictionary <String, Object>();

            try
            {
                reportClient.stepStart("Open the website");
                driver.Navigate().GoToUrl("https://training.perfecto.io");
                pars.Clear();
                pars.Add("content", "Training Website");
                pars.Add("timeout", 20);
                String res = (String)driver.ExecuteScript("mobile:checkpoint:text", pars);

                if (!res.ToLower().Equals("true"))
                {
                    reportClient.reportiumAssert("homepage loaded", false);
                }
                reportClient.stepEnd();

                reportClient.stepStart("navigate to agent page");
                driver.FindElementByXPath("//*[@class=\"mobile-menu\"]").Click();

                pars.Clear();
                pars.Add("label", "Agent");
                pars.Add("timeout", 20);
                driver.ExecuteScript("mobile:button-text:click", pars);

                String result = (String)driver.FindElementByXPath("//*[text()=\"The User Agent\"]").Text;
                Trace.WriteLine(result);

                reportClient.testStop(TestResultFactory.createSuccess());
            }
            catch (Exception e)
            {
                reportClient.testStop(TestResultFactory.createFailure(e.Message, e));
                Trace.Write(e.StackTrace);
                Trace.WriteLine(" ");
            }
        }
示例#3
0
        public void AppiumTestMethod()
        {
            Dictionary <String, Object> pars = new Dictionary <String, Object>();
            String res;

            try
            {
                reportiumClient.testStart("Image Injection Assignment", new TestContextTags("assignment4", "image"));

                // write your code here

                reportiumClient.stepStart("Start the app and upload the image");

                try
                {
                    // close the calendar if open to verify that starting from fresh app
                    pars.Add("name", "RealTimeFilter");
                    driver.ExecuteScript("mobile:application:close", pars);
                }
                catch (Exception e)
                {
                    Trace.Write(e.StackTrace);
                    Trace.WriteLine(" ");
                }
                try
                {
                    pars.Clear();
                    pars.Add("name", "RealTimeFilter");
                    driver.ExecuteScript("mobile:application:open", pars);
                }
                catch (Exception e)
                {
                    // unable to start the app, probably because it isn't installed
                    pars.Clear();
                    pars.Add("file", "PUBLIC:ImageInjection\\RealTimeFilter.ipa");
                    pars.Add("sensorInstrument", "sensor");
                    driver.ExecuteScript("mobile:application:install", pars);

                    pars.Clear();
                    pars.Add("name", "RealTimeFilter");
                    driver.ExecuteScript("mobile:application:open", pars);
                }

                driver.Context = "NATIVE_APP";
                reportiumClient.stepEnd();

                reportiumClient.stepStart("inject the image");

                pars.Clear();
                pars.Add("repositoryFile", "PRIVATE:perfectoL.png");
                pars.Add("identifier", "Victor.RealTimeFilter");
                driver.ExecuteScript("mobile:image.injection:start", pars);
                reportiumClient.stepEnd();

                reportiumClient.stepStart("dismiss popup if it appears");
                // rotate the image (device) to show in landscape
                pars.Clear();
                pars.Add("content", "Access the Camera");
                pars.Add("timeout", 20);
                res = (String)driver.ExecuteScript("mobile:checkpoint:text", pars);

                if (res.ToLower().Equals("true"))
                {
                    pars.Clear();
                    pars.Add("label", "OK");
                    pars.Add("timeout", 10);

                    res = (String)driver.ExecuteScript("mobile:button-text:click", pars);
                }
                reportiumClient.stepEnd();

                reportiumClient.stepStart("verify the image is displayed");
                // rotate the image (device) to show in landscape
                pars.Clear();
                pars.Add("state", "landscape");
                driver.ExecuteScript("mobile:device:rotate", pars);

                pars.Clear();
                pars.Add("content", "Perfection");
                pars.Add("timeout", 20);

                res = (String)driver.ExecuteScript("mobile:checkpoint:text", pars);

                if (res.ToLower().Equals("true"))
                {
                    reportiumClient.testStop(TestResultFactory.createSuccess());
                }
                else
                {
                    pars.Clear();
                    pars.Add("tail", 50);
                    String logStr = (String)driver.ExecuteScript("mobile:device:log", pars);
                    reportiumClient.reportiumAssert("Failed to view image", false);
                    reportiumClient.testStop(TestResultFactory.createFailure("Failed to view image", null));
                }
            }
            catch (Exception e)
            {
                reportiumClient.testStop(TestResultFactory.createFailure(e.Message, e));
            }
        }
示例#4
0
        public void AppiumTestMethod()
        {
            //Write your test here
            // Notify Reporting Server that test is starting
            reportClient.testStart("Wikipedia assignment", new TestContextTags("assignment1", "apple entry"));

            Dictionary <String, Object> pars = new Dictionary <String, Object>();

            try
            {
                reportClient.stepStart("Open YouTube");
                try
                {
                    // close the calendar if open to verify that starting from fresh app
                    pars.Add("name", "YouTube");
                    driver.ExecuteScript("mobile:application:close", pars);
                }
                catch (Exception e)
                {
                    Trace.Write(e.StackTrace);
                    Trace.WriteLine(" ");
                }
                pars.Clear();
                pars.Add("name", "YouTube");
                driver.ExecuteScript("mobile:application:open", pars);
                driver.Context = "NATIVE_APP";

                reportClient.stepEnd();

                reportClient.stepStart("Adjust Volume");
                MaxVolume(driver);
                reportClient.stepEnd();

                reportClient.stepStart("Activate the audio search");
                driver.FindElementByXPath("//*[@content-desc=\"Search\"]").Click();
                driver.FindElementByXPath("//*[@resource-id=\"com.google.android.youtube:id/voice_search\"]").Click();
                reportClient.stepEnd();

                reportClient.stepStart("Play name for audio search");
                // Create audio file from String
                String key = "PRIVATE:mysong.wav";
                pars.Clear();
                pars.Add("text", "Metallica Master of Puppets");
                pars.Add("repositoryFile", key);
                driver.ExecuteScript("mobile:text:audio", pars);
                // inject Audio to device
                pars.Clear();
                pars.Add("key", key);
                pars.Add("wait", "wait");
                driver.ExecuteScript("mobile:audio:inject", pars);
                reportClient.stepEnd();

                reportClient.stepStart("Play the music clip and validate");
                driver.FindElementByXPath("//*[@content-desc=\"Play album\"]").Click();

                pars.Clear();
                pars.Add("timeout", 30);
                pars.Add("duration", 1);
                String audioR = (String)driver.ExecuteScript("mobile:checkpoint:audio", pars);
                reportClient.stepEnd();

                reportClient.stepStart("Close the app");
                // inject Audio to device
                pars.Clear();
                pars.Add("name", "YouTube");
                driver.ExecuteScript("mobile:application:close", pars);
                reportClient.stepEnd();

                if (audioR.ToLower().Equals("true"))
                {
                    reportClient.reportiumAssert("Audio is playing", true);
                    reportClient.testStop(TestResultFactory.createSuccess());
                }
                else
                {
                    reportClient.reportiumAssert("Audio failed", false);
                    reportClient.testStop(TestResultFactory.createFailure("Audio failed", null));
                }
            }
            catch (Exception e)
            {
                reportClient.testStop(TestResultFactory.createFailure(e.Message, e));
                Trace.Write(e.StackTrace);
                Trace.WriteLine(" ");
            }
        }