Example #1
0
 void VerifyElement(string pattern, OpenQA.Selenium.IWebElement element)
 {
     if (!Regex.IsMatch(element.Text, pattern))
     {
         throw new AssertionException(pattern, element.Text, WebDrivers.Default);
     }
 }
Example #2
0
        public virtual void SecurityJOTToken_02()
        {
            TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("SecurityJOTToken_02", new string[] {
                "SecurityJOTTokenPositiveScenario"
            });
#line 11
            this.ScenarioSetup(scenarioInfo);
#line 12
            testRunner.Given("the user is trying to access data in our system", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Given ");
            var sidebarMenu = new PageObjects.FpSideMenus();
            PageObjects.FpCombinedSchedulePage combinedSchedule = new PageObjects.FpCombinedSchedulePage();
            sidebarMenu.LnkCombinedSchedule.Click();
            OpenQA.Selenium.IWebElement framesource = PropertiesCollection.driver.FindElement(OpenQA.Selenium.By.XPath("//iframe[@class='iframe-placeholder']"));

#line 13
            testRunner.When("the JOT token is already expired", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When ");
#line 14

            var frameSourceValue = framesource.GetAttribute("src");
            PropertiesCollection.driver.Close();
            PropertiesCollection.driver.Quit();
            System.Threading.Thread.Sleep(20000);
            PropertiesCollection.driver = new OpenQA.Selenium.Chrome.ChromeDriver([email protected]["ChromeDriverPath"]);
            PropertiesCollection.driver.Navigate().GoToUrl(frameSourceValue);
            PropertiesCollection.driver.Manage().Window.Maximize();

            testRunner.Then("the system returns an error", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then ");
            OpenQA.Selenium.IWebElement errorCode = PropertiesCollection.driver.FindElement(OpenQA.Selenium.By.XPath("//*[@id=\"error-information-popup-content\"]/div[2]"));
            System.Threading.Thread.Sleep(2000);
            Microsoft.VisualStudio.TestTools.UnitTesting.Assert.AreEqual("HTTP ERROR 401", errorCode.Text);
#line hidden
            //this.ScenarioCleanup();
        }
Example #3
0
        private void tobbiekElkuldese()
        {
            //MessageBox.Show("többiek küldése");
            try
            {
                feltekerOldalTetejere();
                //összes egység
                kijelolOsszesEgyseg();

                //kivéve
                kattintlLandzsasok();

                kattintKonnyuLovassag();

                kattintNehezLovassag();

                gyulekezohelyGyujtFontosElem = vezerlo.FindElementByClassName("carry-max");

                fosztogatoKapacitasSzoveg = gyulekezohelyGyujtFontosElem.getInnerHTML();
                //MessageBox.Show("elküldés");

                if (atalakitSzamma(fosztogatoKapacitasSzoveg) > 0)
                {
                    csapatokKuldeseOkosGyujtogetok();
                }
                else
                {
                    //MessageBox.Show("Nincsenek szabad katonák.");
                }
            }
            catch //(Exception hiba)
            {
                //MessageBox.Show(hiba.Message);
            }
        }
Example #4
0
        private void kattintlLandzsasok()
        {
            //lándzsások
            gyulekezohelyGyujtFontosElem = vezerlo.FindElementsByClassName("units-entry-all").
                                           First(l => l.GetAttribute("data-unit") == "spear");

            gyulekezohelyGyujtFontosElem.Click();
        }
Example #5
0
        private void kattintKonnyuLovassag()
        {
            //Könnyűlovasok
            gyulekezohelyGyujtFontosElem = vezerlo.FindElementsByClassName("units-entry-all").
                                           First(l => l.GetAttribute("data-unit") == "light");

            gyulekezohelyGyujtFontosElem.Click();
        }
Example #6
0
        private void kattintNehezLovassag()
        {
            //Nehézlovasság
            gyulekezohelyGyujtFontosElem = vezerlo.FindElementsByClassName("units-entry-all").
                                           First(l => l.GetAttribute("data-unit") == "heavy");

            gyulekezohelyGyujtFontosElem.Click();
        }
Example #7
0
 private static void ClickAtElement(OpenQA.Selenium.IWebElement element)
 {
     do
     {
         Thread.Sleep(1000);
     } while (!element.Displayed);
     element.Click();
     Thread.Sleep(15000);
 }
 private void SetImageElement()
 {
     if (isGroup)
     {
         elemAddImage = driver.FindElement(OpenQA.Selenium.By.Name("composer_photo[]"), 10);
     }
     else
     {
         elemAddImage = driver.FindElement(OpenQA.Selenium.By.XPath("/html/body/div[1]/div[3]/div[1]/div/div[2]/div[2]/div[1]/div[2]/div/div[3]/div/div/div[2]/div/div/div/form/div[2]/span/div[1]/div/a/div[2]/input"), 10);
     }
 }
Example #9
0
 private void vilagValasztas(int vilag)
 {
     try
     {
         kezelendoElem = vezerlo.FindElementsByClassName("world_button_active").
                         First(l => l.Text.Contains(kezeltFalu.Vilagszam + ""));
         kezelendoElem.Click();
     }
     catch
     {
     }
 }
Example #10
0
        private void Search(int row)
        {
            string valueToSearch = handle.GetNext(row, col);

            if (valueToSearch != null)
            {
                string textboxName       = "ctl00$ctl00$ctl00$BodyContent$ContentPlaceHolder1$MainContentPlaceHolder$ResourceHostControl1$resContainer$rptContainers$ctl00$rptColumn1$ctl00$ctl01$Wrapper$txtSearchString";
                string attributeDropdown = "ctl00$ctl00$ctl00$BodyContent$ContentPlaceHolder1$MainContentPlaceHolder$ResourceHostControl1$resContainer$rptContainers$ctl00$rptColumn1$ctl00$ctl01$Wrapper$lbxNodeProperty";
                string searchBtnId       = "ctl00_ctl00_ctl00_BodyContent_ContentPlaceHolder1_MainContentPlaceHolder_ResourceHostControl1_resContainer_rptContainers_ctl00_rptColumn1_ctl00_ctl01_Wrapper_btnSearch";

                chrome.Navigate().GoToUrl("https://solarwindscs.dell.com/Orion/SummaryView.aspx?ViewID=1");

                while (IsElementPresent(textboxName, false, true) == false)
                {
                    Thread.Sleep(25);
                }
                try
                {
                    OpenQA.Selenium.IWebElement searchBox           = chrome.FindElementByName(textboxName);
                    OpenQA.Selenium.IWebElement dropBox             = chrome.FindElementByName(attributeDropdown);
                    OpenQA.Selenium.IWebElement searchBtn           = chrome.FindElementById(searchBtnId);
                    OpenQA.Selenium.Support.UI.SelectElement select = new OpenQA.Selenium.Support.UI.SelectElement(dropBox);
                    //Console.WriteLine("HHHHHHH");
                    searchBox.SendKeys(valueToSearch);
                    //Console.WriteLine("HHHHHHH");
                    select.SelectByIndex(attributeIndex);
                    // Console.WriteLine("uyguygufuov");
                    searchBtn.Click();
                    // Console.WriteLine("HHHHHHH");

                    while (IsElementPresent("StatusMessage", true, false) == false)
                    {
                        Thread.Sleep(25);
                    }

                    string result = chrome.FindElementByClassName("StatusMessage").Text;
                    if (result.Contains("Nodes with ") && result.Contains(" similar to "))
                    {
                        ReadOnlyCollection <OpenQA.Selenium.IWebElement> amount = chrome.FindElementsByClassName("StatusIcon");
                        //Console.WriteLine(amount.Count);
                        handle.AddResult(row, valueToSearch, "Y", (amount.Count - 1).ToString());
                    }
                    else
                    {
                        handle.AddResult(row, valueToSearch, "N", "0");
                    }
                }
                catch (Exception e)
                {
                    throw new WebSearchException(Thread.CurrentThread.ManagedThreadId.ToString());
                }
            }
        }
 private void SetPostTextElement()
 {
     if (isGroup)
     {
         elemPostText = driver.FindElement(OpenQA.Selenium.By.XPath("/html/body/div[1]/div[3]/div[1]/div/div[2]/div[2]/div[2]/div[2]/div[3]/div[1]/div/div/div[2]/div[1]/div/div/div/div[2]/div/div[1]/div[1]/div/div[1]/div[2]/div/div/div/div/div/div/div[2]/div"), 40);
     }
     else
     {
         driver.FindElement(OpenQA.Selenium.By.Name("xhpc_message"), 10).SendKeys(OpenQA.Selenium.Keys.Return);
         elemPostText = driver.FindElement(OpenQA.Selenium.By.XPath("//div [@data-testid='status-attachment-mentions-input']"), 10);
     }
 }
 public void Click(UI.UIClickAction action)
 {
     try
     {
         action.Status = TestResultType.Fail;
         OpenQA.Selenium.IWebElement element = SeleniumUIHelper.GetElement(this.Driver, SeleniumUIHelper.GetBy(action.Element));
         element.Click();
         action.Status = TestResultType.Success;
     }
     catch (System.Exception)
     {
         action.Status = TestResultType.Fail;
         string fileName = string.Format("{0}_{1}_{2}.png", action.TestCaseAction.TestCase.TestCaseRef.Key, action.TestCaseAction.ActionRef.Action, System.DateTime.Now.ToString("yyyyMMddHHmmssms"));
         SeleniumScreenshotHelper.CreateScreenshot(this.Driver, this.TestRunner.Environment, fileName);
         action.Error = new ValidationException("Common.ElementCanNotFound", action.Element, fileName);
     }
 }
Example #13
0
        public void GivenAnEventExists(Table events)
        {
            foreach (var e in events.Rows)
            {
                e["Name"] += uniqueStamp;
                BBCRMHomePage.OpenEventsFA();
                //spawn form
                Panel.WaitClick("//table[contains(@class,'x-btn bbui-pages-section-collapsesection x-btn-icon')]/tbody/tr[2]/td[2]/em/button");
                Panel.WaitClick("//button[./text()='Add new' and contains(@class,'x-btn-text bbui-valuestyles-new-imageandtext')]");
                Panel.WaitClick("//span[./text()='Event']");

                //set form vars and save
                Dialog.SetTextField("//input[contains(@id,'_NAME_value')]", e["Name"]);
                OpenQA.Selenium.IWebElement _web = Dialog.GetEnabledElement("//input[contains(@id,'_STARTDATE_value')]");
                _web.SendKeys(e["Start date"]);
                Dialog.Save();
            }
        }
        public void GotoWebHomeProjectDevOpsMetricsPageTest()
        {
            //Arrange
            bool webLoaded;

            //Act
            string webURL = _webUrl + "Home//Project?rowKey=samsmithnz_DevOpsMetrics_DevOpsMetrics%20CI%2FCD";

            Console.WriteLine("webURL:" + webURL);
            _driver.Navigate().GoToUrl(webURL);
            webLoaded = (_driver.Url == webURL);
            OpenQA.Selenium.IWebElement data = _driver.FindElementByXPath(@"/html/body/div/main/form/h2");
            Debug.WriteLine("data:" + data.Text);

            //Assert
            Assert.IsTrue(webLoaded);
            Assert.IsTrue(data != null);
            Assert.AreEqual(data.Text, "  GitHub - DevOpsMetrics high performing DevOps metrics");
        }
        public void GotoWebHomeMTTRPageTest()
        {
            //Arrange
            bool webLoaded;

            //Act
            string webURL = _webUrl + "Home/MeanTimeToRestore";

            Console.WriteLine("webURL:" + webURL);
            _driver.Navigate().GoToUrl(webURL);
            webLoaded = (_driver.Url == webURL);
            OpenQA.Selenium.IWebElement data = _driver.FindElementByXPath(@"/html/body/div/main/h2");
            Console.WriteLine("data:" + data.Text);

            //Assert
            Assert.IsTrue(webLoaded);
            Assert.IsTrue(data != null);
            Assert.AreEqual(data.Text, "Time to restore service");
        }
        public void GotoWebHomeIndexPageTest()
        {
            //Arrange
            bool webLoaded;

            //Act
            string webURL = _webUrl + "home";

            Console.WriteLine("webURL:" + webURL);
            _driver.Navigate().GoToUrl(webURL);
            webLoaded = (_driver.Url == webURL);
            OpenQA.Selenium.IWebElement data = _driver.FindElementByXPath(@"/html/body/div/main/h2");
            Console.WriteLine("data:" + data.Text);

            //Assert
            Assert.IsTrue(webLoaded);
            Assert.IsTrue(data != null);
            Assert.AreEqual(data.Text, "High performing DevOps metrics");
        }
Example #17
0
        private void gyujtogetes()
        {
            megnyitGyujtogetes();

            /* if (jatekos == Account.botAcc)
             * {
             *   try
             *   {
             *       vezerlo.FindElementsByTagName("a").First(l => l.getInnerHTML().Contains("Kinyit")).Click();
             *       vezerlo.FindElementsByTagName("a").Last(l => l.getInnerHTML().Contains("Kinyit")).Click();
             *   }
             *   catch(Exception hiba)
             *   {
             *       MessageBox.Show(hiba.Message);
             *   }
             *
             *   megnyitGyujtogetes();
             * }*/


            kattintlLandzsasok();

            gyulekezohelyGyujtFontosElem = vezerlo.FindElementByClassName("carry-max");

            fosztogatoKapacitasSzoveg = gyulekezohelyGyujtFontosElem.getInnerHTML();

            if (atalakitSzamma(fosztogatoKapacitasSzoveg) > 0)
            {
                try
                {
                    csapatokKuldeseKivaloGyujtogetok();
                }
                catch
                {
                }
            }
            else
            {
                //MessageBox.Show("Nincsenek szabad katonák.");
            }

            tobbiekElkuldese();
        }
Example #18
0
        private void megnyitGyujtogetes()
        {
            visszateresFaluAttekintesre();

            megnyitGyulekezohely();

            foreach (OpenQA.Selenium.IWebElement link in vezerlo.FindElementByClassName("modemenu").
                     FindElements(OpenQA.Selenium.By.TagName("a")))
            {
                if (i == 2)
                {
                    gyulekezohelyGyujtFontosElem = link;
                }
                i++;
            }

            i = 0;

            gyulekezohelyGyujtFontosElem.Click();
        }
        public void preparePostToFB(string postText, string pathToPhoto)
        {
            if (!(pathToPhoto is null))
            {
                SetImageElement();
                elemAddImage.SendKeys(pathToPhoto);
                if (isGroup)
                {
                    //This line is because in group posts, I need to wait until the post button is enabled before going to publishPost()
                    //or the photo would be lost.
                    OpenQA.Selenium.IWebElement elemPostButton = driver.FindElement(OpenQA.Selenium.By.XPath("//button [@data-testid='react-composer-post-button']"), 60, true);
                }
            }

            if (!postText.Equals(string.Empty))
            {
                SetPostTextElement();
                elemPostText.SendKeys(postText);
            }
        }
    public static Bitmap TakeScreenshot(this OpenQA.Selenium.IWebElement element)
    {
        RemoteWebDriver driver = (RemoteWebDriver)((RemoteWebElement)element).WrappedDriver;

        if (((IHasCapabilities)driver).Capabilities.HasCapability("takesElementScreenshot"))
        {
            byte[] bytes = ((RemoteWebElement)element).GetScreenshot().AsByteArray;
            return((Bitmap)Bitmap.FromStream(new MemoryStream(bytes, 0, bytes.Length, false, true), false, false));
        }
        else
        {
            var dict = (Dictionary <String, Object>)driver.ExecuteScript(@"
                    arguments[0].scrollIntoView(true);
                    var r = arguments[0].getBoundingClientRect(), scrollX = 0, scrollY = 0;
                    for(var e = arguments[0]; e; e=e.parentNode) {
                      scrollX += e.scrollLeft || 0;
                      scrollY += e.scrollTop || 0;
                    }
                    return {left: r.left|0, top: r.top|0, width: r.width|0, height: r.height|0
                           , scrollX: scrollX, scrollY: scrollY, innerHeight: window.innerHeight}; "
                                                                         , element);
            var rect = new System.Drawing.Rectangle(
                Convert.ToInt32(dict["left"]),
                Convert.ToInt32(dict["top"]),
                Convert.ToInt32(dict["width"]),
                Convert.ToInt32(dict["height"]));
            byte[] bytes = driver.GetScreenshot().AsByteArray;
            using (Bitmap bitmap = (Bitmap)Bitmap.FromStream(new MemoryStream(bytes, 0, bytes.Length, false, true), false, false)) {
                if (bitmap.Height > Convert.ToInt32(dict["innerHeight"]))
                {
                    rect.Offset(Convert.ToInt32(dict["scrollX"]), Convert.ToInt32(dict["scrollY"]));
                }
                rect.Intersect(new System.Drawing.Rectangle(0, 0, bitmap.Width, bitmap.Height));
                if (rect.Height == 0 || rect.Width == 0)
                {
                    throw new WebDriverException("WebElement is outside of the screenshot.");
                }
                return(bitmap.Clone(rect, bitmap.PixelFormat));
            }
        }
    }
Example #21
0
        public void WhenIAddEvents(Table eventsToAdd)
        {
            BBCRMHomePage.OpenEventsFA();
            foreach (var eventToAdd in eventsToAdd.Rows)
            {
                eventToAdd["Name"] += uniqueStamp;
                BBCRMHomePage.OpenEventsFA();
                //spawn form
                Panel.WaitClick("//table[contains(@class,'x-btn bbui-pages-section-collapsesection x-btn-icon')]/tbody/tr[2]/td[2]/em/button");
                Panel.WaitClick("//button[./text()='Add new' and contains(@class,'x-btn-text bbui-valuestyles-new-imageandtext')]");
                Panel.WaitClick("//span[./text()='Event']");

                //set form vars and save
                Dialog.SetTextField("//input[contains(@id,'_NAME_value')]", eventToAdd["Name"]);
                OpenQA.Selenium.IWebElement _web = Dialog.GetEnabledElement("//input[contains(@id,'_STARTDATE_value')]");
                _web.SendKeys(eventToAdd["Start date"]);
                if (eventToAdd["Location"] != null && !string.IsNullOrEmpty(eventToAdd["Location"].ToString()))
                {
                    Dialog.SetTextField("//input[contains(@id,'_EVENTLOCATIONID_value')]", eventToAdd["Location"]);
                }
                Dialog.Save();
            }
        }
Example #22
0
        public void GotoFeatureFlagsServiceFeatureFlagsTest()
        {
            //Arrange
            bool serviceLoaded;

            //Act
            string serviceURL = _serviceUrl + "api/featureflags/getfeatureflags";

            Console.WriteLine(serviceURL);
            _driver.Navigate().GoToUrl(serviceURL);
            serviceLoaded = (_driver.Url == serviceURL);
            OpenQA.Selenium.IWebElement data = _driver.FindElementByXPath(@"/html/body/pre");

            //Assert
            Assert.IsTrue(serviceLoaded);
            Assert.IsTrue(data != null);
            //Convert the JSON to the feature flags model
            IEnumerable <FeatureFlag> featureFlags = JsonConvert.DeserializeObject <IEnumerable <FeatureFlag> >(data.Text);

            Assert.IsTrue(featureFlags.Count() > 0);                             //There is more than one owner
            Assert.IsTrue(featureFlags.FirstOrDefault().Name.Length > 0);        //The first flag has an id
            Assert.IsTrue(featureFlags.FirstOrDefault().Description.Length > 0); //The first flag has an name
        }
 private void SetPassword(string password)
 {
     elemPassword = driver.FindElement(OpenQA.Selenium.By.Id("pass"));
     elemPassword.SendKeys(password);
 }
 private void SetUsername(string username)
 {
     elemUsername = driver.FindElement(OpenQA.Selenium.By.Id("email"));
     elemUsername.SendKeys(username);
 }
 public void publishPost()
 {
     OpenQA.Selenium.IWebElement elemPostButton = driver.FindElement(OpenQA.Selenium.By.XPath("//button [@data-testid='react-composer-post-button']"), 10);
     elemPostButton.Click();
 }
Example #26
0
 internal void executeScript(string p, OpenQA.Selenium.IWebElement element)
 {
     throw new NotImplementedException();
 }
Example #27
0
        public void WaitUntilElementClickable(string id, SearchType search)
        {
            var wait = GetWait();

            OpenQA.Selenium.IWebElement element = wait.Until(OpenQA.Selenium.Support.UI.ExpectedConditions.ElementToBeClickable(this.Driver.GetElementById(id, search)));
        }
Example #28
0
 private void kijelolOsszesEgyseg()
 {
     gyulekezohelyGyujtFontosElem = vezerlo.FindElementsByTagName("a").
                                    First(l => l.getInnerHTML().Contains("Összes csapat"));
     gyulekezohelyGyujtFontosElem.Click();
 }