コード例 #1
0
ファイル: UnitTest1.cs プロジェクト: h-4vok/appium-practice
        public void TestMethod8()
        {
            var notepad = @"C:\Windows\System32\notepad.exe";

            var options = new AppiumOptions();

            options.AddAdditionalCapability("app", notepad);

            var driver = new WindowsDriver <WindowsElement>(new Uri(" http://127.0.0.1:4723/"), options);

            var eyes = new Eyes();

            eyes.ApiKey = "lFMnO9e1nbFQEdhebrDmhEBOqB7jXUXJGogj103lRWAzM110";
            eyes.SetAppEnvironment("Windows 10", null);

            try
            {
                eyes.Open("AppiumPractice", "TestMethod8");
                Thread.Sleep(3000);
                var currentAppScreenshot = driver.GetScreenshot();
                var croppedScreenshot    = CropScreenshot(currentAppScreenshot);

                eyes.CheckImage(croppedScreenshot, "Notepad Just Opened");

                eyes.Close();
            }
            finally
            {
                eyes?.AbortIfNotClosed();
                driver.Quit();
            }
        }
コード例 #2
0
ファイル: UnitTest1.cs プロジェクト: h-4vok/appium-practice
        public void TestMethod5()
        {
            var options = new AppiumOptions();

            options.AddAdditionalCapability("app", @"C:\Program Files (x86)\M4Solutions\M4Solutions.exe");

            var driver = new WindowsDriver <WindowsElement>(new Uri(" http://127.0.0.1:4723/"), options);

            driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(2);

            var projectToOpen = @"E:\clients\mapcom\M4 Regression Test Automation\Test Project\Diversicom\ARVIG.prj";

            System.Windows.Forms.Clipboard.SetText(projectToOpen);

            var projectCenterWindow = driver.FindElementByAccessibilityId("ProjectCenter");
            var btnPickProject      = projectCenterWindow.FindElementByAccessibilityId("btnPickProject");

            btnPickProject.Click();

            var openDialog = projectCenterWindow.FindElementByClassName("#32770");

            var fileTextBox = openDialog.FindElementByAccessibilityId("1148");

            fileTextBox.SendKeys(projectToOpen);

            var openButton = openDialog.FindElementByAccessibilityId("1");

            openButton.Click();

            WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(30));

            var mainWindow = driver.FindElementByAccessibilityId("MDIForm1");

            wait.Until(ExpectedConditions.TextToBePresentInElement(mainWindow, "M4 - ARVIG"));
            wait.Until(ExpectedConditions.ElementExists(By.Name("COUNTIES.msi")));

            var eyes = new Eyes();

            eyes.ApiKey = "lFMnO9e1nbFQEdhebrDmhEBOqB7jXUXJGogj103lRWAzM110";
            eyes.SetAppEnvironment("Windows 10", null);

            try
            {
                eyes.Open("AppiumPractice", "TestMethod5");
                Thread.Sleep(3000);
                var currentAppScreenshot = driver.GetScreenshot();

                eyes.CheckImage(currentAppScreenshot.AsByteArray, "Project Finished Loading");

                eyes.Close();
            }
            finally
            {
                eyes?.AbortIfNotClosed();
                driver.Quit();
            }
        }
コード例 #3
0
        public void TestUFGVisualViewport()
        {
            JsonSerializer serializer = JsonUtils.CreateSerializer();
            IWebDriver     driver     = SeleniumUtils.CreateChromeDriver();
            EyesRunner     runner     = new VisualGridRunner(10);
            Eyes           eyes       = new Eyes(runner);

            eyes.visualGridEyes_.EyesConnectorFactory = new Mock.MockEyesConnectorFactory();
            Configuration config        = eyes.GetConfiguration();
            IosDeviceInfo iosDeviceInfo = new IosDeviceInfo(IosDeviceName.iPhone_11_Pro);

            config.AddBrowser(iosDeviceInfo);
            eyes.SetConfiguration(config);
            try
            {
                eyes.Open(driver, "Eyes Selenium SDK", "Eyes Selenium SDK - UFG Visual Viewport Test");
                Mock.MockEyesConnector   mockEyesConnector   = (Mock.MockEyesConnector)eyes.visualGridEyes_.eyesConnector_;
                Mock.MockServerConnector mockServerConnector = new Mock.MockServerConnector(eyes.Logger, new Uri(eyes.ServerUrl));
                EyesConnector            eyesConnector       = new EyesConnector(new RenderBrowserInfo(iosDeviceInfo), config)
                {
                    runningSession_ = new RunningSession(),
                    ServerConnector = mockServerConnector
                };
                mockEyesConnector.WrappedConnector = eyesConnector;

                string inputJson = CommonUtils.ReadResourceFile("Test.Eyes.Selenium.DotNet.Resources.Misc.TestUFGVisualViewport_Input.json");
                RenderStatusResults renderStatusResults = serializer.Deserialize <RenderStatusResults>(inputJson);
                mockEyesConnector.SetRenderStatusResultsList(renderStatusResults);

                driver.Url = "https://applitools.github.io/demo/TestPages/DynamicResolution/desktop.html";
                eyes.Check(Target.Window().Fully());
                eyes.Close();

                runner.GetAllTestResults();

                Assert.AreEqual(1, mockServerConnector.MatchWindowCalls.Count);
                MatchWindowData matchWindowData = mockServerConnector.MatchWindowCalls[0];
                AppOutput       appOutput       = matchWindowData.AppOutput;
                Assert.AreEqual(980, appOutput.Viewport.Width);
                Assert.AreEqual(1659, appOutput.Viewport.Height);

                Assert.AreEqual(375, mockEyesConnector.DeviceSize.Width);
                Assert.AreEqual(812, mockEyesConnector.DeviceSize.Height);
            }
            finally
            {
                eyes.AbortIfNotClosed();
                driver.Quit();
            }
        }
