Example #1
0
 public static void VerifyCommunicationDocumentDownload(RemoteWebDriver driver, Iteration reporter)
 {
     reporter.Add(new Act("Verify Documents link in Communications Page"));
     Selenide.SwitchToFrame(driver, Util.GetLocator("CommunicationFrame"));
     reporter.Add(new Act("Click Document"));
     Selenide.JS.Click(driver, Util.GetLocator("CommunicationDocument_lnk"));
     Selenide.SwitchToWindow(driver);
     reporter.Add(new Act("Verify Retail Calender Document"));
 }
        /// <summary>
        /// VerifyTabsInCostCenterPopUp verfies tabs in cost center popup
        /// </summary>
        /// <param name="driver"></param>
        /// <param name="reporter"></param>

        public static void VerifyTabsInCostCenterPopUp(RemoteWebDriver driver, Iteration reporter)
        {
            reporter.Add(new Act("Switch to cost center popup window"));
            reporter.Add(new Act("Click on each tab in the cost center popup window"));
            Selenide.SwitchToDefaultContent(driver);
            Selenide.SwitchToFrame(driver, Locator.Get(LocatorType.ID, "dlg_ifrm_search"));
            int index = Selenide.GetElementCount(driver, Locator.Get(LocatorType.XPath,
                                                                     "//div[@id='tab_ctrl']/ul/li"));

            for (int tab = 1; tab <= index; tab++)
            {
                Selenide.JS.Click(driver, Locator.Get(LocatorType.XPath,
                                                      string.Format(@"//div[@id='tab_ctrl']/ul/li[{0}]/a/span", tab)));
            }
        }
Example #3
0
        ///<summary>
        ///method to take a screenshot
        ///</summary>
        public static void GetScreener(RemoteWebDriver driver, Iteration reporter, string Message)
        {
            ITakesScreenshot iTakeScreenshot = driver;

            reporter.Screenshot = iTakeScreenshot.GetScreenshot().AsBase64EncodedString;

            if (reporter.Screenshot.Length == 0)
            {
                reporter.Add(new Act("unable to add screenshot"));
            }
            else
            {
                reporter.Add(new Act(Message + "<span class='pull-right'><a href='" + Path.Combine("PassedScreenshots", String.Format("{0} {1} {2} Passed.png", reporter.Browser.TestCase.Title, reporter.Browser.Title, reporter.Title)) + "'><span class='glyphicon glyphicon-paperclip normal'></span></a>&nbsp; </span>"));
            }
        }
 /// <summary>
 /// TypeAccountingDeatls enters details in Accounting Page
 /// </summary>
 /// <param name="driver"></param>
 /// <param name="reporter"></param>
 /// <param name="costcenternumber">First Name</param>
 public static void TypeAccountingDeatls(RemoteWebDriver driver, Iteration reporter,
                                         string costcenternumber)
 {
     reporter.Add(new Act("Entered Cost center text"));
     Selenide.SwitchToFrame(driver, Locator.Get(LocatorType.ID, "iFrameSiteContents"));
     Selenide.SetText(driver, Util.GetLocator("CostCenter_txt"), Selenide.ControlType.Textbox, costcenternumber);
 }
        /// <summary>
        /// ClickCreateNewAccount method click on create new account button
        /// </summary>
        /// <param name="driver"></param>
        /// <param name="reporter"></param>
        public static void ClickCreateNewAccount(RemoteWebDriver driver, Iteration reporter)
        {
            reporter.Add(new Act("Click on Create New Account button"));
            Selenide.Click(driver, Util.GetLocator("createaccount_btn"));

            // *** Create New account redirects to AccountRegister Page *** //
        }
 /// <summary>
 /// CloseStoreLocatorPopupWindow clicks on close icon of doctors entry popup
 /// </summary>
 /// <param name="Driver">Initialized RemoteWebDriver instance</param>
 /// <param name="reporter"></param>
 public static void CloseStoreLocatorPopupWindow(RemoteWebDriver driver, Iteration reporter, string resultsPath)
 {
     try
     {
         reporter.Add(new Act("Close Store Locator Popup Window"));
         //Selenide.SwitchToDefaultContent(driver);
         //Selenide.SwitchToFrame(driver, Locator.Get(LocatorType.ID, "dlg_ifrm_search"));
         Selenide.WaitForElementNotVisible(driver, Locator.Get(LocatorType.ClassName, "dlg_spinner"));
         if (Selenide.IsElementExists(driver, Locator.Get(LocatorType.ID, "createmsgdiv")))
         {
             CommonPage.AcceptErrorMessageIfPresent(driver, reporter, resultsPath);
         }
         //if (Selenide.IsElementExists(driver, Util.GetLocator("Cancel_btn")))
         //{
         //    Selenide.Click(driver, Util.GetLocator("Cancel_btn"));
         //}
         if (Selenide.IsElementExists(driver, Util.GetLocator("StoreInfoCloseBtn_win")))
         {
             Selenide.Click(driver, Util.GetLocator("StoreInfoCloseBtn_win"));
         }
         //CommonPage.WaitUntilSpinnerDisappears(driver);
         //CommonPage.AcceptOrDissmissAlertIfPresent(driver, reporter);
         //CommonPage.AcceptErrorMessageIfPresent(driver);
         Selenide.SwitchToDefaultContent(driver);
     }
     catch (Exception ex)
     {
         CommonPage.AcceptOrDissmissAlertIfPresent(driver, reporter);
         CommonPage.AcceptErrorMessageIfPresent(driver, reporter, resultsPath);
     }
 }
 /// <summary>
 /// CloseCostCenterPopUp method closes Patient Information Poup in Scheduler Page
 /// </summary>
 /// <param name="driver"></param>
 /// <param name="reporter"></param>
 public static void CloseCostCenterPopUp(RemoteWebDriver driver, Iteration reporter)
 {
     reporter.Add(new Act("Close Patient Information Poup in Scheduler Page"));
     Selenide.SwitchToDefaultContent(driver);
     Selenide.JS.Click(driver, Locator.Get(LocatorType.XPath,
                                           string.Format(@"//img[@title='Close']")));
 }
