コード例 #1
0
    // Update is called once per frame
    void FixedUpdate()
    {
        //Vector2 gaze = new Vector2 (Tracker.EyePos.x , Tracker.EyePos.y);
        if (Renderer == null)
        {
            return;
        }
        string gazeStr = "";

        if (UseMouse)
        {
            gaze = new Vector2((float)Input.mousePosition.x / (float)Screen.width, 1 - (float)Input.mousePosition.y / (float)Screen.height);

            //gaze = ScreenToField (gaze);

            /*
             * gaze.x +=dir*speed ;
             * if (gaze.x < 0 || gaze.x > 1) {
             *      dir = -dir;
             *      Mathf.Clamp01 (gaze.x);
             * }
             * gaze.y = 0.5f;*/

            for (int i = 0; i < _GazeList.Length; ++i)
            {
                gazeStr += (gaze.x).ToString() + "," + (gaze.y).ToString();
                if (i != _GazeList.Length - 1)
                {
                    gazeStr += ",";
                }
            }
        }
        else
        {
            _GazeList[0] = Tracker.GetEyeGaze(PupilGazeTracker.GazeSource.BothEyes);
            _GazeList[1] = Tracker.GetEyeGaze(PupilGazeTracker.GazeSource.BothEyes);

            //must convert to screenspace first
            //var g = gaze;//ScreenToField (gaze);
            for (int i = 0; i < _GazeList.Length; ++i)
            {
                var g = new Vector2(_GazeList[i].x, 1 - (_GazeList[i].y));
                gazeStr += (g.x).ToString() + "," + (g.y).ToString();
                if (i != _GazeList.Length - 1)
                {
                    gazeStr += ",";
                }
            }
        }
        Robot.Connector.SendData(TxKitEyes.ServiceName, "Gaze", gazeStr, false);


        if (screen)
        {
            _imageshot.TakeScreenshot(Renderer.Results[0].CombinedTexture, Application.dataPath + "\\.screenShots\\");
            _imageshot.TakeScreenshot(Renderer.Results[0].OriginalTexture, Application.dataPath + "\\.screenShots\\");
            screen = false;
        }
    }
コード例 #2
0
        public static void ExceptionLog(string message)
        {
            string screenName     = ScreenshotHelper.TakeScreenshot();
            string screenShotPath = TestReport.AddScreenCapture(screenName);

            TestReport.Log(LogStatus.Warning, screenShotPath + message);
        }
コード例 #3
0
ファイル: ExceptionPolicy.cs プロジェクト: jpreecedev/WebCal
        public static string HandleException(IUnityContainer container, Exception exception)
        {
            if (exception == null)
            {
                return(string.Empty);
            }

            try
            {
                container.Resolve <IRepository <DetailedException> >().Add(new DetailedException
                {
                    ApplicationName  = AppDomain.CurrentDomain.FriendlyName,
                    ExceptionDetails = string.Format("{0}\n{1}", exception.Message, exception.StackTrace),
                    Occurred         = DateTime.Now,
                    RawImage         = ScreenshotHelper.TakeScreenshot()
                });
            }
            catch (Exception ex)
            {
                if (string.Equals(Resources.ERR_UNABLE_FIND_DATA_PROVIDER, ex.Message))
                {
                    MessageBoxHelper.ShowError(string.Format("{0}\n\n{1}", Resources.ERR_UNABLE_FIND_SQL_CE, ex.Message));
                    Application.Exit();
                }
                else
                {
                    MessageBoxHelper.ShowError(ex.Message);
                }
            }

            return(GetExceptionMessage(exception));
        }
コード例 #4
0
        public void BaseCleanup()
        {
            var status     = TestContext.CurrentContext.Result.Outcome.Status;
            var stacktrace = string.IsNullOrEmpty(TestContext.CurrentContext.Result.StackTrace)
                    ? ""
                    : string.Format("<pre>{0}</pre>", TestContext.CurrentContext.Result.Message);
            LogStatus logstatus;

            switch (status)
            {
            case TestStatus.Failed:
                logstatus = LogStatus.Fail;
                string screenName     = ScreenshotHelper.TakeScreenshot();
                string screenshotPath = TestLog.AddScreenCapture("screenshots//" + screenName);
                TestLog.Log(LogStatus.Fail, "Screenshot on Fail", screenshotPath);
                break;

            case TestStatus.Inconclusive:
                logstatus = LogStatus.Warning;
                TestLog.Log(LogStatus.Warning, "Warning");
                break;

            case TestStatus.Skipped:
                logstatus = LogStatus.Skip;
                break;

            default:
                logstatus = LogStatus.Pass;
                break;
            }
            Browser.Close();
            TestLog.Log(logstatus, "Test ended with <b>" + logstatus + stacktrace);
            ReportLog.EndTest(TestLog);
            ReportLog.Flush();
        }
コード例 #5
0
    private IEnumerator ExportLayers <T>(List <T> layers, ScreenshotHelper screenshot, Progress progress, string exportPath) where T : PatchMapLayer
    {
        // Export each individual layer
        int size = layers.Count;

        for (int i = 0; i < size; ++i)
        {
            string name = layers[i].name;
            if (layers[i].PatchData.patch != null)
            {
                name = layers[i].PatchData.patch.DataLayer.Name;
            }

            if (!progress.Update("Exporting layer (" + (i + 1) + "/" + size + "): " + name + " ..."))
            {
                yield break;
            }

            layers[i].Show(true);

            var filename = exportPath + name + "_" + imgSize.ToString() + ".png";
            yield return(screenshot.TakeScreenshot(filename, exportWidth, exportHeight, false));

            layers[i].Show(false);
        }
    }
コード例 #6
0
 public void AfterWebTest()
 {
     if (ScenarioContext.Current.TestError != null)
     {
         ScreenshotHelper.TakeScreenshot(driver);
     }
 }
コード例 #7
0
        public void TakeScreenshotTest()
        {
            Driver.Url = "https://www.google.com";
            var name = $"screenshot-{DateTime.Now.Second}";

            ScreenshotHelper.TakeScreenshot(Driver, screenshotFileName: name);
            Assert.IsTrue(File.Exists($"C:\\Users\\james\\Desktop\\Screenshots\\{name}.png"), "The screenshot doesn't exist in the specified file location.");
        }