コード例 #4
0
        static void Main(string[] args)
        {
            // Open a Chrome browser.
            var driver = new ChromeDriver();

            // Initialize the eyes SDK and set your private API key.
            var eyes = new Eyes();

            //scroll and take full page screenshot
            eyes.ForceFullPageScreenshot = true;


            // Hard code the Applitools API key or get it from the environment (see the Tutorial for details)
            // eyes.ApiKey = "Your_APIKEY";
            eyes.ApiKey = Environment.GetEnvironmentVariable("APPLITOOLS_API_KEY");

            try
            {
                // Call getTestInfoForPart to get the appropriate test information.
                Dictionary <string, string> testInfo = GetTestInfoForPart(args);


                // Start the test by setting AUT's name, window or the page name that's being tested, viewport width and height
                eyes.Open(driver, testInfo["appName"], testInfo["windowName"], new Size(
                              Int32.Parse(testInfo["viewportWidth"]), Int32.Parse(testInfo["viewportHeight"])));


                // Navigate the browser to the "hello world!" web-site.
                driver.Url = testInfo["url"];

                // Visual checkpoint #1.
                eyes.CheckWindow(testInfo["windowName"]);

                // End the test.
                eyes.Close();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
            finally
            {
                // Close the browser.
                driver.Quit();

                // If the test was aborted before eyes.Close was called, ends the test as aborted.
                eyes.AbortIfNotClosed();
            }
        }
コード例 #5
0
        public void Test5_DynamicContestTest()
        {
            Eyes eyes = new Eyes();

            eyes.ApiKey = Environment.GetEnvironmentVariable("APPLITOOLS_HACKATHON_API_KEY");

            eyes.Open(driver, appName, "Dynamic Content Test");
            //driver.Navigate().GoToUrl("https://demo.applitools.com/hackathon.html?showAd=true");
            driver.Navigate().GoToUrl("https://demo.applitools.com/hackathonV2.html?showAd=true");

            InduceDelay(1);
            eyes.CheckWindow();

            eyes.Close();
            eyes.AbortIfNotClosed();
        }
コード例 #6
0
ファイル: Demo.cs プロジェクト: ivyguo1002/Automation
            public void AfterEach()
            {
                // Close the browser.
                driver.Quit();

                // If the test was aborted before eyes.close was called, ends the test as aborted.
                eyes.AbortIfNotClosed();

                //Wait and collect all test results
                // we pass false to this method to suppress the exception that is thrown if we
                // find visual differences
                TestResultsSummary allTestResults = runner.GetAllTestResults(false);

                // Print results
                Console.WriteLine(allTestResults);
            }
コード例 #7
0
        private static void TestScrollRegion_(Size?size)
        {
            // Open a Chrome browser.
            var driver = new ChromeDriver();

            // Initialize the eyes SDK and set your private API key.
            var eyes = new Eyes();

            //var eyes = new Eyes(new Uri("https://test2eyes.applitools.com"));
            //eyes.ApiKey = "XucYP13zAM2eWJE7EoyBiojebKA6D9xMucHuPHGMeQ4110";
            //scroll and take full page screenshot
            eyes.ForceFullPageScreenshot = true;

            // Hard code the Applitools API key or get it from the environment (see the Tutorial for details)
            //eyes.ApiKey = "0rQly9ew54FfJWfpSCG5wIWAj0LCtQ5HNPpatwRNFQc110";
            try
            {
                driver.Url = "https://qa.servicetitan.com/";

                driver.FindElement(By.CssSelector("#username")).SendKeys("applitools");
                driver.FindElement(By.CssSelector("#password")).SendKeys("1234");

                driver.FindElement(By.CssSelector("#loginButton")).Click();


                WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(30));
                wait.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementToBeClickable(By.CssSelector("#navbar > div.ui.inverted.menu.extra-navigation > a:nth-child(4) > i"))).Click();
                wait.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementToBeClickable(By.CssSelector("#settingsMenu > button"))).Click();

                if (size.HasValue)
                {
                    eyes.Open(driver, "test", "check region", size.Value);
                }
                else
                {
                    eyes.Open(driver, "test", "check region");
                }
                eyes.Check("region", Target.Region(By.CssSelector("#settingsMenu")).Fully());
                eyes.Close();
            }
            finally
            {
                eyes.AbortIfNotClosed();
                driver.Quit();
            }
        }