Example #8
0
    // Update is called once per frame
    void Update()
    {
        //Keyboard movement
        float   translation = Input.GetAxis("Vertical") * verSpeed;   //y input
        float   straffe     = Input.GetAxis("Horizontal") * horSpeed; //x input
        Vector2 mvMent      = new Vector2(straffe, translation);      //Save inputs for recording

        translation *= Time.deltaTime;                                //calculate distance
        straffe     *= Time.deltaTime;
        translation  = Mathf.Clamp(translation, translation / 2, translation);
        character.transform.Translate(straffe, 0, translation);

        //Mouse Movement
        var     md        = new Vector2(Input.GetAxisRaw("Mouse X"), Input.GetAxisRaw("Mouse Y")); //input
        Vector2 mseMvment = md;                                                                    //Save input for recording

        md          = Vector2.Scale(md, new Vector2(sensitivity * smoothing, sensitivity * 2 / 3 * smoothing));
        smoothV.x   = Mathf.Lerp(smoothV.x, md.x, 1f / smoothing);
        smoothV.y   = Mathf.Lerp(smoothV.y, md.y, 1f / smoothing);
        mouseLook  += smoothV;
        mouseLook.y = Mathf.Clamp(mouseLook.y, -25, 25); //limit how far up and down the player can look

        //Rotate view
        transform.localRotation           = Quaternion.AngleAxis(-mouseLook.y, Vector3.right);
        character.transform.localRotation = Quaternion.AngleAxis(mouseLook.x, character.transform.up);

        //record full command
        currRec.Add(next: new Command(mvMent, mseMvment));

        //If next iteration is begun
        if (Input.GetKeyDown("space"))
        {
            //instantiate PastSelf for recorded iteration and save iteration to allRec
            Iteration temp = currRec;                                                                            //create duplicate
            temp.avatar = Instantiate(PastSelf, new Vector3(0, 2, -10 * (iterNum)), new Quaternion(0, 0, 0, 1)); //instantiate
            temp.avatar.GetComponentInChildren <Camera>().enabled          = false;                              //disable camera to avoid conflicts
            temp.avatar.GetComponentInChildren <PastCharacter>().iterNum   = iterNum++;                          //keep track of and iterate iteration number; MAY BE USEFUL FOR JUMPING BACK ITERATIONS IN CASE OF PARADOX
            temp.avatar.GetComponentInChildren <PastCharacter>().inputList = temp;                               //apply recorded commands to PastSelf
            allRec.Add(temp);                                                                                    //Add iteration to list of iterations

            //Reset recording iteration
            currRec = new Iteration();

            //place player for next iteration
            character.transform.position      = new Vector3(0, 2, -10 * iterNum);
            character.transform.localRotation = Quaternion.Euler(0, 0, 0);
            mouseLook.y = mouseLook.x = 0;
        }

        //Control of mouse visibility
        if (Input.GetKeyDown("escape")) //free mouse if esc is pressed
        {
            Cursor.lockState = CursorLockMode.None;
        }
        if (Input.GetMouseButtonDown(0)) //hide mouse if game is clicked
        {
            Cursor.lockState = CursorLockMode.Locked;
        }
    }
 /// <summary>
 /// ClickCorporateSubLink selects sub links in Corporate
 /// </summary>
 /// <param name="driver"></param>
 /// <param name="reporter"></param>
 public static void ClickCorporateSubLink(RemoteWebDriver driver, Iteration reporter, string submenuname)
 {
     reporter.Add(new Act(String.Format("Click the {0} link under corporate sublink", submenuname)));
     Selenide.Focus(driver, Locator.Get(LocatorType.XPath,
                                        string.Format(@"//table[@class='wide100']/descendant::div[@id='bannernav']/descendant::a[text()='{0}']", submenuname)));
     Selenide.Click(driver, Locator.Get(LocatorType.XPath,
                                        string.Format(@"//table[@class='wide100']/descendant::div[@id='bannernav']/descendant::a[text()='{0}']", submenuname)));
 }
        /// <summary>
        /// VerifyNationalVisionDocumentDownload verfies pdf downloads
        /// </summary>
        /// <param name="driver"></param>
        /// <param name="reporter"></param>

        public static void VerifyNationalVisionDocumentDownload(RemoteWebDriver driver, Iteration reporter)
        {
            reporter.Add(new Act("Click on About National Vision Documents"));
            Selenide.SwitchToFrame(driver, Util.GetLocator("AboutNationalVisionFrame"));
            Selenide.JS.Click(driver, Util.GetLocator("NVDocument_lnk"));
            Selenide.SwitchToWindow(driver);
            Selenide.VerifyVisible(driver, Util.GetLocator("VerifyAboutNVDocument_lnk"));
        }
        /// <summary>
        /// logic goes here where we extract data
        /// </summary>
        /// <param name="driver"></param>
        /// <param name="reporter"></param>
        public static void LookForStories(RemoteWebDriver driver, Iteration reporter, string sitename)
        {
            reporter.Add(new Act("looking into the site for stories"));
            Console.WriteLine("Going to run for given site name");
            List <Dictionary <string, string> > data = ChooseDataRetrevalScheme(driver, reporter, sitename);

            WriteToFIles(reporter, sitename, data);
        }