コード例 #8
0
 public void AfterScenario()
 {
     if (ScenarioContext.Current.TestError != null)
     {
         _screenshotHelper.TakeScreenshot(_driver);
     }
     _driver?.Quit();
     DriverHolder.Utilize();
 }
コード例 #9
0
        public void TakeScreenshotNoProvidedNameTest()
        {
            var date = DateTime.Now;

            Driver.Url = "https://www.google.com";
            ScreenshotHelper.TakeScreenshot(Driver);
            var files = Directory.GetFiles("C:\\Users\\james\\Desktop\\Screenshots\\", $"{date.Month}{date.Day}{date.Year}*", SearchOption.TopDirectoryOnly);

            Assert.IsTrue(files.Length > 0, "The screenshot doesn't exist in the specified file location.");
        }
コード例 #10
0
        public void TearDown()
        {
            if (TestContext.CurrentContext.Result.Outcome != ResultState.Success)
            {
                Console.WriteLine("Saving screenshot for failed test");
                ScreenshotHelper.TakeScreenshot();
            }

            DriverManager.Current.Driver.Manage().Cookies.DeleteAllCookies();
            DriverManager.Current.Driver.Navigate().GoToUrl(Constants.ServiceUrl);
        }
コード例 #11
0
 public static void ButtonIsDisabled(By locator)
 {
     try
     {
         Assert.IsNotNull(Driver.GetClickableElement((locator)).GetAttribute("disabled"));
     }
     catch (AssertionException e)
     {
         string screenName     = ScreenshotHelper.TakeScreenshot();
         string scrrenShotPath = TestReport.AddScreenCapture(screenName);
         TestReport.Log(LogStatus.Warning, scrrenShotPath + "Button is not disabled: " + e.Message);
     }
 }
コード例 #12
0
 public static void IsNotPresent(By locator)
 {
     try
     {
         Assert.IsFalse(ElementPresentBool(locator));
         TestReport.Log(LogStatus.Pass, "Element is not present: " + locator);
     }
     catch (AssertionException e)
     {
         string screenName     = ScreenshotHelper.TakeScreenshot();
         string screenShotPath = TestReport.AddScreenCapture(screenName);
         TestReport.Log(LogStatus.Warning, screenShotPath + "<br> Element is not present: " + e.Message);
     }
 }
コード例 #13
0
 public static void TitleIsPresent(string title)
 {
     try
     {
         (new WebDriverWait(Driver.Instance, TimeSpan.FromSeconds(10))).Until(ExpectedConditions.TitleContains(title));
         Assert.AreEqual(title, Driver.Instance.Title);
         TestReport.Log(LogStatus.Pass, "Title is present: " + title);
     }
     catch (AssertionException e)
     {
         string screenName     = ScreenshotHelper.TakeScreenshot();
         string scrrenShotPath = TestReport.AddScreenCapture(screenName);
         TestReport.Log(LogStatus.Warning, scrrenShotPath + "Title verification failed: " + e.Message);
     }
 }
コード例 #14
0
 public static void AreEqual(By locator, string elementName)
 {
     try
     {
         element = Driver.GetVisibleElement(locator);
         Assert.AreEqual(elementName, Driver.Instance.FindElement(locator).Text.Trim());
         TestReport.Log(LogStatus.Pass, "Element '" + elementName + "' is equal to '" + element.Text + "'");
     }
     catch (AssertionException e)
     {
         string screenName     = ScreenshotHelper.TakeScreenshot();
         string screenShotPath = TestReport.AddScreenCapture(screenName);
         TestReport.Log(LogStatus.Warning, screenShotPath + "<br> Element is not equal: " + e.Message);
     }
 }
コード例 #15
0
 public static void IsPresent(By locator)
 {
     //Driver.Instance.FindElement(locator);
     try
     {
         element = Driver.GetVisibleElement(locator);
         Assert.IsTrue(ElementPresentBool(locator));
         TestReport.Log(LogStatus.Pass, "Element is present: " + locator.ToString());
     }
     catch (AssertionException e)
     {
         string screenName     = ScreenshotHelper.TakeScreenshot();
         string screenShotPath = TestReport.AddScreenCapture(screenName);
         TestReport.Log(LogStatus.Warning, screenShotPath + "<br> Element is not present: " + e.Message);
     }
 }
コード例 #16
0
        /// <summary>
        /// Take a screenshot of the current browser UI
        /// </summary>
        /// <param name="targetFileName">The name of the file to save the results as, **excluding any file extension**</param>
        /// <param name="imageOverlayText">If required, any text to overlay on the image, such as the contents of a dialog message</param>
        /// <param name="isHappyPathImage">If set to true, the text will be green, otherwise it will be red</param>
        protected void TakeScreenshot(string targetFileName, string imageOverlayText = "", bool isHappyPathImage = false)
        {
            string dialogMessage;

            if (Session.DriverSession.Driver.IsAlertBoxDisplayed(out dialogMessage))
            {
                string errorMessage =
                    $"Unable to create a screenshot due to an unhandled popup with following message - {dialogMessage}";
                LogX.Error.Write(errorMessage);
                Console.Error.WriteLine(errorMessage);
                throw new WebDriverException(errorMessage);
            }
            string fullSavePath = Path.Combine(GetTestResultsPathWithTestName(true), targetFileName.SanitiseFilename());

            ScreenshotHelper.TakeScreenshot(Session.DriverSession.Driver, fullSavePath, imageOverlayText, isHappyPathImage);
        }