コード例 #8
0
        public void Test2_DataDrivenTest(string userNameValue, string passwordValue, string alertMsgValue, string urlValue, string testNameValue)
        {
            Eyes eyes = new Eyes();

            eyes.ApiKey = Environment.GetEnvironmentVariable("APPLITOOLS_HACKATHON_API_KEY");
            BatchInfo batchInfo = new BatchInfo("Data Driven Test");

            batchInfo.Id = "DataDrivenTest";
            eyes.Batch   = batchInfo;
            string testValue = $"Data Driven Test - {testNameValue}";

            eyes.Open(driver, appName, testValue);
            InduceDelay(2);
            Console.WriteLine($"user name {userNameValue} - password {passwordValue} - alert msg {alertMsgValue}");

            if (!String.IsNullOrEmpty(userNameValue))
            {
                loginPageUIElements.userNameInput.Clear();
                loginPageUIElements.userNameInput.SendKeys(userNameValue);
            }

            if (!String.IsNullOrEmpty(passwordValue))
            {
                loginPageUIElements.passwordInput.Clear();
                loginPageUIElements.passwordInput.SendKeys(passwordValue);
            }

            loginPageUIElements.loginBtn.Click();

            InduceDelay(2);

            eyes.CheckWindow();

            try
            {
                loginPageUIElements.userNameInput.Clear();
                loginPageUIElements.passwordInput.Clear();
            }
            catch (NoSuchElementException)
            {
                Console.WriteLine("User name and password elements are not present");
            }

            eyes.Close();
            eyes.AbortIfNotClosed();
        }
コード例 #9
0
        public void Test3_TableSortTest()
        {
            Eyes eyes = new Eyes();

            eyes.ApiKey = Environment.GetEnvironmentVariable("APPLITOOLS_HACKATHON_API_KEY");

            InduceDelay(1);
            eyes.ForceFullPageScreenshot = true;
            eyes.Open(driver, appName, "Table Sort Test");

            landingPage.amountHeader.Click();
            InduceDelay(1);
            eyes.CheckWindow();

            eyes.Close();
            eyes.AbortIfNotClosed();
        }
コード例 #10
0
 public void afterTest()
 {
     if (eyes.IsOpen)
     {
         try
         {
             eyes.Close();
             eyes.AbortIfNotClosed();
         }
         catch (Exception e)
         {
             Configuration.driver.Close();
             Assert.Fail(e.Message);
         }
     }
     Configuration.driver.Close();
 }
コード例 #11
0
        public void AfterEachTest()
        {
            // check if an exception was thrown
            Boolean testPassed = TestContext.CurrentContext.Result.Outcome.Status != NUnit.Framework.Interfaces.TestStatus.Failed;

            if (testPassed)
            {
                // Close the Eyes instance, no need to wait for results, we'll get those at the end in afterTestSuite
                eyes.CloseAsync();
            }
            else
            {
                // There was an exception so the test may be incomplete - abort the test
                eyes.AbortIfNotClosed();
            }
            webDriver.Quit();
        }
コード例 #12
0
        public void TestSpecialRendering(string url, string testName)
        {
            string           logsPath   = TestUtils.InitLogPath();
            ILogHandler      logHandler = TestUtils.InitLogHandler(logPath: logsPath);
            VisualGridRunner runner     = new VisualGridRunner(30, logHandler);

            runner.DebugResourceWriter = new FileDebugResourceWriter(logsPath);

            Eyes eyes = new Eyes(runner);

            Configuration sconf = new Configuration();

            sconf.SetTestName(testName);
            sconf.SetAppName("Visual Grid Render Test");
            sconf.SetBatch(TestDataProvider.BatchInfo);

            sconf.AddDeviceEmulation(DeviceName.Galaxy_S5);
            sconf.AddBrowser(1200, 800, BrowserType.CHROME);
            sconf.AddBrowser(1200, 800, BrowserType.FIREFOX);

            // Edge doesn't support Shadow-DOM - returns an empty image.
            //sconf.AddBrowser(1200, 800, BrowserType.EDGE);

            // Internet Explorer doesn't support Shadow-DOM - fails to render and throws an error.
            //sconf.AddBrowser(1200, 800, BrowserType.IE_11);
            //sconf.AddBrowser(1200, 800, BrowserType.IE_10);

            eyes.SetConfiguration(sconf);
            ChromeDriver driver = SeleniumUtils.CreateChromeDriver();

            try
            {
                eyes.Open(driver);
                driver.Url = url;
                Thread.Sleep(500);
                eyes.Check(testName, Target.Window().Fully());
                eyes.Close(false);
                TestResultsSummary allResults = runner.GetAllTestResults(false);
            }
            finally
            {
                driver.Quit();
                eyes.AbortIfNotClosed();
                runner.StopServiceRunner();
            }
        }