Example #12
0
        /// <summary>
        /// AssertPageTitle verify page title macth
        /// </summary>
        /// <param name="driver"></param>
        /// <param name="reporter"></param>
        /// <param name="pageTitle"></param>
        public static void AssertPageTitle(RemoteWebDriver driver, Iteration reporter, string pTitle = "")
        {
            reporter.Add(new Act("Waiting for page title"));

            Selenide.WaitForTitle(driver, pTitle);
            string title = Selenide.GetTitle(driver);

            //title = title.Replace("'", "");
            if (!title.ToLower().Contains(pTitle.ToLower()))
            {
                reporter.Add(new Act("Asserting current page title"));
                throw new Exception(string.Format(@"Page Title not matched: Expected Title: ""{0}"" <br> Current Page Title: ""{1}""", pTitle, title));
            }
            else
            {
                reporter.Add(new Act("Asserted current page title : " + title));
            }
        }
        /// <summary>
        /// VerifyMessageInavalidDetails method verifies the message when we enter the invalid details
        /// </summary>
        /// <param name="driver"></param>
        /// <param name="reporter"></param>
        /// <param name="textToAssert">Expected message</param>
        public static void VerifyMessageInavalidDetails(RemoteWebDriver driver, Iteration reporter, String textToAssert)
        {
            reporter.Add(new Act("Verify error message when user enter invalid details"));
            String actualText = Selenide.GetText(driver,
                                                 Locator.Get(LocatorType.XPath, "//div[@class='login-form']/descendant::li"), Selenide.ControlType.Label);

            if (!textToAssert.Equals(actualText))
            {
                reporter.Chapter.Step.Action.IsSuccess = false;
                throw new Exception(String.Format(
                                        @"Expected Error message not appeared, Expected: {0}, Actual: {1}", textToAssert, actualText));
            }
        }
Example #14
0
        public static void TakeScreenShotAndAttachToReport(RemoteWebDriver driver, string link,
                                                           string resultsPath, Iteration reporter)
        {
            Screenshot ss         = ((ITakesScreenshot)driver).GetScreenshot();
            string     screenshot = ss.AsBase64EncodedString;

            byte[] screenshotAsByteArray = ss.AsByteArray;
            ss.SaveAsFile(Path.Combine(resultsPath, "Screenshots", String.Format("{0}.Png",
                                                                                 link, DateTime.Now.ToString("hhmmssfff"))), ImageFormat.Png);
            ss.ToString();
            reporter.Add(new Act(" " + link + "<a href='" + Path.Combine("Screenshots", String.Format("{0}.png", link)) + "'><span class='glyphicon glyphicon-paperclip normal' align='right'></span></a>"));
            //reporter.Add(new Act("<span class='glyphicon glyphicon-remove green'></span>"));
        }