コード例 #17
0
    private IEnumerator ExportLayers <T>(List <T> layers, ScreenshotHelper screenshot, Progress progress, string exportPath) where T : MapLayer
    {
        // Export each individual layer
        int size = layers.Count;

        for (int i = 0; i < size; ++i)
        {
            string name       = layers[i].name;
            var    patchLayer = layers[i] as PatchMapLayer;
            if (patchLayer != null && patchLayer.PatchData.patch != null)
            {
                name = patchLayer.PatchData.patch.DataLayer.Name;
            }

            if (!progress.Update("Exporting layer (" + (i + 1) + "/" + size + "): " + name + " ..."))
            {
                yield break;
            }

            layers[i].Show(true);
            if (layers[i] is SnapshotMapLayer)
            {
                ShowSnapshotLegendItem(i, true);
                yield return(new WaitForFrames(2));
            }
            else if (!(layers[i] is ContoursMapLayer))
            {
                ShowDataLayerLegendItem(i, true);
                yield return(new WaitForFrames(2));
            }

            var filename = exportPath + name + "_" + imgSize.ToString() + ".png";
            yield return(screenshot.TakeScreenshot(filename, exportWidth, exportHeight, !(layers[i] is ContoursMapLayer)));

            layers[i].Show(false);
            if (layers[i] is SnapshotMapLayer)
            {
                ShowSnapshotLegendItem(i, false);
                yield return(new WaitForFrames(2));
            }
            else if (!(layers[i] is ContoursMapLayer))
            {
                ShowDataLayerLegendItem(i, false);
                yield return(new WaitForFrames(2));
            }
        }
    }
コード例 #18
0
        public void DI_Resident_History___Assessments_display_on_Residents_History_Grid()
        {
            Browser.Open();
            LoginPage.SignIn();
            //Step 1  Select Resident History tile
            LandingPage.NavigateToResidentHistoryPage();
            //Step 2  Click SEARCH button
            Driver.ClickOn(SearchResidentsPage.searchButton);
            //Step 3  Select resident tile from the FIRST page
            Driver.ClickOn(SearchResidentsPage.firstResidentTile);
            //Step 4  Click CREATE MDS button
            Driver.ClickOn(ResidentsHistoryPage.createNewMDSBtn);
            SchedulePage.VistALogin();
            //Step 5  Create New MDS Assessment
            Driver.ClickOn(SchedulePage.carePlanReviewDateCalendar);
            Driver.ClickOn(SchedulePage.calendarTodayBtn);
            Driver.ClickOn(SchedulePage.a1600EntryDateCalendar);
            Driver.ClickOn(SchedulePage.calendarTodayBtn);
            Driver.ClickOn(SchedulePage.a01RadioBtn);
            Driver.ClickOn(SchedulePage.b02RadioBtn);
            Driver.ClickOn(SchedulePage.f99RadioBtn);
            Driver.ClickOn(SchedulePage.createNewMDSCreateBtnEnabled);
            VerifyElement.AreEqual(SchedulePage.assessmentHeader, "Assessment Header");
            //Step 6  Click Residents History link
            Driver.WaitForElement(By.XPath("//a[@class='ng-binding ng-scope'][contains(., 'History')]"));
            string aType1 = Driver.Instance.FindElement(By.XPath("(//p[@class='form-control-static ng-binding'])[1]")).Text.ToString();

            Driver.ClickOn(By.XPath("//a[@class='ng-binding ng-scope'][contains(., 'History')]"));
            VerifyElement.AreEqual(ResidentsHistoryPage.pageHeader, "Resident's History");
            string aType2 = Driver.Instance.FindElement(By.XPath("(//span[@class='lead ng-binding ng-scope'])[last()]//preceding-sibling::span")).Text.ToString();
            string aType3 = Driver.Instance.FindElement(By.XPath("(//span[@class='lead ng-binding ng-scope'])[last()]")).Text.ToString();
            //Step 7  Verify that  Assessment Type has display correctly on Residents History Grid
            string aTypeAdded = aType2 + " " + aType3;

            try
            {
                Assert.AreEqual(aType1, aTypeAdded);
                TestReport.Log(LogStatus.Pass, "Assessment type '" + aType1 + "' is equal to '" + aTypeAdded);
            }
            catch (AssertionException e)
            {
                string screenName     = ScreenshotHelper.TakeScreenshot();
                string screenShotPath = TestReport.AddScreenCapture(screenName);
                TestReport.Log(LogStatus.Warning, screenShotPath + "<br> Assessment type is not equal: " + e.Message);
            }
        }
コード例 #19
0
ファイル: UITestBase.cs プロジェクト: vuluuLG/SeleniumCSharp
        public void TestCleanup()
        {
            if (TestContext.CurrentTestOutcome != UnitTestOutcome.Inconclusive)
            {
                if (TestContext.CurrentTestOutcome == UnitTestOutcome.Failed)
                {
                    ScreenshotHelper.TakeScreenshot(out errorImagePath, null, EnvironmentSetting.ResultLocation);
                }

                if (lastReportPath != null)
                {
                    TestContext.AddResultFile(lastReportPath);
                }

                Browser.QuitAll();
            }
        }
コード例 #20
0
        public void TearDown()
        {
            if (SettingsHelper.GetValue(SettingsValues.Environment).ToLower() == SeleniumServerLocations.Remote)
            {
                BrowserstackHelper.SetSessionStatus(
                    TestContext.CurrentContext.Result.Outcome.Status.ToString().ToLower() == SessionStatuses.Failed.GetValue()
                                        ? SessionStatuses.Failed.GetValue()
                                        : SessionStatuses.Passed.GetValue());
            }
            else
            {
                if (SettingsHelper.GetValue(SettingsValues.EnableScreenshoting).Equals("yes", StringComparison.InvariantCultureIgnoreCase) &&
                    TestContext.CurrentContext.Result.Outcome.Status.ToString().ToLower() == SessionStatuses.Failed.GetValue())
                {
                    ScreenshotHelper.TakeScreenshot(TestContext.CurrentContext.Test.MethodName);
                }
            }

            Browser.Close();
        }
コード例 #21
0
        private void Initialize(Window owner = null)
        {
            if (owner != null)
            {
                Owner             = owner;
                owner.WindowState = WindowState.Minimized;
                owner.Hide();
                FullScreenshot = ScreenshotHelper.TakeScreenshot(true, out _usedScreen);
                owner.Show();
            }
            else
            {
                FullScreenshot = ScreenshotHelper.TakeScreenshot(true, out _usedScreen);
            }
            LogManager.AddLogItem($"UsedScreen: left: {_usedScreen.Bounds.Left}", "Screenshot.Initialize");
            Left        = _usedScreen.Bounds.Left; // ensure multi screen
            Top         = 0;
            Width       = 1;                       // This is a trick to reduce the maximizing visuals.
            Height      = 1;
            WindowState = WindowState.Maximized;
#if DEBUG
            LogManager.AddLogItem($"My left is: {Left}");
#endif
        }