コード例 #13
0
        public void TestVisualGridSkipList()
        {
            VisualGridRunner runner = new VisualGridRunner(10);
            Eyes             eyes   = new Eyes(runner);

            TestUtils.SetupLogging(eyes);
            eyes.visualGridEyes_.EyesConnectorFactory = new Mock.MockEyesConnectorFactory();

            Configuration config = eyes.GetConfiguration();

            config.AddBrowser(1050, 600, BrowserType.CHROME);
            config.SetBatch(TestDataProvider.BatchInfo);
            eyes.SetConfiguration(config);

            MockEyesConnector mockEyesConnector;

            IWebDriver driver = SeleniumUtils.CreateChromeDriver();

            driver.Url = "https://applitools.github.io/demo/DomSnapshot/test-iframe.html";
            try
            {
                mockEyesConnector = OpenEyesAndGetConnector_(eyes, config, driver);

                eyes.Check(Target.Window());
                string[] expectedUrls = new string[] {
                    "https://applitools.github.io/demo/DomSnapshot/test.css",
                    "https://applitools.github.io/demo/DomSnapshot/smurfs.jpg",
                    "https://applitools.github.io/blabla",
                    "https://applitools.github.io/demo/DomSnapshot/iframes/inner/smurfs.jpg",
                    "https://applitools.github.io/demo/DomSnapshot/test.html",
                    "https://applitools.github.io/demo/DomSnapshot/iframes/inner/test.html",
                    "https://applitools.github.io/demo/DomSnapshot/iframes/frame.html"
                };
                CollectionAssert.AreEquivalent(expectedUrls, runner.CachedBlobsURLs.Keys);
                eyes.Check(Target.Window());
                eyes.Close();

                runner.GetAllTestResults();
            }
            finally
            {
                eyes.AbortIfNotClosed();
                driver.Close();
            }
        }
コード例 #14
0
 public new void TearDown()
 {
     try
     {
         TestResults results = eyes_.Close();
         eyes_.Logger.Log("Mismatches: " + results.Mismatches);
         if (expectedIgnoreRegions_.Count > 0)
         {
             var sessionResults = TestUtils.GetSessionResults(eyes_.ApiKey, results);
             var ignoreRegions  = sessionResults.ActualAppOutput[0].ImageMatchSettings.Ignore;
             TestUtils.CompareSimpleRegionsList_(ignoreRegions, expectedIgnoreRegions_, "Ignore");
         }
     }
     finally
     {
         eyes_.AbortIfNotClosed();
     }
 }
コード例 #15
0
        public void Cleanup()
        {
            webDriver.Quit();

            IList categories = (IList)TestContext.CurrentContext.Test.Properties["Category"];

            if (categories.Count > 0)
            {
                foreach (string category in categories)
                {
                    if (category.Contains("Visual"))
                    {
                        Eyes.Close();
                        Eyes.AbortIfNotClosed();
                    }
                }
            }
        }