Example #15
0
        /// <summary>
        /// Clicks [Project Search] on top bar
        /// </summary>


        public static void QuickNavLineItem(RemoteWebDriver driver, Iteration reporter, String lineItemId)
        {
            reporter.Add(new Act("Set Quick Navigation Line Item " + lineItemId));
            Selenide.SetText(driver, new Locator(LocatorType.ID, "quickNavInput"), Selenide.ControlType.Textbox, lineItemId);

            if (Selenide.Browser.isIPadSafari(driver))
            {
                Selenide.JS.Enter(driver, new Locator(LocatorType.ID, "quickNavInput"));
            }
            else
            {
                Selenide.Enter(driver, new Locator(LocatorType.ID, "quickNavInput"));
            }
        }
        private static void WriteToFIles(Iteration reporter, string sitename, List <Dictionary <string, string> > data)
        {
            reporter.Add(new Act("Writing Files all <b></b> of them to D:MinedData"));
            int    j    = 1;
            string site = Regex.Replace(sitename, @"[^0-9a-zA-Z]+", "_");

            foreach (Dictionary <string, string> dict in data)
            {
                String currentsnap  = DateTime.Now.ToString("yyyyMMdd_hhmm");
                var    StoryHeaders = dict.Select(kvp => kvp.Key).ToList();
                string seperator    = "~~~~~Seperate~~~~~";
                var    Storys       = dict.Select(kvp => kvp.Value).ToList();


                string totalTxt = StoryHeaders[0] + seperator + Storys[0];

                Console.WriteLine("Going to create a TXT");

                Common.CreateWithParallelFileWriteBytes(@"/home/nvadran/DataTemp/Text/", site + "_News_" + currentsnap + "_" + j, totalTxt);
                j++;
            }
            reporter.Add(new Act("After filtering suitable for text analytics is :: <b> " + j + " </b> of them in D:MinedData"));
        }
        /// <summary>
        /// ClickOnAnyStoreNumber method clicks on store number in the results
        /// </summary>
        /// <param name="driver"></param>
        /// <param name="reporter"></param>
        /// <param name="resultsPath"></param>
        public static void ClickOnAnyStoreNumber(RemoteWebDriver driver, Iteration reporter, string resultsPath)
        {
            try
            {
                reporter.Add(new Act("Click on store number in results of Stores Directory Page"));
                //Selenide.SwitchToFrame(driver, Locator.Get(LocatorType.ID, "iFrameSiteContents"));
                if (Selenide.IsElementExists(driver, Locator.Get(LocatorType.XPath, "//table[@class='formview']/descendant::tr[2]/td//a/nobr")))
                {
                    Selenide.Click(driver, Locator.Get(LocatorType.XPath, ("//table[@class='formview']/descendant::tr[2]/td//a/nobr")));
                }
                else if (Selenide.IsElementExists(driver, Locator.Get(LocatorType.XPath, "//table[@class='formview']/descendant::tr[2]/td//a")))
                {
                    Selenide.Click(driver, Locator.Get(LocatorType.XPath, ("//table[@class='formview']/descendant::tr[2]/td//a")));
                }
                else
                {
                    reporter.Add(new Act("Results not found"));
                }

                Selenide.WaitForElementNotVisible(driver, Locator.Get(LocatorType.ClassName, "dlg_spinner"));
                //WaitForPageLoad(driver, 10);
                //CommonPage.WaitUntilSpinnerDisappears(driver);
                CommonPage.AcceptOrDissmissAlertIfPresent(driver, reporter);
                CommonPage.AcceptErrorMessageIfPresent(driver, reporter, resultsPath);
                //Selenide.SwitchToFrame(driver,Locator.Get(LocatorType.ID, "dlg_ifrm_search"));
                Selenide.SwitchToDefaultContent(driver);
            }

            catch (SystemException sysex)
            {
                //    this.Reporter.Chapter.Step.Action.Extra = sysex.Message + "<br/>" + sysex.StackTrace;
                //    Reporter.Chapter.Step.Action.IsSuccess = false;
                CommonPage.AcceptOrDissmissAlertIfPresent(driver, reporter);
                CommonPage.AcceptErrorMessageIfPresent(driver, reporter, resultsPath);
            }
        }