コード例 #22
0
        public void CN_WIP___Verify_Number_of_assessments__bottom_right()
        {
            Browser.Open();
            LoginPage.SignIn();
            //Step 1  Select Work In Progress tile.
            LandingPage.NavigateToWorkInProgressPage();
            //Step 2  Verify that "Due in" slider bar have 7 days by default
            VerifyElement.IsPresent(By.XPath("//span[@class='ng-binding'][text()='7 days']"));
            //Step 3  Verify Number of assessments (bottom right)
            //Step 4  Verify that pages has 5 assessments per page if  number of assessments (bottom right) more(equal) 5 OR less than 5 assessments in the First page if  number of assessments less than 10.
            int firstPageResidents = Driver.Instance.FindElements(WorkInProgressPage.residentsList).Count;

            Driver.WaitForElement(WorkInProgressPage.residentsList);
            Assert.AreEqual(firstPageResidents, 5);
            //Step 5  Verify that number of assessments from pages equal number of assessments(bottom right)
            if (Driver.IsElementPresent(WorkInProgressPage.nextButton))
            {
                Driver.ClickOn(WorkInProgressPage.nextButton);
                Driver.WaitFor(3);
                int secondPageResidents = Driver.Instance.FindElements(WorkInProgressPage.residentsList).Count;
                if (Driver.IsElementPresent(WorkInProgressPage.nextButton))
                {
                    Driver.ClickOn(WorkInProgressPage.nextButton);
                    Driver.WaitFor(3);
                    int thirdPageResidents = Driver.Instance.FindElements(WorkInProgressPage.residentsList).Count;
                    if (Driver.IsElementPresent(WorkInProgressPage.nextButton))
                    {
                        Driver.ClickOn(WorkInProgressPage.nextButton);
                        Driver.WaitFor(3);
                        int fourthPageResidents = Driver.Instance.FindElements(WorkInProgressPage.residentsList).Count;
                        Driver.ClickOn(WorkInProgressPage.nextButton);
                        Driver.WaitFor(3);
                        string assessments = Driver.Instance.FindElement(WorkInProgressPage.totalAssessments).Text.ToString().Substring(0, 2);
                        try
                        {
                            Assert.AreEqual(firstPageResidents + secondPageResidents + thirdPageResidents + fourthPageResidents, Convert.ToInt32(assessments));
                            TestReport.Log(LogStatus.Pass, "Assessments are equal to: " + assessments);
                        }
                        catch (Exception e)
                        {
                            string screenName     = ScreenshotHelper.TakeScreenshot();
                            string screenShotPath = TestReport.AddScreenCapture(screenName);
                            TestReport.Log(LogStatus.Warning, screenShotPath + "Assessments are not equal to: " + assessments + e.Message);
                        }
                    }
                    else
                    {
                        string assessments = Driver.Instance.FindElement(WorkInProgressPage.totalAssessments).Text.ToString().Substring(0, 2);
                        try
                        {
                            Assert.AreEqual(firstPageResidents + secondPageResidents + thirdPageResidents, Convert.ToInt32(assessments));
                            TestReport.Log(LogStatus.Pass, "Assessments are equal to: " + assessments);
                        }
                        catch (Exception e)
                        {
                            string screenName     = ScreenshotHelper.TakeScreenshot();
                            string screenShotPath = TestReport.AddScreenCapture(screenName);
                            TestReport.Log(LogStatus.Warning, screenShotPath + "Assessments are not equal to: " + assessments + e.Message);
                        }
                    }
                }
                else
                {
                    string assessments = Driver.Instance.FindElement(WorkInProgressPage.totalAssessments).Text.ToString().Substring(0, 2);
                    try
                    {
                        Assert.AreEqual(firstPageResidents + secondPageResidents, Convert.ToInt32(assessments));
                        TestReport.Log(LogStatus.Pass, "Assessments are equal to: " + assessments);
                    }
                    catch (Exception e)
                    {
                        string screenName     = ScreenshotHelper.TakeScreenshot();
                        string screenShotPath = TestReport.AddScreenCapture(screenName);
                        TestReport.Log(LogStatus.Warning, screenShotPath + "Assessments are not equal to: " + assessments + e.Message);
                    }
                }
            }
            else
            {
                string assessments = Driver.Instance.FindElement(WorkInProgressPage.totalAssessments).Text.ToString().Substring(0, 2);
                Assert.AreEqual(firstPageResidents, Convert.ToInt32(assessments));
            }
            //Step 6  Slide slider bar to 1 day
            SchedulePage.MoveSlider(-2);
            Driver.ClickOn(SchedulePage.onePagination);
            Driver.WaitFor(4);
            //Step 7  Verify Number of assessments (bottom right)
            int firstPageResidents2 = Driver.Instance.FindElements(WorkInProgressPage.residentsList).Count;

            Assert.AreEqual(firstPageResidents2, 5);
            //Step 8  Verify that pages has 5 assessments per page if  number of assessments (bottom right) more(equal) 10 OR less than 10 assessments in the First page if  number of assessments less than 10.
            //Step 9  Verify that number of assessments from pages equal number of assessments(bottom right)
            if (Driver.IsElementPresent(WorkInProgressPage.nextButton))
            {
                Driver.ClickOn(WorkInProgressPage.nextButton);
                Driver.WaitFor(3);
                int secondPageResidents = Driver.Instance.FindElements(WorkInProgressPage.residentsList).Count;
                if (Driver.IsElementPresent(WorkInProgressPage.nextButton))
                {
                    Driver.ClickOn(WorkInProgressPage.nextButton);
                    Driver.WaitFor(3);
                    int thirdPageResidents = Driver.Instance.FindElements(WorkInProgressPage.residentsList).Count;
                    if (Driver.IsElementPresent(WorkInProgressPage.nextButton))
                    {
                        Driver.ClickOn(WorkInProgressPage.nextButton);
                        Driver.WaitFor(3);
                        int fourthPageResidents = Driver.Instance.FindElements(WorkInProgressPage.residentsList).Count;
                        Driver.ClickOn(WorkInProgressPage.nextButton);
                        Driver.WaitFor(3);
                        string assessments = Driver.Instance.FindElement(WorkInProgressPage.totalAssessments).Text.ToString().Substring(0, 2);
                        try
                        {
                            Assert.AreEqual(firstPageResidents2 + secondPageResidents + thirdPageResidents + fourthPageResidents, Convert.ToInt32(assessments));
                            TestReport.Log(LogStatus.Pass, "Assessments are equal to: " + assessments);
                        }
                        catch (Exception e)
                        {
                            string screenName     = ScreenshotHelper.TakeScreenshot();
                            string screenShotPath = TestReport.AddScreenCapture(screenName);
                            TestReport.Log(LogStatus.Warning, screenShotPath + "Assessments are not equal to: " + assessments + e.Message);
                        }
                    }
                    else
                    {
                        string assessments = Driver.Instance.FindElement(WorkInProgressPage.totalAssessments).Text.ToString().Substring(0, 2);
                        try
                        {
                            Assert.AreEqual(firstPageResidents2 + secondPageResidents + thirdPageResidents, Convert.ToInt32(assessments));
                            TestReport.Log(LogStatus.Pass, "Assessments are equal to: " + assessments);
                        }
                        catch (Exception e)
                        {
                            string screenName     = ScreenshotHelper.TakeScreenshot();
                            string screenShotPath = TestReport.AddScreenCapture(screenName);
                            TestReport.Log(LogStatus.Warning, screenShotPath + "Assessments are not equal to: " + assessments + e.Message);
                        }
                    }
                }
                else
                {
                    string assessments = Driver.Instance.FindElement(WorkInProgressPage.totalAssessments).Text.ToString().Substring(0, 2);
                    try
                    {
                        Assert.AreEqual(firstPageResidents2 + secondPageResidents, Convert.ToInt32(assessments));
                        TestReport.Log(LogStatus.Pass, "Assessments are equal to: " + assessments);
                    }
                    catch (Exception e)
                    {
                        string screenName     = ScreenshotHelper.TakeScreenshot();
                        string screenShotPath = TestReport.AddScreenCapture(screenName);
                        TestReport.Log(LogStatus.Warning, screenShotPath + "Assessments are not equal to: " + assessments + e.Message);
                    }
                }
            }
            else
            {
                string assessments = Driver.Instance.FindElement(WorkInProgressPage.totalAssessments).Text.ToString().Substring(0, 2);
                Assert.AreEqual(firstPageResidents2, Convert.ToInt32(assessments));
            }
            //Step 10 Slide slider bar to 370 days
            SchedulePage.MoveSlider(120);
            Driver.ClickOn(SchedulePage.onePagination);
            Driver.WaitFor(3);
            //Step 11 Verify Number of assessments (bottom right)
            int firstPageResidents3 = Driver.Instance.FindElements(WorkInProgressPage.residentsList).Count;

            Assert.AreEqual(firstPageResidents3, 5);
            //Step 12 Verify that pages has 5 assessments per page if  number of assessments (bottom right) more(equal) 10 OR less than 10 assessments in the First page if  number of assessments less than 10.
            //Step 13 Verify that number of assessments from pages equal number of assessments(bottom right)
            if (Driver.IsElementPresent(WorkInProgressPage.nextButton))
            {
                Driver.ClickOn(WorkInProgressPage.nextButton);
                Driver.WaitFor(3);
                int secondPageResidents = Driver.Instance.FindElements(WorkInProgressPage.residentsList).Count;
                if (Driver.IsElementPresent(WorkInProgressPage.nextButton))
                {
                    Driver.ClickOn(WorkInProgressPage.nextButton);
                    Driver.WaitFor(3);
                    int thirdPageResidents = Driver.Instance.FindElements(WorkInProgressPage.residentsList).Count;
                    if (Driver.IsElementPresent(WorkInProgressPage.nextButton))
                    {
                        Driver.ClickOn(WorkInProgressPage.nextButton);
                        Driver.WaitFor(3);
                        int fourthPageResidents = Driver.Instance.FindElements(WorkInProgressPage.residentsList).Count;
                        Driver.ClickOn(WorkInProgressPage.nextButton);
                        Driver.WaitFor(3);
                        string assessments = Driver.Instance.FindElement(WorkInProgressPage.totalAssessments).Text.ToString().Substring(0, 2);
                        try
                        {
                            Assert.AreEqual(firstPageResidents3 + secondPageResidents + thirdPageResidents + fourthPageResidents, Convert.ToInt32(assessments));
                            TestReport.Log(LogStatus.Pass, "Assessments are equal to: " + assessments);
                        }
                        catch (Exception e)
                        {
                            string screenName     = ScreenshotHelper.TakeScreenshot();
                            string screenShotPath = TestReport.AddScreenCapture(screenName);
                            TestReport.Log(LogStatus.Warning, screenShotPath + "Assessments are not equal to: " + assessments + e.Message);
                        }
                    }
                    else
                    {
                        string assessments = Driver.Instance.FindElement(WorkInProgressPage.totalAssessments).Text.ToString().Substring(0, 2);
                        try
                        {
                            Assert.AreEqual(firstPageResidents3 + secondPageResidents + thirdPageResidents, Convert.ToInt32(assessments));
                            TestReport.Log(LogStatus.Pass, "Assessments are equal to: " + assessments);
                        }
                        catch (Exception e)
                        {
                            string screenName     = ScreenshotHelper.TakeScreenshot();
                            string screenShotPath = TestReport.AddScreenCapture(screenName);
                            TestReport.Log(LogStatus.Warning, screenShotPath + "Assessments are not equal to: " + assessments + e.Message);
                        }
                    }
                }
                else
                {
                    string assessments = Driver.Instance.FindElement(WorkInProgressPage.totalAssessments).Text.ToString().Substring(0, 2);
                    try
                    {
                        Assert.AreEqual(firstPageResidents3 + secondPageResidents, Convert.ToInt32(assessments));
                        TestReport.Log(LogStatus.Pass, "Assessments are equal to: " + assessments);
                    }
                    catch (Exception e)
                    {
                        string screenName     = ScreenshotHelper.TakeScreenshot();
                        string screenShotPath = TestReport.AddScreenCapture(screenName);
                        TestReport.Log(LogStatus.Warning, screenShotPath + "Assessments are not equal to: " + assessments + e.Message);
                    }
                }
            }
            else
            {
                string assessments = Driver.Instance.FindElement(WorkInProgressPage.totalAssessments).Text.ToString().Substring(0, 2);
                Assert.AreEqual(firstPageResidents3, Convert.ToInt32(assessments));
            }
        }