コード例 #16
0
        public static void Main(string[] args)
        {
            // Open a Chrome browser.
            var driver = new ChromeDriver();

            // Initialize the eyes SDK and set your private API key.
            var eyes = new Eyes();

            eyes.ApiKey = "hTP9KIw4l9LKUGxlQdod46b4vRRvOaF8UfGOs1RmYyo110";

            try
            {
                // Start the test and set the browser's viewport size to 800x600.
                eyes.Open(driver, "Hello World!", "My first Selenium C# test!", new Size(800, 600));

                // Navigate the browser to the "hello world!" web-site.
                driver.Url = "https://www.agoda.com";

                // Visual checkpoint #1.
                eyes.CheckWindow("RESORT");

                // Click the "Click me!" button.
                driver.FindElement(By.XPath("//*[@data-selenium='homesTab']")).Click();

                // Visual checkpoint #2.
                eyes.CheckWindow("RESORT");

                // End the test.
                eyes.Close();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
            finally
            {
                // Close the browser.
                driver.Quit();

                // If the test was aborted before eyes.Close was called, ends the test as aborted.
                eyes.AbortIfNotClosed();
            }
        }
コード例 #17
0
        public void Trello_1846_Duda_32648()
        {
            Eyes eyes = new Eyes();

            TestUtils.SetupLogging(eyes);

            eyes.SendDom                 = false;
            eyes.MatchTimeout            = TimeSpan.Zero;
            eyes.ForceFullPageScreenshot = true;

            IWebDriver driver = SeleniumUtils.CreateChromeDriver();

            try
            {
                IWebDriver innerDriver = eyes.Open(driver, "Duda", "Duda Issue 3", new Size(937, 904));
                innerDriver.Url = "https://editor-sandbox.duda.co/login";
                innerDriver.FindElement(By.CssSelector("#j_username")).SendKeys("*****@*****.**");
                innerDriver.FindElement(By.CssSelector("body > div.signupBodyInner > div.signupBox > div > form > div:nth-child(2) > input[type=password]")).SendKeys("qwer7890");
                innerDriver.FindElement(By.CssSelector("body > div.signupBodyInner > div.signupBox > div > form > input")).Click();
                Thread.Sleep(1000);
                innerDriver.FindElement(By.CssSelector("div._draggable.freestylePopupBody.ui-draggable > div > div > div > span > span > svg")).Click();
                innerDriver.SwitchTo().Frame(0);
                innerDriver.FindElement(By.CssSelector("#trial-action")).Click();
                Thread.Sleep(1000);
                innerDriver.SwitchTo().DefaultContent();
                //By frame =  By.ClassName("OldDashboard-iframe-2bj");
                innerDriver.SwitchTo().Frame(0);
                By          scrollMain      = By.CssSelector("div.scrollable--main");
                By          scrollInner     = By.CssSelector("div.scrollableInner");
                By          region          = By.CssSelector("#accountPlanPopupWrapper > div > div > div > div.accountPlanContent > div > div > div");
                IWebElement scrollMainElem  = driver.FindElement(scrollMain);
                IWebElement scrollInnerElem = driver.FindElement(scrollInner);
                IWebElement regionElem      = driver.FindElement(region);
                eyes.Check("frame fully ", Target.Region(scrollInner).ScrollRootElement(scrollInner).Fully());
                innerDriver.SwitchTo().DefaultContent();
                eyes.Close();
            }
            finally
            {
                driver.Quit();
                eyes.AbortIfNotClosed();
            }
        }
コード例 #18
0
        public void Ticket_1561_GovIL()
        {
            var driver = new ChromeDriver();
            var eyes   = new Eyes();

            eyes.SetLogHandler(new StdoutLogHandler());
            try
            {
                eyes.Open(driver, "GovIL", "#31542", new Size(1680, 895));
                driver.Url = "https://www.gov.il/he/departments/policies/26122019";
                eyes.Check("Step 1", Target.Region(By.CssSelector("#accordion-files")));
                eyes.Close();
            }
            finally
            {
                driver.Quit();
                eyes.AbortIfNotClosed();
            }
        }
コード例 #19
0
        public void TestFullWindowInCorrectLocationAfterRetry()
        {
            WebDriverProvider       webdriverProvider      = new WebDriverProvider();
            IServerConnectorFactory serverConnectorFactory = new MockServerConnectorFactory(webdriverProvider);
            Eyes eyes = new Eyes(serverConnectorFactory);

            eyes.Batch = TestDataProvider.BatchInfo;
            TestUtils.SetupLogging(eyes);
            MockServerConnector mockServerConnector = (MockServerConnector)eyes.seleniumEyes_.ServerConnector;

            mockServerConnector.AsExpected = false;
            IWebDriver driver = SeleniumUtils.CreateChromeDriver();

            webdriverProvider.SetDriver(driver);
            driver.Url = "https://applitools.github.io/demo/TestPages/FramesTestPage/";
            try
            {
                eyes.Open(driver, "DotNet Tests", nameof(TestFullWindowInCorrectLocationAfterRetry), new Size(700, 460));
                driver.FindElement(By.TagName("input")).SendKeys("Different Input");
                eyes.Check(Target.Window().Fully());
                eyes.Close();
            }
            finally
            {
                eyes.AbortIfNotClosed();
                driver.Quit();
            }
            Assert.AreEqual(1, mockServerConnector.MatchWindowCalls.Count, "Matches");
            Assert.AreEqual(0, mockServerConnector.ReplaceMatchedStepCalls.Count, "Replacements");
            byte[] screenshotBytes = mockServerConnector.ImagesAsByteArrays[0];
            string finalImageHash  = screenshotBytes.GetSha256Hash();

            if (finalImageHash != "0EEBFD0FCDE40BA1FB5D4B8C4DA535F3C846B2E1685C84488E43FC6DC6ECD88A" && // Windows
                finalImageHash != "5E771AB31BA0D3232E370FDA5E630A649E0E03FA704243BBD288303B4D9064B3" && // Windows with different Antialiasing
                finalImageHash != "35D38A5CE5571F4D2AB4C543FB7CDB2EDC85A82C2472A8F062700637DE8BCF30" && // Windows, Chrome >= 87
                finalImageHash != "CAE9ADB9A45932BF9DEA51972A6B69908D012324E0CB4B2A93368CDD3C8E56D2" && // Linux, Chrome >=85
                finalImageHash != "993DB6CB4EC9D93AB5A7F0F598F179DADBB562A5E6A31BFAA6211C809BA5C9BB" && // Linux, Chrome >=87
                finalImageHash != "53CD94D4450FF82825C8B36A04E0BC68B32BACFB4F09019294D907AF0080F6E5")   // Linux, Chrome >=89
            {
                Assert.Fail("Different image than expected. Hash: {0}\nBase64:\n{1}\n", finalImageHash,
                            string.Join("\n", Convert.ToBase64String(screenshotBytes).Split(160)));
            }
        }
コード例 #20
0
        public void TestUFGVisualViewport()
        {
            JsonSerializer serializer = JsonUtils.CreateSerializer();
            IWebDriver     driver     = SeleniumUtils.CreateChromeDriver();
            EyesRunner     runner     = new VisualGridRunner(10);
            Eyes           eyes       = new Eyes(runner);

            TestUtils.SetupLogging(eyes);
            Configuration config        = eyes.GetConfiguration();
            IosDeviceInfo iosDeviceInfo = new IosDeviceInfo(IosDeviceName.iPhone_11_Pro);

            config.AddBrowser(iosDeviceInfo);
            eyes.SetConfiguration(config);
            try
            {
                eyes.Open(driver, "Eyes Selenium SDK", "Eyes Selenium SDK - UFG Visual Viewport Test");

                string inputJson = CommonUtils.ReadResourceFile("Test.Eyes.Selenium.DotNet.Resources.Misc.TestUFGVisualViewport_Input.json");
                RenderStatusResults renderStatusResults = serializer.Deserialize <RenderStatusResults>(inputJson);

                driver.Url = "https://applitools.github.io/demo/TestPages/DynamicResolution/desktop.html";
                eyes.Check(Target.Window().Fully());
                eyes.Close(false);

                TestResultsSummary resultsSummary = runner.GetAllTestResults(false);
                Assert.AreEqual(1, resultsSummary.Count);
                TestResults    results        = resultsSummary[0].TestResults;
                SessionResults sessionResults = TestUtils.GetSessionResults(eyes.ApiKey, results);

                Assert.AreEqual(1, sessionResults.ActualAppOutput.Length);
                ActualAppOutput appOutput = sessionResults.ActualAppOutput[0];
                Assert.AreEqual(980, appOutput.Image.Viewport.Width);
                Assert.AreEqual(1659, appOutput.Image.Viewport.Height);

                Assert.AreEqual(375, sessionResults.Env.DisplaySize.Width);
                Assert.AreEqual(812, sessionResults.Env.DisplaySize.Height);
            }
            finally
            {
                eyes.AbortIfNotClosed();
                driver.Quit();
            }
        }
コード例 #21
0
ファイル: Hooks.cs プロジェクト: VinnyIla/AppliToolsHackathon
        public void AfterScenario()
        {
            IWebDriver driver = null;

            try
            {
                driver = (IWebDriver)ScenarioContext.Current["WEBDRIVER"];
                driver.Close();
                driver.Quit();
                driver = null;
            }
            catch (Exception e)
            {
                Console.WriteLine($"Selenium Web Driver not found to dispose. {e.Message}");
            }

            finally
            {
                ScenarioContext.Current["WEBDRIVER"] = null;

                Console.WriteLine("After Scenario - Test Completed");
            }


            //Close Eyes
            try
            {
                EyesRunner runner = (EyesRunner)ScenarioContext.Current["EYESRUNNER"];
                Eyes       eyes   = (Eyes)ScenarioContext.Current["EYES"];

                eyes.CloseAsync();

                // If the test was aborted before eyes.close was called, ends the test as aborted.
                eyes.AbortIfNotClosed();

                //Wait and collect all test results
                TestResultsSummary allTestResults = runner.GetAllTestResults();
            }catch (Exception e)
            {
            }
        }
コード例 #22
0
        public void TestNotepad()
        {
            Process notepad = Process.Start("notepad");

            // Open notepad
            WinWindow testApp = new WinWindow();

            testApp.SearchProperties[WinWindow.PropertyNames.ClassName] = "Notepad";

            // Initialize the eyes SDK and set your private API key.
            var eyes = new Eyes();

            eyes.SetLogHandler(new FileLogHandler(@"c:\temp\logs\codedui_notepad_test.log", true, true));

            try
            {
                // Start the test and set the application's viewport size to 800x600
                eyes.Open(testApp, "Hello World!", "My first CodedUI C# test", new Size(800, 600));

                // Visual checkpoint #1
                eyes.CheckWindow("Hello!");

                // Write something
                WinEdit edit = new WinEdit(testApp);
                Keyboard.SendKeys("Applitools CodedUI Demo");

                // Visual checkpoint #2
                eyes.CheckWindow("Write!");

                // End the test
                eyes.Close();
            }
            finally
            {
                // Close the app.
                notepad.CloseMainWindow();

                // If the test was aborted before eyes.Close was called, ends the test as aborted.
                eyes.AbortIfNotClosed();
            }
        }
コード例 #23
0
        public void TestGithub()
        {
            var eyes = new Eyes();

            eyes.SetLogHandler(new StdoutLogHandler(true));
            eyes.BranchName = "demo";

            HtmlHyperlink pricingHyperlink = UIMap.UIGoogleWindowsInterneWindow
                                             .UIGitHubEnterpriseGitrDocument.UIPricingHyperlink;
            HtmlHyperlink faqHyperlink = UIMap.UIGoogleWindowsInterneWindow
                                         .UIPricingGitHubEnterprDocument.UIFAQHyperlink;
            HtmlHyperlink supportHyperlink = UIMap.UIGoogleWindowsInterneWindow
                                             .UIFAQGitHubEnterpriseDocument.UISupportHyperlink;
            HtmlHyperlink contactHyperlink = UIMap.UIGoogleWindowsInterneWindow
                                             .UISupportGitHubEnterprDocument.UIContactHyperlink;
            HtmlHyperlink homeHyperlink = UIMap.UIGoogleWindowsInterneWindow
                                          .UIContactusGitHubEnterDocument.UIHomeHyperlink;

            UIMap.UIGoogleWindowsInterneWindow.LaunchUrl(
                new Uri("https://enterprise.github.com/"));

            eyes.Open(
                UIMap.UIGoogleWindowsInterneWindow, "Github", "Browse Tabs", new Size(1000, 700));
            try
            {
                eyes.CheckWindow("Home");

                Mouse.Click(pricingHyperlink, new Point(38, 17));
                eyes.CheckWindow("Pricing");

                Mouse.Click(supportHyperlink, new Point(38, 17));
                eyes.CheckWindow("Support");

                eyes.Close();
            }
            finally
            {
                eyes.AbortIfNotClosed();
            }
        }
コード例 #24
0
        public void TestHelloWorld()
        {
            // Open a browser
            BrowserWindow testBrowser = BrowserWindow.Launch();

            // Initialize the eyes SDK and set your private API key.
            var eyes = new Eyes();

            try
            {
                // Start the test and set the browser's viewport size to 800x600
                eyes.Open(testBrowser, "Hello World!", "My first CodedUI C# test", new Size(800, 600));

                // Navigate the browser to the "hello world!" web-site.
                testBrowser.NavigateToUrl(new Uri("https://applitools.com/helloworld"));

                // Visual checkpoint #1
                eyes.CheckWindow("Hello!");

                // Click the "Click me!" button
                HtmlDocument doc    = new HtmlDocument(testBrowser);
                HtmlButton   button = new HtmlButton(doc);
                Mouse.Click(button);

                // Visual checkpoint #2
                eyes.CheckWindow("Click!");

                // End the test
                eyes.Close();
            }
            finally
            {
                // Close the browser.
                testBrowser.Close();

                // If the test was aborted before eyes.Close was called, ends the test as aborted.
                eyes.AbortIfNotClosed();
            }
        }
コード例 #25
0
        public void TestFullWindowInCorrectLocationAfterRetry()
        {
            IServerConnectorFactory serverConnectorFactory = new MockServerConnectorFactory();
            Eyes eyes = new Eyes(serverConnectorFactory);

            eyes.Batch = TestDataProvider.BatchInfo;
            TestUtils.SetupLogging(eyes);
            MockServerConnector mockServerConnector = (MockServerConnector)eyes.seleniumEyes_.ServerConnector;

            mockServerConnector.AsExcepted = false;
            IWebDriver driver = SeleniumUtils.CreateChromeDriver();

            driver.Url = "https://applitools.github.io/demo/TestPages/FramesTestPage/";
            try
            {
                eyes.Open(driver, "DotNet Tests", nameof(TestFullWindowInCorrectLocationAfterRetry), new Size(700, 460));
                driver.FindElement(By.TagName("input")).SendKeys("Different Input");
                eyes.Check(Target.Window().Fully());
                eyes.Close();
            }
            finally
            {
                eyes.AbortIfNotClosed();
                driver.Quit();
            }
            Assert.AreEqual(1, mockServerConnector.MatchWindowCalls.Count, "Matches");
            Assert.AreEqual(0, mockServerConnector.ReplaceMatchedStepCalls.Count, "Replacements");
            byte[] screenshotBytes = mockServerConnector.MatchWindowCalls[0].AppOutput.ScreenshotBytes;
            string finalImageHash  = screenshotBytes.GetSha256Hash();

            if (finalImageHash != "1C2E890355934CF44F070D1F8199E0AF390275E9D82ED82A898C8172406555E9" && // Windows
                finalImageHash != "0DC273FEF58C6E4B2563DF2078347B32EFC702E96E11D782E3664F0690881E6B" && // Windows with different Antialiasing
                finalImageHash != "1FCC19630668582400BD59119FDF4692707B67A524DEB2F8047D96C9E56CC074" && // Linux, Chrome <85
                finalImageHash != "FCBE40C10CFD01E9F86084F655708226E53B98508F1696CBAEEF158CA20CDD78")   // Linux, Chrome >=85
            {
                Assert.Fail("Different image than expected. Hash: {0}\nBase64:\n{1}\n", finalImageHash,
                            string.Join('\n', Convert.ToBase64String(screenshotBytes).Split(160)));
            }
        }
コード例 #26
0
        public static void Main(string[] args)
        {
            DesiredCapabilities caps = new DesiredCapabilities();

            caps.SetCapability("browserName", "Firefox");
            caps.SetCapability("username", "YOUR_SAUCE_USERNAME");
            caps.SetCapability("accessKey", "YOUR_SAUCE_ACCESS_KEY");
            IWebDriver driver = new RemoteWebDriver(new Uri("https://ondemand.saucelabs.com:443/wd/hub"), caps, TimeSpan.FromSeconds(600));

            // This is your api key, make sure you use it in all your tests.
            var eyes = new Eyes();

            eyes.ApiKey = "YOUR_API_KEY";

            try
            {
                // Start visual testing with browser viewport set to 1024x768.
                // Make sure to use the returned driver from this point on.
                driver = eyes.Open(driver, "Applitools", "Test Web Page", new Size(1024, 768));

                driver.Navigate().GoToUrl("http://www.applitools.com");

                // Visual validation point #1
                eyes.CheckWindow("Main Page");

                driver.FindElement(By.CssSelector(".features>a")).Click();

                // Visual validation point #2
                eyes.CheckWindow("Features Page");

                // End visual testing. Validate visual correctness.
                eyes.Close();
            }
            finally
            {
                eyes.AbortIfNotClosed();
                driver.Quit();
            }
        }
コード例 #27
0
ファイル: UnitTest1.cs プロジェクト: h-4vok/appium-practice
        public void TestMethod11()
        {
            var notepad = @"C:\Windows\System32\notepad.exe";

            var options = new AppiumOptions();

            options.AddAdditionalCapability("app", notepad);

            var driver = new WindowsDriver <WindowsElement>(new Uri(" http://127.0.0.1:4723/"), options);

            driver.Manage().Window.Maximize();

            var textEditor = driver.FindElementByAccessibilityId("15");

            textEditor.SendKeys("ABCDEF");

            var eyes = new Eyes();

            eyes.ApiKey = "lFMnO9e1nbFQEdhebrDmhEBOqB7jXUXJGogj103lRWAzM110";
            eyes.SetAppEnvironment("Windows 10", null);

            try
            {
                eyes.Open("AppiumPractice", "TestMethod11");
                Thread.Sleep(3000);
                var currentAppScreenshot = driver.GetScreenshot();
                var croppedScreenshot    = CropScreenshotWithRect(currentAppScreenshot, textEditor);
                var croppedScreenshot2   = CropScreenshotOf2(croppedScreenshot, new Rectangle(900, 0, textEditor.Size.Width - 900, textEditor.Size.Height));

                eyes.CheckImage(croppedScreenshot2, "Cropped Text Editor");

                eyes.Close();
            }
            finally
            {
                eyes?.AbortIfNotClosed();
                driver.Quit();
            }
        }
コード例 #28
0
        public void Trello_1722_LampsPlus()
        {
            Eyes eyes = new Eyes();

            eyes.StitchMode = StitchModes.CSS;
            TestUtils.SetupLogging(eyes);

            IWebDriver driver = new ChromeDriver();

            try
            {
                eyes.Open(driver, "LampsPlus", "Bug", new Size(800, 600));

                driver.Url = "https://www.lampsplus.com/products/juno-close-up-3-light-white-par30-floating-canopy-track-kit__68e68.html";

                // Visual checkpoint #1 - Check the login page.
                //eyes.CheckWindow("Login Page");
                var wait    = new WebDriverWait(driver, new TimeSpan(0, 0, 30));
                var element = wait.Until(ExpectedConditions.ElementIsVisible(By.Id("pdAddToCart")));

                // This will create a test with two test steps.
                driver.FindElement(By.Id("pdAddToCart")).Click();

                element = wait.Until(ExpectedConditions.ElementIsVisible(By.Id("cartPromotionalCode")));
                driver.FindElement(By.Id("cartPromotionalCode")).Click();
                //element = wait.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementIsVisible(By.ClassName("promoInput")));

                eyes.Check("Window", Target.Window().Fully().Ignore(By.Id("cartId")));
                eyes.Check("Region", Target.Region(By.Id("cartOverview")).Fully().Ignore(By.Id("cartId")));

                // End the test.
                eyes.Close(false);
            }
            finally
            {
                eyes.AbortIfNotClosed();
                driver.Quit();
            }
        }
コード例 #29
0
        public void ShoppingExperienceTest()
        {
            Eyes eyes = new Eyes(runner);

            eyes.SetConfiguration(suiteConfig);
            eyes.Open(webDriver, "Filter Results", "Task 2", new System.Drawing.Size(800, 600));

            //Click on the filter menu
            webDriver.FindElement(By.XPath(HomePage.filtersAnchorInTabletMode)).Click();
            InduceDelay(2);
            //Click the Black check box in filter panel
            webDriver.FindElement(By.XPath(HomePage.blackColorCheckBoxInTableMode)).Click();
            InduceDelay(2);
            //Click on Filter button
            webDriver.FindElement(By.XPath(HomePage.filterButton)).Click();
            InduceDelay(2);
            eyes.CheckWindow();
            eyes.Check("Product Grid", Target.Region(By.Id("product_grid")));

            eyes.Close();

            eyes.AbortIfNotClosed();
        }
コード例 #30
0
        public void IEDriverTest(string driverVersion)
        {
            var runner = new ClassicRunner();
            var driver = new InternetExplorerDriver(@"C:\Users\USER\Downloads\IEDrivers\" + driverVersion);

            var eyes = new Eyes(runner);

            TestUtils.SetupLogging(eyes);

            try
            {
                eyes.Open(driver, "IE", "IEDriverServer version " + driverVersion);
                driver.Url = "https://applitools.com";
                eyes.Check(Target.Window());
                eyes.Close();
            }
            finally
            {
                runner.GetAllTestResults();
                driver.Quit();
                eyes.AbortIfNotClosed();
            }
        }