Example #18
0
        ///<summary>
        ///verify that images in the web page are displayed are not
        ///</summary>
        public static void IsImagesDisplayed(RemoteWebDriver driver, Locator locator, Iteration reporter)
        {
            IWebElement         element = driver.FindElementByXPath(locator.Location);
            IList <IWebElement> lst     = driver.FindElements(By.XPath(locator.Location));

            for (int j = 0; j < lst.Count; j++)
            {
                string         sorc    = lst[j].GetAttribute("src");
                string         name    = lst[j].GetAttribute("alt");
                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(sorc);
                request.Method = "GET";
                try
                {
                    using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())

                        if (response.StatusCode == HttpStatusCode.OK)
                        {
                            reporter.Add(new Act("Image displayed  " + name));
                        }
                        else
                        {
                            reporter.Add(new Act("Image not displayed" + name));
                        }
                }
                catch (Exception e)
                {
                    j++;
                    reporter.Add(new Act("Image not displayed    " + name));
                    if (e.Message.Contains("404") && j == lst.Count)
                    {
                        throw new Exception("image not loaded");
                    }
                    continue;
                }
            }
        }
Example #19
0
        /// <summary>
        /// Performs login
        /// </summary>
        /// <param name="Driver">Initialized RemoteWebDriver instance</param>
        /// <param name="username">Login Username</param>
        /// <param name="password">Login Password</param>
        public static void Login(RemoteWebDriver driver, Iteration reporter, string username, string password)
        {
            reporter.Add(new Act(String.Format("Set Username {0}, Password {1} and Click Login", username, password)));
            Selenide.WaitForElementVisible(driver, Util.GetLocator("UserNamTxtBox"));
            Selenide.SetText(driver, Util.GetLocator("UserNamTxtBox"), Selenide.ControlType.Textbox, username);
            Selenide.SetText(driver, Util.GetLocator("PasswordTxtBox"), Selenide.ControlType.Textbox, password);
            Selenide.Click(driver, Util.GetLocator("LoginBtn"));
            System.Threading.Thread.Sleep(2000);
            Actions actions = new Actions(driver);

            actions.SendKeys(OpenQA.Selenium.Keys.Escape);
            //var ajaxIsComplete = (bool)(driver as IJavaScriptExecutor).ExecuteScript("return jQuery.active == 0");
            ((IJavaScriptExecutor)driver).ExecuteScript("return window.stop();");
            var ajaxIsComplete = (bool)(driver as IJavaScriptExecutor).ExecuteScript("return jQuery.active == 0");
            //Selenide.WaitForElementVisible(driver, Util.GetLocator("DashBoardOpenTickets"));
        }
        /// <summary>
        /// TypeCostCenterNumber method enters cost center number in cost center number field
        /// </summary>
        /// <param name="driver"></param>
        /// <param name="reporter"></param>
        /// <param name="costCenterNumber">Store Number</param>
        public static void TypeCostCenterNumber(RemoteWebDriver driver, Iteration reporter,
                                                string costCenterNumber)
        {
            reporter.Add(new Act("Enter cost center number in cost center number field"));
            Selenide.SwitchToFrame(driver, Locator.Get(LocatorType.ID, "iFrameSiteContents"));
            if (costCenterNumber.Equals(""))
            {
                return;
            }
            else if (Selenide.IsElementExists(driver, Util.GetLocator("CostCenterNumber1_txt")))
            {
                Selenide.Clear(driver, Util.GetLocator("CostCenterNumber1_txt"), Selenide.ControlType.Textbox);
                Selenide.SetText(driver, Util.GetLocator("CostCenterNumber1_txt"), Selenide.ControlType.Textbox, costCenterNumber);
            }

            //Selenide.SwitchToDefaultContent(driver);
        }
Example #21
0
 /// <summary>
 /// Performs login
 /// </summary>
 /// <param name="Driver">Initialized RemoteWebDriver instance</param>
 /// <param name="username">Login Username</param>
 /// <param name="password">Login Password</param>
 public static void Login(RemoteWebDriver driver, Iteration reporter, string username, string password)
 {
     try
     {
         reporter.Add(new Act(String.Format("Set Username {0}, Password {1} and Click Login", username, password)));
         Selenide.WaitForElementNotVisible(driver, Locator.Get(LocatorType.ID, "dlg_spinner"));
         Selenide.WaitForElementVisible(driver, Util.GetLocator("UserName_txt"));
         Selenide.SetText(driver, Util.GetLocator("UserName_txt"), Selenide.ControlType.Textbox, username);
         Selenide.WaitForElementVisible(driver, Util.GetLocator("Password_txt"));
         Selenide.SetText(driver, Util.GetLocator("Password_txt"), Selenide.ControlType.Textbox, password);
         Selenide.WaitForElementVisible(driver, Util.GetLocator("Login_btn"));
         Selenide.JS.Click(driver, Util.GetLocator("Login_btn"));
         Selenide.WaitForElementNotVisible(driver, Locator.Get(LocatorType.ID, "dlg_spinner"));
         System.Threading.Thread.Sleep(5000);
     }
     catch (Exception ex)
     {
     }
 }