コード例 #23
0
        static void Main(string[] args)
        {
            log4net.Config.BasicConfigurator.Configure();
            log4net.ILog log = log4net.LogManager.GetLogger(typeof(Program));

            log.Info("Starting");

            System.Globalization.CultureInfo ci = new System.Globalization.CultureInfo("es");
            System.Threading.Thread.CurrentThread.CurrentCulture = ci;

            Console.WriteLine("Options ");
            Console.WriteLine("1: Cerrar Actividades CM");
            Console.WriteLine("2: Crear Tarea");
            Console.WriteLine("3: Cerrar Tarea");
            Console.WriteLine("4: Crear Tareas (excel)");
            Console.WriteLine("5: Download report as csv");
            Console.WriteLine("6: Open app (IE)");
            Console.WriteLine("8: Crear defecto");
            Console.Write("Escoger opcion: ");
            var option = Console.ReadLine();

            Console.WriteLine("Opcion escogida es: {0}", option);



            switch (option)
            {
            case "8":

                var defectsExcel = new ExcelQueryFactory("Defects.xlsx");


                var defects = from x in defectsExcel.Worksheet <DefectDTO>() select x;
                foreach (var def in defects)
                {
                    if (def.IdAuthorization != null)
                    {
                        Login();
                        log.InfoFormat("Creando Defecto: {0}", def.ToString());
                        var    autPage    = new AutorizationPage(driver);
                        string autPageUrl = "";
                        autPageUrl += ConfigurationManager.AppSettings["URLBase"];
                        autPageUrl += ConfigurationManager.AppSettings["WISearchURLPartialHistory"];
                        autPage.GoToURL(string.Format(autPageUrl, def.IdAuthorization));
                        string areaProyecto = autPage.AreaProyecto();
                        log.InfoFormat("Area proyecto {0}", areaProyecto);

                        string PrmUrl = "";
                        PrmUrl += ConfigurationManager.AppSettings["URLBase"];
                        PrmUrl += ConfigurationManager.AppSettings["WISearchURLPartialHistory"];
                        Console.WriteLine("Prmurl {0}", PrmUrl);
                        autPage.GoToURL(string.Format(PrmUrl, autPage.Father()));


                        SolPage solPage = new SolPage(driver);
                        solPage.FillAttributes(def);


                        var    defPage   = new DefectPage(driver);
                        string newDefUrl = "";
                        newDefUrl += ConfigurationManager.AppSettings["URLBase"];
                        newDefUrl += ConfigurationManager.AppSettings["ProjectAreaURLPartial"];
                        newDefUrl += ConfigurationManager.AppSettings["URLdefectPartial"];

                        defPage.GoToURL(string.Format(newDefUrl, areaProyecto));

                        defPage.CreateDefect(def);

                        var input = Console.ReadLine();

                        Logout();
                    }
                }
                break;


            case "6":
                string currentDirectory = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
                string driverFolder     = Path.Combine(currentDirectory, ConfigurationManager.AppSettings["DriversDirectory"]);
                var    options          = new InternetExplorerOptions
                {
                    IgnoreZoomLevel             = true,
                    ForceCreateProcessApi       = true,
                    BrowserCommandLineArguments = "-private",
                    PageLoadStrategy            = PageLoadStrategy.None
                };


                string site = ConfigurationManager.AppSettings["IEUrl"];

                string usuario = ConfigurationManager.AppSettings["IEUser"];

                string clave = ConfigurationManager.AppSettings["IEPassword"];


                driver = new InternetExplorerDriver(driverFolder, options);
                var NetAppLogin = new NetAppLogin(driver);
                NetAppLogin.GoToURL(site);

                Console.WriteLine("now is {0}", DateTime.Now.ToLongTimeString());

                Console.WriteLine("about to start....");
                Console.WriteLine("now is {0}", DateTime.Now.ToLongTimeString());
                AutoItX.WinActivate("Windows Security");
                AutoItX.WinWaitActive("Windows Security");
                AutoItX.Sleep(500);
                AutoItX.WinActivate("Windows Security");
                AutoItX.Send("{TAB}");
                AutoItX.WinActivate("Windows Security");
                AutoItX.Send("{TAB}");
                AutoItX.WinActivate("Windows Security");
                AutoItX.Send("{ENTER}");
                AutoItX.WinActivate("Windows Security");
                AutoItX.Send("{TAB}");
                AutoItX.WinActivate("Windows Security");
                AutoItX.Send("{ENTER}");
                AutoItX.WinActivate("Windows Security");
                AutoItX.Sleep(500);
                AutoItX.WinActivate("Windows Security");
                AutoItX.Send("TIM");
                AutoItX.WinActivate("Windows Security");
                AutoItX.Send("{ASC 092}");
                AutoItX.WinActivate("Windows Security");
                AutoItX.Send(usuario);
                AutoItX.WinActivate("Windows Security");
                AutoItX.Send("{TAB}");
                AutoItX.WinActivate("Windows Security");
                AutoItX.Sleep(500);
                AutoItX.WinActivate("Windows Security");
                AutoItX.Send(clave);
                AutoItX.WinActivate("Windows Security");
                AutoItX.Send("{ENTER}");



                break;

            case "5":
                Login();
                var savedQueryPage = new SavedQueryPage(driver);
                savedQueryPage.downloadCSV();
                log.Info("Se descargó reporte en download");
                Logout();


                break;


            case "4":

                var tasksExcel = new ExcelQueryFactory("Tasks.xlsx");


                var timeTasks = from x in tasksExcel.Worksheet <TimeTask>() select x;
                foreach (var task in timeTasks)
                {
                    if (task != null && task.ToString() != null && task.IdTicket != "" && task.IdTicket != null)
                    {
                        Login();
                        log.InfoFormat("Creando Tarea: {0}", task.ToString());
                        Console.WriteLine(task.ToString());
                        Console.WriteLine("taskplanned for {0}", task.TaskPlannedFor == null);
                        int         taskCode = Int32.Parse(task.IdTicket);
                        NewTaskPage taskPage = null;
                        taskPage = new NewTaskPage(driver, taskCode);

                        if (task.TimeSpentHr.Contains(","))
                        {
                            task.TimeSpentHr = task.TimeSpentHr.Replace(",", ".");
                            Console.WriteLine("new timespent {0}", task.TimeSpentHr);
                        }
                        taskPage.VisitTicketLinksTab(task);

                        Logout();
                    }
                    else
                    {
                        log.Error("No se procesan tareas nulas");
                    }
                }

                //report
                Login();
                savedQueryPage = new SavedQueryPage(driver);
                savedQueryPage.downloadCSV();
                log.Info("Se descargó reporte en download");
                Logout();

                break;

            case "3":    //close task tarea
                var taskCode1 = int.Parse(ConfigurationManager.AppSettings["TaskID"]);
                var page1     = new TaskPage(driver, "", null);
                page1.GoTo(taskCode1);
                page1.CloseTask("Completada");      //Completada o Invalida o En Trabajo

                break;



            case "2":      //crear task

                var taskPage2 = new NewTaskPage(driver, int.Parse(ConfigurationManager.AppSettings["IdTicket"]));
                taskPage2.VisitTicketLinksTab(null);



                break;

            case "1":
                try
                {
                    Login();

                    int startRow = int.Parse(ConfigurationManager.AppSettings["startRow"]);
                    int endRow   = int.Parse(ConfigurationManager.AppSettings["endRow"]);
                    int processingAssignations = endRow - startRow + 1;
                    Console.WriteLine("Skipping {0} attention(s)", startRow - 2);
                    Console.WriteLine("Processing {0} attention(s)", processingAssignations);


                    var excel = new ExcelQueryFactory("Modelo.xlsx");
                    excel.AddTransformation <AssignationExcel>(x => x.DDS, cellValue => cellValue == "Y");
                    excel.AddTransformation <AssignationExcel>(x => x.Installed, cellValue => cellValue != "N");
                    excel.AddTransformation <AssignationExcel>(x => x.SourcesCompiled, cellValue => cellValue != "N");
                    excel.AddTransformation <AssignationExcel>(x => x.Special, cellValue => cellValue == "Y");

                    var assignations = from x in excel.Worksheet <AssignationExcel>() select x;

                    var assignationList = assignations.ToList().Skip(startRow - 2).Take(processingAssignations);



                    foreach (var task in assignationList)
                    {
                        Console.WriteLine("Processing Actividad id {0} summary {1} installed {2}", task.Id, task.Summary, task.Installed);

                        //crear assignation request
                        var request = new AssignationRequest();
                        if (task.Cycle > 0)
                        {
                            request.Cycle = task.Cycle;
                        }
                        if (task.DDS)
                        {
                            request.DDS = task.DDS;
                        }
                        request.Id = task.Id;
                        if (!task.Installed)
                        {
                            request.Installation = task.Installed;
                        }
                        if (task.NumberDefects > 0)
                        {
                            request.NumberDefects = task.NumberDefects;
                        }
                        if (task.NumberPbls > 0)
                        {
                            request.NumberPBL = task.NumberPbls;
                        }
                        if (!task.SourcesCompiled)
                        {
                            request.SourcesCompiled = task.SourcesCompiled;
                        }
                        request.TimeSpent = task.TotalTime;
                        Console.WriteLine("Task state {0}", task.ClosingState);
                        if (task.ClosingState == 1)
                        {
                            request.ClosingState = SeleniumCM.Models.AssignationRequest.AttentionClosingState.ExitosoConErrores;
                        }
                        if (task.ClosingState == 2)
                        {
                            request.ClosingState = SeleniumCM.Models.AssignationRequest.AttentionClosingState.Stopper;
                        }
                        if (task.Special)
                        {
                            request.Special = task.Special;
                        }

                        var atencion = AssignationFactory.createAssignation(request);
                        //Console.ReadLine();



                        //buscar actividad
                        var activity = task.Id;
                        var url      = String.Format("https://172.19.112.112:9443/ccm/web/projects/CLARO.CERTIFICACION#action=com.ibm.team.workitem.viewWorkItem&id={0}&tab=esfuerzoscm", activity);
                        driver.Navigate().GoToUrl(url);
                        driver.Navigate().Refresh();
                        driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(20);

                        IWebElement table = null;
                        table = driver.FindElement(By.ClassName("DetailsSplitTable"));
                        var i = 0;
                        foreach (var tarea in atencion.Tasks)
                        {
                            //editar campos  t1

                            IWebElement field = null;
                            field = table.FindElements(By.TagName("input"))[i];
                            field.Clear();
                            field.SendKeys(tarea.ReportTime.ToString());
                            i++;
                        }

                        //guardar
                        IWebElement saveBtn = null;
                        saveBtn = driver.FindElement(By.CssSelector("button.primary-button"));
                        saveBtn.Click();

                        //cambiar estado a Status
                        IWebElement statusList = null;
                        statusList = driver.FindElement(By.CssSelector("select[aria-label='Status']"));    //select status
                        var selectElement = new SelectElement(statusList);
                        selectElement.SelectByText("Finalizado");

                        //cambiar estado a Resolution
                        var resolutionList = driver.FindElement(By.CssSelector("select[aria-label='Resolution']"));    //select status
                        selectElement = new SelectElement(resolutionList);
                        Console.WriteLine("Closing state {0}", request.ClosingState.ToString());
                        switch (request.ClosingState)
                        {
                        case SeleniumCM.Models.AssignationRequest.AttentionClosingState.Exitoso:
                            selectElement.SelectByText("Exitoso");
                            break;

                        case SeleniumCM.Models.AssignationRequest.AttentionClosingState.ExitosoConErrores:
                            selectElement.SelectByText("Exitoso con Errores");
                            break;

                        case SeleniumCM.Models.AssignationRequest.AttentionClosingState.Stopper:
                            selectElement.SelectByText("Stopper (No Instalado)");
                            break;

                        default:
                            break;
                        }


                        //guardar final
                        saveBtn.Click();
                        driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(5);
                        ScreenshotHelper.TakeScreenshot(driver, request.Id);
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine("Exception Message {0}", e.Message);
                    Console.WriteLine("Exception Trace {0}", e.StackTrace);
                }
                break;

            default:
                break;
            }
            //page object return
            return;
        }
コード例 #24
0
    private IEnumerator ExportImages(string exportPath, ScreenshotHelper screenshot)
    {
        var background = map.GetLayerController <MapboxLayerController>();
        List <MapboxLayer>  backgroundLayers = GetLayers(background);
        List <GridMapLayer> gridLayers       = GetLayers <GridMapLayer>(map);
        List <MapLayer>     toolLayers       = GetLayers(map.GetLayerController <ToolLayerController>());

        int count = 0;

        if (fullInterfaceToggle.isOn)
        {
            count++;
        }
        if (bgLayersCombToggle.isOn)
        {
            count++;
        }
        if (bgLayersSepToggle.isOn)
        {
            if (backgroundLayers.Count > 0)
            {
                count++;
            }
            count += gridLayers.Count;
            count += toolLayers.Count;
        }

        Progress progress = new Progress(count, analysisProgress);

        // Export a screenshot of the full interface
        if (fullInterfaceToggle.isOn)
        {
            legendPanel.gameObject.SetActive(true);
            yield return(new WaitForFrames(2));

            ExpandLegendItems(true);
            yield return(new WaitForFrames(2));

            if (!progress.Update("Exporting full interface ..."))
            {
                yield break;
            }

            yield return(null);

            var filename = exportPath + fullInterfaceFilename + "_" + imgSize.ToString() + ".png";
            yield return(screenshot.TakeScreenshot(filename, exportWidth, exportHeight, true));

            ExpandLegendItems(false);
            legendPanel.gameObject.SetActive(false);
        }

        // Export a screenshot with all layers
        if (bgLayersCombToggle.isOn)
        {
            ToggleUI(false);
            yield return(new WaitForFrames(2));

            ExpandLegendItems(true);
            yield return(new WaitForFrames(2));

            if (!progress.Update("Exporting all layers combined ..."))
            {
                yield break;
            }
            yield return(null);

            var filename = exportPath + bgLayersCombFilename + "_" + imgSize.ToString() + ".png";
            yield return(screenshot.TakeScreenshot(filename, exportWidth, exportHeight, true));

            ExpandLegendItems(false);
            ToggleUI(true);
        }

        if (bgLayersSepToggle.isOn)
        {
            // Hide UI
            ToggleUI(false, false);
            yield return(new WaitForFrames(2));

            ToggleLegendItems(false);
            yield return(new WaitForFrames(2));

            // Hide all grid layers
            foreach (var layer in gridLayers)
            {
                layer.SetShape(GridMapLayer.Shape.Circle);
                layer.SetInterpolation(false);
                layer.Show(false);
            }

            bool contourOn = false;

            // Hide all tool layers
            foreach (var layer in toolLayers)
            {
                // For colour preservation when Contour Tool is active
                if (layer is ContoursMapLayer)
                {
                    contourOn = true;
                }

                var gridLayer = layer as GridMapLayer;
                if (gridLayer != null)
                {
                    gridLayer.SetShape(GridMapLayer.Shape.Circle);
                }
                layer.Show(false);
            }

            // For colour preservation when Contour Tool is active
            if (contourOn)
            {
                ComponentManager.Instance.Get <DataLayers>().ResetToolOpacity();
            }

            bool cancelled = false;

            if (backgroundLayers.Count > 0)
            {
                if (!progress.Update("Exporting background layer ..."))
                {
                    cancelled = true;
                }

                if (!cancelled)
                {
                    yield return(null);

                    var filename = exportPath + backgroundFilename + "_" + imgSize.ToString() + ".png";
                    yield return(screenshot.TakeScreenshot(filename, exportWidth, exportHeight, true));
                }
            }

            // Hide background
            if (background)
            {
                background.gameObject.SetActive(false);
            }

            ToggleUI(false);
            yield return(new WaitForFrames(2));

            ToggleLegendItems(false);
            yield return(new WaitForFrames(2));

            // Iterate thru each individual layer and export them
            if (!cancelled && gridLayers.Count > 0)
            {
                yield return(ExportLayers(gridLayers, screenshot, progress, exportPath));

                if (progress.IsCancelled)
                {
                    cancelled = true;
                }
            }
            if (!cancelled && toolLayers.Count > 0)
            {
                yield return(ExportLayers(toolLayers, screenshot, progress, exportPath));

                if (progress.IsCancelled)
                {
                    cancelled = true;
                }
            }

            // Show background again
            if (background)
            {
                background.gameObject.SetActive(true);
            }

            // Show all tool layers again
            foreach (var layer in toolLayers)
            {
                var gridLayer = layer as GridMapLayer;
                if (gridLayer != null)
                {
                    gridLayer.SetShape(GridMapLayer.Shape.Circle);
                }
                layer.Show(true);
            }

            // Show all grid layers again
            foreach (var layer in gridLayers)
            {
                layer.SetShape(GridMapLayer.Shape.Circle);
                layer.SetInterpolation(false);
                layer.Show(true);
            }

            // For colour preservation when Contour Tool is active
            if (contourOn)
            {
                ComponentManager.Instance.Get <DataLayers>().AutoReduceToolOpacity();
            }

            // Show UI again
            ToggleLegendItems(true);
            ToggleUI(true);
        }

        progress.Stop();
    }