Example #22
0
 /// <summary>
 /// SelectApplication method selects the application at login screen
 /// </summary>
 /// <param name="Driver">Initialized RemoteWebDriver instance</param>
 /// <param name="applicationName">Link Name</param>
 public static void SelectApplication(RemoteWebDriver driver, Iteration reporter, string applicationName)
 {
     reporter.Add(new Act(String.Format("Select the {0} link ", applicationName)));
     Selenide.SwitchToFrame(driver, Locator.Get(LocatorType.ID, "dlg_ifrm_modal2"));
     try
     {
         Actions     action      = new Actions(driver);
         IWebElement application = Selenide.GetElement(driver, Locator.Get(LocatorType.XPath, string.Format(@"//table[@id='tblSelect']/descendant::a[contains(@title,""{0}"")]/div", applicationName)));
         //Selenide.Click(driver,Locator.Get(LocatorType.XPath, string.Format(@"//table[@id='tblSelect']/descendant::a[contains(@title,""{0}"")]/div", applicationName)));
         //Selenide.Click(driver, Locator.Get(LocatorType.XPath, string.Format(@"//table[@id='tblSelect']/descendant::a[contains(@title,'{0}')]/div", applicationName)));
         action.MoveToElement(application).Click().Build().Perform();
         WaitForPageLoad(driver, 10);
         Selenide.WaitForElementNotVisible(driver, Locator.Get(LocatorType.ClassName, "dlg_spinner"));
         Selenide.SwitchToDefaultContent(driver);
     }
     catch (Exception ex)
     {
         throw new Exception(String.Format("{ 0 } link not found in the website", applicationName));
     }
 }
Example #23
0
 /// <summary>
 /// Verifies whether the page is Login or not
 /// </summary>
 /// <param name="Driver">Initialized RemoteWebDriver instance</param>
 public static void VerifyPage(RemoteWebDriver driver, Iteration reporter)
 {
     reporter.Add(new Act("Verify Login Page"));
     //Selenide.WaitForElementVisible(driver);
 }
Example #24
0
    // Update is called once per frame
    void FixedUpdate()
    {
        //Keyboard movement
        float   translation = Input.GetAxis("Vertical") * verSpeed;   //y input
        float   straffe     = Input.GetAxis("Horizontal") * horSpeed; //x input
        Vector2 mvMent      = new Vector2(straffe, translation);      //Save inputs for recording

        translation *= Time.deltaTime;                                //calculate distance
        straffe     *= Time.deltaTime;
        translation  = Mathf.Clamp(translation, translation / 2, translation);
        character.transform.Translate(straffe, 0, translation);

        //Mouse Movement
        var     md        = new Vector2(Input.GetAxisRaw("Mouse X"), Input.GetAxisRaw("Mouse Y")); //input
        Vector2 mseMvment = md;                                                                    //Save input for recording

        md          = Vector2.Scale(md, new Vector2(sensitivity * smoothing, sensitivity * 2 / 3 * smoothing));
        smoothV.x   = Mathf.Lerp(smoothV.x, md.x, 1f / smoothing);
        smoothV.y   = Mathf.Lerp(smoothV.y, md.y, 1f / smoothing);
        mouseLook  += smoothV;
        mouseLook.y = Mathf.Clamp(mouseLook.y, yConstraints.x, yConstraints.y); //limit how far up and down the player can look

        //Rotate view
        view.transform.localRotation      = Quaternion.AngleAxis(-mouseLook.y, Vector3.right);
        character.transform.localRotation = Quaternion.AngleAxis(mouseLook.x, character.transform.up);

        //record full command
        currRec.Add(next: new Command(mvMent, mseMvment));

        //checks to see if characters are within line of sight of each other
        //int layerMask = 1 << 9;
        //layerMask = ~layerMask;

        //for (int i = 0; i < allRec.Count(); i++)
        //{
        //    Debug.Log("allRec.Count = " + allRec.Count());
        //    Iteration itor = allRec[i];
        //    if (Physics.Linecast(transform.position, itor.avatar.transform.position, layerMask))
        //    {
        //        Debug.Log("No LOS");
        //    }
        //    else
        //    {
        //        Debug.Log("LOS");
        //    }
        //}

        //If next iteration is begun
        if (Input.GetKeyDown("space"))
        {
            //instantiate PastSelf for recorded iteration and save iteration to allRec
            Iteration temp = currRec;                                                                            //create duplicate
            temp.avatar = Instantiate(PastSelf, Spots.startLocator(Level, iterNum), new Quaternion(0, 0, 0, 1)); //instantiate
            temp.avatar.GetComponentInChildren <Camera>().enabled = false;                                       //disable camera to avoid conflicts
            temp.avatar.GetComponent <PastCharacter>().iterNum    = iterNum++;                                   //keep track of and iterate iteration number; MAY BE USEFUL FOR JUMPING BACK ITERATIONS IN CASE OF PARADOX
            temp.avatar.GetComponent <PastCharacter>().inputList  = temp;                                        //apply recorded commands to PastSelf
            allRec.Add(temp);                                                                                    //Add iteration to list of iterations

            //Reset recording iteration
            currRec = new Iteration();

            //place player for next iteration
            character.transform.position      = Spots.startLocator(Level, iterNum);
            character.transform.localRotation = Quaternion.Euler(0, 0, 0);
            mouseLook.y = mouseLook.x = 0;
        }

        //Control of mouse visibility
        if (Input.GetKeyDown("escape")) //free mouse if esc is pressed
        {
            Cursor.lockState = CursorLockMode.None;
        }
        if (Input.GetMouseButtonDown(0)) //hide mouse if game is clicked
        {
            Cursor.lockState = CursorLockMode.Locked;
        }

        //increment timing function
        timer++;
        //after around 3 seconds hide the text
        if (timer >= 180)
        {
            showText = false;
        }
    }
 /// <summary>
 /// VerifyCostCenterNumber method verifies the CC Number in Search Results Page
 /// </summary>
 /// <param name="driver"></param>
 /// <param name="reporter"></param>
 /// <param name="costcenternumber"></param>
 public static void VerifyCostCenterNumber(RemoteWebDriver driver, Iteration reporter, string costcenternumber)
 {
     reporter.Add(new Act(String.Format("Verify {0} cost ceter number is visible", costcenternumber)));
     Selenide.VerifyVisible(driver, Locator.Get(LocatorType.XPath,
                                                string.Format(@"//tr[@class='GridRow_altN_selN_hovN']/td[2]/a[text()='{0}']", costcenternumber)));
 }
Example #26
0
        /// <summary>
        /// ClickContentLinks method clicks the content links in the WebPortal
        /// </summary>
        /// <param name="driver"></param>
        /// <param name="reporter"></param>
        public static void ClickExternalApplicationMenus(RemoteWebDriver driver, Iteration reporter, string resultsPath)
        {
            int    ExternalMenuCount, LinksCountInExternalMenu;
            bool   IsExternalApplication;
            int    NumberOfExternalMenu;
            int    NumberOfSubmenuInExternalMenu;
            string LinkTextInExternalMenu;
            string ExternalMenuText;
            string submenu1 = string.Empty;

            //Checks for external application
            IsExternalApplication = Selenide.IsElementExists(driver, Locator.Get(LocatorType.XPath, "//div[@class='secmenu']/ul/li/a"));
            if (IsExternalApplication)
            {
                //Counts number of Menu's in external application
                NumberOfExternalMenu = Selenide.GetElementCount(driver, Locator.Get(LocatorType.XPath, "//div[@class='secmenu']/ul/li/a"));
                for (ExternalMenuCount = 1; ExternalMenuCount <= NumberOfExternalMenu; ExternalMenuCount++)
                {
                    //Clicks a menu in external application
                    Selenide.Click(driver, Locator.Get(LocatorType.XPath, string.Format(@"//div[@class='secmenu']/ul/li[{0}]/a", ExternalMenuCount + 1)));

                    Thread.Sleep(1000);
                    ExternalMenuText = Selenide.GetText(driver, Locator.Get(LocatorType.XPath, string.Format
                                                                                (@"//div[@class='secmenu']/ul/li[{0}]/a", ExternalMenuCount + 1)), Selenide.ControlType.Label);

                    reporter.Add(new Act(string.Format(@"Click on <b>{0}</b> menu in the external application", ExternalMenuText)));

                    Selenide.Click(driver, Locator.Get(LocatorType.XPath, string.Format(@"//div[@class='secmenu']/ul/li[{0}]/a", ExternalMenuCount + 1)));

                    NumberOfSubmenuInExternalMenu = Selenide.GetElementCount(driver, Locator.Get(LocatorType.XPath, string.Format
                                                                                                     (@"//div[@class='secmenu']/ul/li[{0}]/ul/li", ExternalMenuCount + 1)));

                    reporter.Add(new Act(string.Format
                                             (@"Menu count in each external application(Ex: SIM): <b>{0}</b>", NumberOfSubmenuInExternalMenu)));

                    for (LinksCountInExternalMenu = 1; LinksCountInExternalMenu <= NumberOfSubmenuInExternalMenu; LinksCountInExternalMenu++)
                    {
                        Selenide.Click(driver, Locator.Get(LocatorType.XPath, string.Format
                                                               (@"//div[@class='secmenu']/ul/li[{0}]/a", ExternalMenuCount + 1)));

                        LinkTextInExternalMenu = Selenide.GetText(driver, Locator.Get(LocatorType.XPath, string.Format
                                                                                          (@"//div[@class='secmenu']/ul/li[{0}]/ul/li[{1}]", ExternalMenuCount + 1, LinksCountInExternalMenu)), Selenide.ControlType.Label);

                        reporter.Add(new Act(string.Format
                                                 (@"Click on " + "<b>" + "{0}" + "</b>" + " submenu In the external application", LinkTextInExternalMenu)));

                        try
                        {
                            Selenide.Click(driver, Locator.Get(LocatorType.XPath, string.Format
                                                                   (@"//div[@class='secmenu']/ul/li[{0}]/a", ExternalMenuCount + 1)));

                            Selenide.Click(driver, Locator.Get(LocatorType.XPath, string.Format
                                                                   (@"//div[@class='secmenu']/ul/li[{0}]/ul/li[{1}]/a", ExternalMenuCount + 1, LinksCountInExternalMenu)));

                            AcceptOrDissmissAlertIfPresent(driver, reporter);
                            AcceptErrorMessageIfPresent(driver);

                            Selenide.WaitForElementNotVisible(driver, Locator.Get(LocatorType.ClassName, "dlg_spinner"));
                            Selenide.WaitForElementNotVisible(driver, Util.GetLocator("Spinner1_img"));
                            Selenide.WaitForElementNotVisible(driver, Util.GetLocator("Spinner2_img"));

                            CloseBrowserNewTab(driver);
                            Selenide.Focus(driver, Locator.Get(LocatorType.XPath, string.Format(@"//td[@class='left']")));
                            //Thread.Sleep(1000);
                        }
                        catch (Exception ex)
                        {
                            reporter.Add(new Act(string.Format
                                                     (@"Error found in external application menu link: <b>{0}</b>", LinkTextInExternalMenu)));

                            CommonPage.TakeScreenShotAndAttachToReport(driver, LinkTextInExternalMenu, resultsPath, reporter);
                        }
                    }
                }
            }
        }
 /// <summary>
 /// ClickSearch performs Search Operation
 /// </summary>
 /// <param name="driver"></param>
 /// <param name="reporter"></param>
 public static void ClickSearch(RemoteWebDriver driver, Iteration reporter)
 {
     reporter.Add(new Act("Click on Search button"));
     Selenide.Click(driver, Util.GetLocator("AccountingSearch_btn"));
 }
 /// <summary>
 /// ClickForgotPasswordLink method clicks on forgot password click here link
 /// </summary>
 /// <param name="uname">User Name </param>
 /// <param name="password">Password to login into the application</param>
 public static void ClickForgotPasswordLink(RemoteWebDriver driver, Iteration reporter)
 {
     reporter.Add(new Act("Click on forgot password link"));
     Selenide.Click(driver, Util.GetLocator("ForgotPassword_lnk"));
 }
 /// <summary>
 /// ClickCostCenterAndVerify performs Search Operation
 /// </summary>
 /// <param name="driver"></param>
 /// <param name="reporter"></param>
 /// <param name="costcenternumber"></param>
 public static void ClickCostCenterAndVerify(RemoteWebDriver driver, Iteration reporter, string costcenternumber)
 {
     reporter.Add(new Act("Click on Search button"));
     Selenide.Click(driver, Locator.Get(LocatorType.XPath,
                                        string.Format(@"//tr[@class='GridRow_altN_selN_hovN']/td[2]/a[text()='{0}']", costcenternumber)));
 }
 /// <summary>
 /// Click on logout button
 /// </summary>
 /// <param name="driver"></param>
 /// <param name="reporter"></param>
 public static void clickLogout(RemoteWebDriver driver, Iteration reporter)
 {
     reporter.Add(new Act("Click on  Logout button"));
     Selenide.Click(driver, Util.GetLocator("acclogout_btn"));
 }