Example #1
0
 public static IWebElement ExplicitWait(IWebDriver driver, string Identifier)
 {
     return(new WebDriverWait(driver, TimeSpan.FromSeconds(5)).Until(ExpectedConditions.ElementExists(By.Id(Identifier))));
 }
Example #2
0
        static void Main(string[] args)
        {
            {
                var driver = new ChromeDriver(Environment.CurrentDirectory);
                //Console.WriteLine("TEST!");
                //driver.Manage().Timeouts().PageLoad = TimeSpan.FromMinutes(3);
                WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(30));
                driver.Navigate().GoToUrl("https://finance.yahoo.com/");
                wait.Until(ExpectedConditions.ElementExists(By.Id("uh-signedin")));

                driver.FindElement(By.XPath(".//a[@id = 'uh-signedin']")).Click();


                Console.WriteLine("Email:");
                var userName = Console.ReadLine();

                driver.FindElement(By.XPath(".//input[@name = 'username']")).SendKeys(userName);

                driver.FindElement(By.XPath(".//input[@id= 'login-signin']")).Click();

                Console.WriteLine("Password:"******".//input[@id = 'login-passwd']")).SendKeys(passWord);
                driver.FindElement(By.XPath(".//button[@id = 'login-signin']")).Click();

                // Navigate to My portfolio page
                driver.FindElement(By.XPath(".//a[@title = 'My Portfolio']")).Click();

                // Wit for pop up, then click 'x' to exit pop up
                wait.Until(ExpectedConditions.ElementExists(By.XPath("//dialog[@id = '__dialog']/section/button")));
                driver.FindElement(By.XPath("//dialog[@id = '__dialog']/section/button")).Click();

                // Click on watch list under Portfolio
                driver.FindElement(By.XPath("//*[@id=\"main\"]/section/section/div[2]/table/tbody/tr[1]/td[1]/a")).Click();


                // Ready to scrape data to console
                wait.Until(ExpectedConditions.ElementExists(By.XPath("//html[1]/body[1]/div[2]/div[3]/section[1]/section[2]/div[2]/table[1]/tbody[1]")));
                var table    = driver.FindElement(By.XPath("/html[1]/body[1]/div[2]/div[3]/section[1]/section[2]/div[2]/table[1]/tbody[1]"));
                var children = table.FindElements(By.XPath(".//*"));
                //Console.WriteLine(table);

                List <IWebElement> elements = new List <IWebElement>();
                elements = driver.FindElements(By.XPath("//tbody/tr")).ToList <IWebElement>();


                List <Stock> PortStocks = new List <Stock>();

                foreach (var stock in elements)
                {
                    var      newStock     = Convert.ToString(stock.Text);
                    string[] anotherStock = newStock.Split(' ');
                    //foreach(var item in anotherStock)
                    //{
                    //    Console.WriteLine(item);
                    //}
                    PortStocks.Add(new Stock()
                    {
                        StockSymbol = anotherStock[0], LastPrice = anotherStock[1],
                        MarketTime  = "0" + anotherStock[5] + ":00",
                        PriceChange = anotherStock[2], PercentChange = anotherStock[3]
                    });
                }

                foreach (var stock in PortStocks)
                {
                    Console.WriteLine(stock.StockSymbol);
                    Console.WriteLine(stock.LastPrice);
                    Console.WriteLine(stock.MarketTime);
                    Console.WriteLine(stock.PriceChange);
                    Console.WriteLine(stock.PercentChange);
                }



                // Set Up Local Database
                var connString = "Host=localhost;Username=urbensonlaurent;Password=davidbabo16;Database=teststocks";

                using (var connect = new NpgsqlConnection(connString))
                {
                    connect.Open();

                    // Insert some data
                    using (var cmd = new NpgsqlCommand())
                    {
                        cmd.Connection = connect;
                        foreach (var stock in PortStocks)
                        {
                            string data = string.Format("INSERT INTO stockington (SYMBOL, LASTPRICE, CHANGE, DATETIME) VALUES ('{0}','{1}',{2},'{3}')", stock.StockSymbol, stock.LastPrice, stock.PriceChange, stock.MarketTime);
                            cmd.CommandText = data;
                            cmd.ExecuteNonQuery();
                        }
                    }
                }
            }
        }
Example #3
0
        //Waits for an element to appear
        public static void WaitUntil(string xpath, int time)
        {
            WebDriverWait waitForElement = new WebDriverWait(PropertiesCollection.driver, TimeSpan.FromSeconds(time));

            waitForElement.Until(ExpectedConditions.ElementExists(By.XPath(xpath)));
        }
Example #4
0
        //This function search the required video and verify the same and navigate to video landing page
        public void searchVideoVerification(string videoname, string guid_Admin)
        {
            log.Info("searchVideoVerification::::");

            Boolean flag = false;

            //wait till jquery gets completed
            uf.isJqueryActive(driver);

            handlePromotionalPopup();

            handleEmergencyPopUp();

            Thread.Sleep(5000);

            iWait.Until(ExpectedConditions.ElementExists((OR.GetElement("VideoLandingPage", "SearchTB", "TVWebPortalOR.xml"))));

            //search the required video
            IWebElement SearchTextField = driver.FindElement((OR.GetElement("VideoLandingPage", "SearchTB", "TVWebPortalOR.xml")));

            SearchTextField.SendKeys(videoname);

            iWait.Until(ExpectedConditions.ElementToBeClickable((OR.GetElement("VideoLandingPage", "SearchIcon", "TVWebPortalOR.xml"))));

            //Click on searchIcon
            IWebElement SearchIcon = driver.FindElement((OR.GetElement("VideoLandingPage", "SearchIcon", "TVWebPortalOR.xml")));

            SearchIcon.Click();
            Thread.Sleep(2000);

            //handleEmergencyPopUp();

            uf.isJqueryActive(driver);



            //verifying the search result
            IList <IWebElement> videoSearchList = (IList <IWebElement>)driver.FindElement((OR.GetElement("VideoLandingPage", "SearchResult", "TVWebPortalOR.xml"))).FindElements(OR.GetElement("VideoLandingPage", "SearchResultRecord", "TVWebPortalOR.xml"));


            //gettting the search result details
            foreach (IWebElement currentSearchrecord in videoSearchList)
            {
                IWebElement searchresultDetails = driver.FindElement((OR.GetElement("VideoLandingPage", "SearchResultDetails", "TVWebPortalOR.xml")));
                String      webvideoTitle       = searchresultDetails.Text.Trim();

                //getting video Title from search result
                if (webvideoTitle.Equals(videoname))
                {
                    flag = true;

                    String videoID_Web = searchresultDetails.GetAttribute("data-videono");

                    String guid_Web = searchresultDetails.GetAttribute("data-videoid");

                    cf.writingIntoXML("AdminPortal", "VideoManagement", "VideoID", videoID_Web, "SysConfig.xml");

                    //verifying the Video Guid match on webportal with admin portal
                    Assert.AreEqual(guid_Admin, guid_Web);

                    IWebElement serachResultLink = driver.FindElement((OR.GetElement("VideoLandingPage", "SearchResultLink", "TVWebPortalOR.xml")));

                    log.Info("Web Video Title:" + webvideoTitle + " at line:" + new StackTrace(true).GetFrame(0).GetFileLineNumber());

                    serachResultLink.Click();

                    uf.isJqueryActive(driver);

                    break;
                }
            }
        }
 public IWebElement DueDate()
 {
     return(explicitWait.Until(ExpectedConditions.ElementExists(dueDate)));
 }
        public bool dragDropSwinlineInBackLog()
        {
            List <object> objectDisplay = new List <object>();
            Validacao     validacao     = new Validacao();
            WebDriverWait wait          = new WebDriverWait(SetUp.Driver, TimeSpan.FromSeconds(50));

            wait.Until(ExpectedConditions.ElementExists(By.CssSelector(".ui-draggable.ui-droppable")));
            IWebElement         panelBacklog = SetUp.Driver.FindElement(By.CssSelector("#__xmlview0--spliterBacklogCardView-content-0"));
            IList <IWebElement> listDragDrop = SetUp.Driver.FindElements(By.CssSelector(".ui-draggable.ui-droppable"));
            IList <IWebElement> listBacklog  = SetUp.Driver.FindElements(By.CssSelector(".BacklogOperation-Card"));
            var cardDragDrop = listDragDrop.Where(x => x.GetAttribute("innerText").Contains(workCenterName)).FirstOrDefault();

            for (int pos = 0; pos < listDragDrop.Count;)
            {
                listDragDrop = SetUp.Driver.FindElements(By.CssSelector(".ui-draggable.ui-droppable"));
                panelBacklog = SetUp.Driver.FindElement(By.CssSelector("#__xmlview0--spliterBacklogCardView-content-0"));
                cardDragDrop = listDragDrop.Where(x => x.GetAttribute("innerText").Contains(workCenterName)).FirstOrDefault();
                if (listDragDrop.Count == 0)
                {
                    break;
                }
                Actions actions = new Actions(SetUp.Driver);
                actions.DragAndDrop(cardDragDrop, panelBacklog).Build().Perform();
                wait.Until(ExpectedConditions.InvisibilityOfElementLocated(By.CssSelector("#sap-ui-blocklayer-popup")));
                listBacklog = SetUp.Driver.FindElements(By.CssSelector(".BacklogOperation-Card"));
                for (int card = 0; card < listBacklog.Count();)
                {
                    var    lastList           = listBacklog.Last();
                    var    stringSplitBacklog = lastList.Text.Split(new string[] { "\r\n" }, StringSplitOptions.None);
                    string orderIdBacklog     = stringSplitBacklog[0].Replace(" ", "");
                    orderIdBacklog = orderIdBacklog.Split('-')[0];
                    getOrderIdList.Add(orderIdBacklog);
                    getOrderIdList.Last();
                    getSplitOrderId = getOrderIdListToString();
                    break;
                }
                wait.Until(ExpectedConditions.InvisibilityOfElementLocated(By.CssSelector("#sap-ui-blocklayer-popup")));
                listDragDrop = SetUp.Driver.FindElements(By.CssSelector(".ui-draggable.ui-droppable"));
                new Schedule_SapConnect().tableBLOper(getPlanningIDExcel, getSplitOrderId);
                ExcelWorksheet xlsxInput              = Schedule_BLOperExcel.XlsxInput;
                var            planilha               = xlsxInput;
                var            linha                  = 2;
                string         orderIdExcel           = planilha.Cells[linha, 1]?.Value?.ToString();
                string         activityExcel          = planilha.Cells[linha, 2]?.Value?.ToString();
                string         excelJoinOrderActivity = orderIdExcel + "-" + activityExcel;
                string         excelControlKey        = planilha.Cells[linha, 4]?.Value?.ToString();
                string         excelWorkCenter        = planilha.Cells[linha, 5]?.Value?.ToString();
                string         excelDescription       = planilha.Cells[linha, 7]?.Value?.ToString();
                string         excelDate              = planilha.Cells[linha, 11]?.Value?.ToString();
                string         excelHour              = planilha.Cells[linha, 12]?.Value?.ToString();
                string         excelJoinDateHour      = excelDate + " - " + excelHour;
                listBacklog = SetUp.Driver.FindElements(By.CssSelector(".BacklogOperation-Card"));
                bool exist = false;
                listBacklog.Where(x => x.Text.Contains(excelJoinOrderActivity))
                .ToList()
                .ForEach(row =>
                {
                    if ((row.Text.Contains(excelWorkCenter) && row.Text.Contains(excelDescription)) &&
                        ((row.Text.Contains(excelJoinDateHour) && row.Text.Contains(excelControlKey))))
                    {
                        cardChangePosition = row;
                        new Util().HighlightElementPassou(cardChangePosition);
                        exist = true;
                    }
                    else
                    {
                        cardChangePosition = row;
                        new Util().HighlightElementFalhou(cardChangePosition);
                        exist = false;
                    }
                });
                if (exist.Equals(false))
                {
                    return(false);
                }
            }
            return(true);
        }
Example #7
0
        public void ThenTheResultShouldBeOnTheScreen(int result)
        {
            var input = _wait.Until(ExpectedConditions.ElementExists(By.Id("Result")));

            Assert.Equal(result, Convert.ToInt32(input.GetAttribute("value")));
        }
Example #8
0
 /**
  * 默认时间等待直到页面包含该控件
  * @param text    期望出现的文本
  * @param seconds    超时时间
  * @return    Boolean    检查给定文本是否存在于指定元素中, 超时则捕获抛出异常TimeoutException并返回false
  * @see    org.openqa.selenium.support.ui.ExpectedConditions.textToBePresentInElement(WebElement element, String text)
  */
 public static IWebElement WaitUntilPageExistsControl(By by)
 {
     try
     {
         IWebElement control = new WebDriverWait(Driver, TimeSpan.FromSeconds(timeOutInSeconds)).Until(ExpectedConditions.ElementExists(by));
         Thread.Sleep(2000);
         return(control);
     }
     catch (Exception e)
     {
         return(null);
     }
 }
 //This method watches the browser and waits for the form on the page to have fully loaded before moving forward.
 //It waits for the text box element with the Id of FirstName to be drawn.
 public void WaitForFormShown()
 {
     new WebDriverWait(driver, TimeSpan.FromSeconds(30)).Until(ExpectedConditions.ElementExists((By.Id("FirstName"))));
 }
Example #10
0
        public static void ForElement(By by, IWebDriver driver, TimeSpan timeSpan)
        {
            WebDriverWait wait = new WebDriverWait(driver, timeSpan);

            wait.Until(ExpectedConditions.ElementExists(by));
        }
        public void TVWeb_001_VerifyBottomBar()
        {
            try
            {
                log.Info("Verify Bottom Bar Test Started" + " at line:" + new StackTrace(true).GetFrame(0).GetFileLineNumber());

                IWebElement backToTop;

                IJavaScriptExecutor executor;

                String myCommunityURL, faceBookURL, twitterURL, linkedinURL, youTubeURL, myCommunityStatus, facebookStatus, twitterStatus, linkedinStatus, youTubeStatus, myIETHeader,
                       IETTvHelp, TvAccType, othIETSites, abtLinksURL, othLinksURL, bottomFooterURL, abtLinkStatus, othLinkStatus, IEThelpURL, IEThelpStatus, IETAccTypeURL, IETAccTypeStatus, bottomLinkStatus, copyRightText;

                IList <IWebElement> myCommunityLinks, myCommunity, facebook, twitter, linkedin, youTube, footerSection, footerFourSections, abtIET, abtHelp, abtAccType, abtOthSites, bottomFooter, bottomFooterList;

                String[] arrAbtIET       = { "Vision, mission & values", "People", "Our offices & venues", "Savoy Place upgrade", "Working at the IET" };
                String[] arrIETHelp      = { "FAQ", "Institution", "Technical requirements", "Contact", "Corporate", "Forgot password", "Delegate / Speaker access code" };
                String[] arrAccType      = { "Institution", "Members", "Visitor", "Corporate", "Individual" };
                String[] arrOthSites     = { "The IET", "E&T Jobs", "E&T Magazine", "", "IET Connect", "IET Digital Library", "IET Electrical", "IET Faraday", "IET Venues" };
                String[] arrBottomFooter = { "Cookies", "Privacy Statement", "Accessibility", "Legal Notices", "T&C" };


                int ScrollTop, cntFooterSections, cntGlobal = 0;

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

                wait.Until(ExpectedConditions.ElementExists(By.ClassName(or.readingXMLFile("BottomBar", "overLaySpinner", "TVWebPortalOR.xml"))));

                Thread.Sleep(2000);

                Boolean resScrollDown = uf.scrollDown(driver);

                log.Info("Scroll Down Result=" + resScrollDown + " at line:" + new StackTrace(true).GetFrame(0).GetFileLineNumber());

                Thread.Sleep(5000);

                // Verify scroll down is performed

                Assert.AreEqual(true, resScrollDown);

                backToTop = driver.FindElement(By.Id(or.readingXMLFile("BottomBar", "backToTop", "TVWebPortalOR.xml"))).FindElement(By.TagName("a"));

                // Verify Back to Top anchor is present

                Assert.AreEqual("Click to Go Top", backToTop.GetAttribute("title").ToString());

                // Click on Back to Top anchor

                executor = (IJavaScriptExecutor)driver;
                executor.ExecuteScript("arguments[0].click();", backToTop);

                Thread.Sleep(2000);

                // Verify Back to Top functionality

                ScrollTop = uf.getScrollTop(driver);

                Assert.AreEqual(0, ScrollTop);

                Thread.Sleep(2000);

                // Once again scroll down for link verification

                uf.scrollDown(driver);

                Thread.Sleep(2000);

                //////// Verify My Community Icon Presence and Status ///////

                myCommunityLinks = driver.FindElement(By.ClassName(or.readingXMLFile("BottomBar", "myCommunityLinks", "TVWebPortalOR.xml"))).FindElements(By.TagName("li"));

                log.Info("Total icon List" + myCommunityLinks.Count + " at line:" + new StackTrace(true).GetFrame(0).GetFileLineNumber());

                // Verify Total No. of My community icons

                Assert.AreEqual(5, myCommunityLinks.Count);

                // Verify MyCommunity section is present

                myCommunity = myCommunityLinks.ElementAt(0).FindElements(By.TagName("a"));

                Assert.AreEqual(1, myCommunity.Count);

                myCommunityURL = myCommunity.ElementAt(0).GetAttribute("href").ToString();

                log.Info("My Community URL:" + myCommunityURL + " at line:" + new StackTrace(true).GetFrame(0).GetFileLineNumber());

                // Verify MyCommunity URL

                Assert.AreEqual("http://mycommunity.theiet.org/?origin=foot-social", myCommunityURL);

                // Verify MyCommunity Request Status

                myCommunityStatus = uf.getStatusCode(new Uri(myCommunityURL.ToString()));

                Assert.AreEqual("OK", myCommunityStatus);

                // Verify MyCommunity icon title text

                Assert.AreEqual("My Community icon", myCommunity.ElementAt(0).FindElement(By.TagName("img")).GetAttribute("title").ToString());

                // Verify MyCommunity text

                Assert.AreEqual("MyCommunity", myCommunity.ElementAt(0).FindElement(By.TagName("span")).Text.ToString());

                // Verify Facebook icon is present and it's status

                facebook = myCommunityLinks.ElementAt(1).FindElements(By.TagName("a"));

                faceBookURL = facebook.ElementAt(0).GetAttribute("href").ToString();

                log.Info("Facebook URL:" + faceBookURL + " at line:" + new StackTrace(true).GetFrame(0).GetFileLineNumber());

                // Verify Facebook URL

                Assert.AreEqual("http://www.theiet.org/policy/media/follow/facebook.cfm?origin=foot-social", faceBookURL);

                // Verify Facebook Request Status

                facebookStatus = uf.getStatusCode(new Uri(faceBookURL.ToString()));

                Assert.AreEqual("OK", facebookStatus);

                // Verify Facebook icon title text

                Assert.AreEqual("Facebook icon", facebook.ElementAt(0).FindElement(By.TagName("img")).GetAttribute("title").ToString());

                // Verify Twitter icon is present and it's status

                twitter = myCommunityLinks.ElementAt(2).FindElements(By.TagName("a"));

                twitterURL = twitter.ElementAt(0).GetAttribute("href").ToString();

                log.Info("Twitter URL:" + twitterURL + " at line:" + new StackTrace(true).GetFrame(0).GetFileLineNumber());

                // Verify Twitter URL

                Assert.AreEqual("http://www.theiet.org/policy/media/follow/twitter.cfm?origin=foot-social", twitterURL);

                // Verify Twitter Request Status

                twitterStatus = uf.getStatusCode(new Uri(twitterURL.ToString()));

                Assert.AreEqual("OK", twitterStatus);

                // Verify Twitter icon title text

                Assert.AreEqual("Twitter icon", twitter.ElementAt(0).FindElement(By.TagName("img")).GetAttribute("title").ToString());

                // Verify Linkedin icon is present and it's status

                linkedin = myCommunityLinks.ElementAt(3).FindElements(By.TagName("a"));

                linkedinURL = linkedin.ElementAt(0).GetAttribute("href").ToString();

                log.Info("Linkedin URL:" + linkedinURL + " at line:" + new StackTrace(true).GetFrame(0).GetFileLineNumber());

                // Verify Linkedin URL

                Assert.AreEqual("http://www.theiet.org/policy/media/follow/linkedin.cfm?origin=foot-social", linkedinURL);

                // Verify Linkedin Request Status

                linkedinStatus = uf.getStatusCode(new Uri(linkedinURL.ToString()));

                Assert.AreEqual("OK", linkedinStatus);

                // Verify Linkedin icon title text

                Assert.AreEqual("LinkedIn icon", linkedin.ElementAt(0).FindElement(By.TagName("img")).GetAttribute("title").ToString());

                // Verify Youtube icon is present and it's status

                youTube = myCommunityLinks.ElementAt(4).FindElements(By.TagName("a"));

                youTubeURL = youTube.ElementAt(0).GetAttribute("href").ToString();

                log.Info("YouTube URL:" + youTubeURL);

                // Verify YouTube URL

                Assert.AreEqual("http://www.theiet.org/policy/media/follow/youtube.cfm?origin=foot-social", youTubeURL);

                // Verify YouTube Request Status

                youTubeStatus = uf.getStatusCode(new Uri(youTubeURL.ToString()));

                Assert.AreEqual("OK", youTubeStatus);

                // Verify four sections are present in footer

                footerSection = driver.FindElements(By.CssSelector(or.readingXMLFile("BottomBar", "footerFourSections", "TVWebPortalOR.xml")));

                cntFooterSections = footerSection.Count();

                Assert.AreEqual(1, cntFooterSections);

                footerFourSections = footerSection.ElementAt(0).FindElements(By.TagName("div"));

                log.Info("Total Footer Sections:" + footerFourSections.Count + " at line:" + new StackTrace(true).GetFrame(0).GetFileLineNumber());

                Assert.AreEqual(4, footerFourSections.Count);

                // {This needs to be taken from Test Data - Currently it is mentioned in test script}

                // Verify About the IET section

                myIETHeader = footerFourSections.ElementAt(0).FindElement(By.TagName("h4")).Text.ToString();

                log.Info("My IET Header:" + myIETHeader);

                // Verify My IET section header text

                Assert.AreEqual("About the IET", myIETHeader);

                abtIET = footerFourSections.ElementAt(0).FindElement(By.TagName("ul")).FindElements(By.TagName("li"));

                // Verify expected no. of links are present under About the IET

                Assert.AreEqual(5, abtIET.Count());

                // Verifying all links present under 'About the IET' section

                foreach (String val in arrAbtIET)
                {
                    log.Info("Verifying " + val + " at line:" + new StackTrace(true).GetFrame(0).GetFileLineNumber());

                    Assert.AreEqual(abtIET.ElementAt(cntGlobal).FindElement(By.TagName("a")).Text, val);

                    abtLinksURL = abtIET.ElementAt(cntGlobal).FindElement(By.TagName("a")).GetAttribute("href").ToString();

                    abtLinkStatus = uf.getStatusCode(new Uri(myCommunityURL.ToString()));

                    Assert.AreEqual("OK", abtLinkStatus);

                    cntGlobal++;
                }

                // Verify IET.tV help section

                IETTvHelp = footerFourSections.ElementAt(1).FindElement(By.TagName("h4")).Text.ToString();

                log.Info("IET TV Help:" + IETTvHelp);

                // Verify IET TV. help section header text

                Assert.AreEqual("IET.tv help", IETTvHelp);

                cntGlobal = 0;

                abtHelp = footerFourSections.ElementAt(1).FindElement(By.TagName("ul")).FindElements(By.TagName("li"));

                // Verify expected no. of links are present under 'IET.tv help'

                Assert.AreEqual(7, abtHelp.Count());

                // Verifying all links present under 'IET.tv help' section

                foreach (String val in arrIETHelp)
                {
                    log.Info("Verifying " + val + " at line:" + new StackTrace(true).GetFrame(0).GetFileLineNumber());

                    Assert.AreEqual(abtHelp.ElementAt(cntGlobal).FindElement(By.TagName("a")).Text, val);

                    String newVal = val.Replace(" ", "-");

                    if (cntGlobal == 0)
                    {
                        IEThelpURL = driver.Url.ToString() + "?" + newVal.ToLower();
                    }
                    else if (cntGlobal == 1 || cntGlobal == 4)
                    {
                        IEThelpURL = driver.Url.ToString() + "?services=h" + newVal.ToLower();
                    }
                    else
                    {
                        IEThelpURL = driver.Url.ToString() + "?services=" + newVal.ToLower();
                    }

                    log.Info("IET HELP URL:= " + IEThelpURL);

                    IEThelpStatus = uf.getStatusCode(new Uri(IEThelpURL.ToString()));

                    Assert.AreEqual("OK", IEThelpStatus);

                    cntGlobal++;
                }

                // Verify IET.tv account types section

                TvAccType = footerFourSections.ElementAt(2).FindElement(By.TagName("h4")).Text.ToString();

                log.Info("IET TV Account Types:" + TvAccType + " at line:" + new StackTrace(true).GetFrame(0).GetFileLineNumber());

                // Verify IET TV. account types header text

                Assert.AreEqual("IET.tv account types", TvAccType);

                cntGlobal = 0;

                abtAccType = footerFourSections.ElementAt(2).FindElement(By.TagName("ul")).FindElements(By.TagName("li"));

                // Verify expected no. of links are present under 'IET.tv account types'

                Assert.AreEqual(5, abtAccType.Count());

                // Verifying all links present under 'IET.tv help' section

                foreach (String val in arrAccType)
                {
                    log.Info("Verifying " + val + " at line:" + new StackTrace(true).GetFrame(0).GetFileLineNumber());

                    Assert.AreEqual(abtAccType.ElementAt(cntGlobal).FindElement(By.TagName("a")).Text, val);

                    String newVal = val.Replace(" ", "-");

                    if (cntGlobal == 0 || cntGlobal == 3)
                    {
                        IETAccTypeURL = driver.Url.ToString() + "?services=a" + newVal.ToLower();
                    }
                    else
                    {
                        IETAccTypeURL = driver.Url.ToString() + "?services=" + newVal.ToLower();
                    }

                    log.Info("IET Acc Type URL:= " + IETAccTypeURL + " at line:" + new StackTrace(true).GetFrame(0).GetFileLineNumber());

                    IETAccTypeStatus = uf.getStatusCode(new Uri(IETAccTypeURL.ToString()));

                    Assert.AreEqual("OK", IETAccTypeStatus);

                    cntGlobal++;
                }


                // Verify Other IET websites section

                othIETSites = footerFourSections.ElementAt(3).FindElement(By.TagName("h4")).Text.ToString();

                log.Info("Other IET WebSites:" + othIETSites + " at line:" + new StackTrace(true).GetFrame(0).GetFileLineNumber());

                // Verify IET TV. help section header text

                Assert.AreEqual("Other IET websites", othIETSites);

                cntGlobal = 0;

                abtOthSites = footerFourSections.ElementAt(3).FindElement(By.TagName("ul")).FindElements(By.TagName("li"));

                Assert.AreEqual(9, abtOthSites.Count());

                // Verifying all links present under 'About the IET' section

                foreach (String val in arrOthSites)
                {
                    if (cntGlobal != 3)
                    {
                        log.Info("Verifying " + val + " at line:" + new StackTrace(true).GetFrame(0).GetFileLineNumber());

                        Assert.AreEqual(abtOthSites.ElementAt(cntGlobal).FindElement(By.TagName("a")).Text, val);

                        othLinksURL = abtOthSites.ElementAt(cntGlobal).FindElement(By.TagName("a")).GetAttribute("href").ToString();

                        log.Info("Other IET Websites:= " + othLinksURL + " at line:" + new StackTrace(true).GetFrame(0).GetFileLineNumber());

                        othLinkStatus = uf.getStatusCode(new Uri(othLinksURL.ToString()));

                        Assert.AreEqual("OK", othLinkStatus);
                    }

                    cntGlobal++;
                }

                // Verify Bottom Footer - Cookies, Privacy statement etc.

                cntGlobal = 0;

                bottomFooter = driver.FindElements(By.CssSelector(or.readingXMLFile("BottomBar", "bottomFooter", "TVWebPortalOR.xml")));

                Assert.AreEqual(1, bottomFooter.Count());

                // Verify Bottom Footer is present

                bottomFooterList = bottomFooter.ElementAt(0).FindElement(By.TagName("div")).FindElements(By.TagName("a"));

                foreach (String val in arrBottomFooter)
                {
                    log.Info("Verifying " + val + " at line:" + new StackTrace(true).GetFrame(0).GetFileLineNumber());

                    // Verify bottom footer value is present as expected

                    Assert.AreEqual(val, bottomFooterList.ElementAt(cntGlobal).Text);

                    bottomFooterURL = bottomFooterList.ElementAt(cntGlobal).GetAttribute("href").ToString();

                    log.Info("Bottom Footer URL := " + bottomFooterURL + " at line:" + new StackTrace(true).GetFrame(0).GetFileLineNumber());

                    bottomLinkStatus = uf.getStatusCode(new Uri(bottomFooterURL.ToString()));

                    Assert.AreEqual("OK", bottomLinkStatus);

                    cntGlobal++;
                }

                // Verify Copyright text

                copyRightText = driver.FindElement(By.CssSelector(or.readingXMLFile("BottomBar", "copyRight", "TVWebPortalOR.xml"))).FindElement(By.TagName("p")).Text.ToString();

                log.Info("Copyright text:=" + copyRightText + " at line:" + new StackTrace(true).GetFrame(0).GetFileLineNumber());

                Assert.AreEqual("© 2015 The Institution of Engineering and Technology is registered as a Charity in England & Wales (no 211014) and Scotland (no SC038698)", copyRightText);
            }
            catch (Exception e)
            {
                log.Error(e.Message + " at line:" + new StackTrace(true).GetFrame(0).GetFileLineNumber());
                Assert.AreEqual(true, false);
            }
        }
        public override object Execute(object parameter)
        {
            bool canSkipKnightRecruitment = _webDriverBaseMethodsService.ExistsByAndCondition(ExpectedConditions.ElementExists(By.ClassName("knight_recruit_rush")), _timeoutForChceckingElementsExistence);

            return(canSkipKnightRecruitment);
        }
Example #13
0
        public void OpenMenuByName(string menuName)
        {
            var menuContainer                = new WebDriverWait(driver, TimeSpan.FromSeconds(10)).Until(ExpectedConditions.ElementExists((By.CssSelector("#box-apps-menu"))));
            IList <IWebElement> menuLinks    = menuContainer.FindElements(By.CssSelector("#app- > a"));
            IWebElement         menuItemLink = driver.FindElement(By.LinkText(menuName));

            menuItemLink.Click();
        }
Example #14
0
        public bool ClickOnMenus()
        {
            var menuContainer             = new WebDriverWait(driver, TimeSpan.FromSeconds(10)).Until(ExpectedConditions.ElementExists((By.CssSelector("#box-apps-menu"))));
            IList <IWebElement> menuLinks = menuContainer.FindElements(By.CssSelector("#app- > a"));

            for (int i = 0; i < menuLinks.Count; i++)
            {
                menuContainer = new WebDriverWait(driver, TimeSpan.FromSeconds(10)).Until(ExpectedConditions.ElementExists((By.CssSelector("#box-apps-menu"))));
                menuLinks     = menuContainer.FindElements(By.CssSelector("#app- > a"));
                IWebElement menuItemLink = driver.FindElement(By.LinkText(menuLinks[i].Text));
                menuItemLink.Click();
                var selectedMenu = driver.FindElement(By.ClassName("selected"));
                IList <IWebElement> innerMenu = selectedMenu.FindElements(By.TagName("li"));

                for (int j = 0; j < innerMenu.Count; j++)
                {
                    selectedMenu = driver.FindElement(By.ClassName("docs"));
                    innerMenu    = selectedMenu.FindElements(By.TagName("li"));
                    IWebElement innerMenuItemLink = driver.FindElement(By.LinkText(innerMenu[j].Text));
                    innerMenuItemLink.Click();

                    if (!IsElementPresent(By.TagName("h1")))
                    {
                        return(false);
                    }
                }
                if (!IsElementPresent(By.TagName("h1")))
                {
                    return(false);
                }
            }
            return(true);
        }
Example #15
0
 public void SearchCaseFour(string from, string to, string numberOfPassangers, string departDate, string returnDate)
 {
     Pages.Home home = new Pages.Home(driver);
     home.OpenPage();
     home.SearchInManyPlace(from, to, numberOfPassangers, departDate, returnDate);
     foreach (var windowHandle in driver.WindowHandles)
     {
         if (windowHandle != driver.CurrentWindowHandle)
         {
             driver.SwitchTo().Window(windowHandle);
             IWebElement dynamicElement = (new WebDriverWait(driver, TimeSpan.Parse("60"))).Until(ExpectedConditions.ElementExists(By.Id("view-itinerary")));
             Assert.IsTrue(dynamicElement.Text.Contains("Hide"));
         }
     }
 }
Example #16
0
 public bool HasTicketsList(bool isMainPage)
 {
     foreach (var windowHandle in driver.WindowHandles)
     {
         if (isMainPage)
         {
             if (windowHandle != driver.CurrentWindowHandle)
             {
                 driver.SwitchTo().Window(windowHandle);
                 IWebElement dynamicElement = (new WebDriverWait(driver, TimeSpan.Parse("60"))).Until(ExpectedConditions.ElementExists(page.GetTicketsListContainer()));
                 return(page.GetTicketsListElement(dynamicElement).Count() > 0);
             }
         }
         if (!isMainPage)
         {
             IWebElement dynamicElement = (new WebDriverWait(driver, TimeSpan.Parse("60"))).Until(ExpectedConditions.ElementExists(page.GetTicketsListContainer()));
             return(page.GetTicketsListElement(dynamicElement).Count() > 0);
         }
     }
     return(false);
 }
Example #17
0
        public void ComplianceSmoke()

        {
            //Define a variable for the test script and description
            var ComplianceSmokeTestReport = TestReport.StartTest("Compliance Smoke Test", "This test will perform a high level smoke on Compliance Module");

            Driver.Url = "https://qa.fransupport.com/new/corporate/login.aspx";

            //One method of using a control
            Driver.FindElement(By.Id("txtUserName")).SendKeys("*****@*****.**");;

            //Second method of using a control
            IWebElement PasswordField = Driver.FindElement(By.Id("txtPassword"));

            PasswordField.SendKeys("admin1953");

            Driver.FindElement(By.Id("btnSignIn")).Click();

            //Handle if there are any communications present
            try

            {
                //Click Acknowledge button if exists
                Driver.FindElement(By.Id("btnAck")).Click();

                //Print that sign in step has passed
                ComplianceSmokeTestReport.Log(LogStatus.Pass, "Signed in Successfully");

                //Look if there are multiplt messages
                int MultipleMessages = Driver.FindElements(By.Id("btnAck")).Count();

                while (MultipleMessages > 0)
                {
                    Driver.FindElement(By.Id("btnAck")).Click();
                    MultipleMessages = Driver.FindElements(By.Id("btnAck")).Count();
                }

                //Print that communication(s) have been acknowledged.
                ComplianceSmokeTestReport.Log(LogStatus.Pass, "Communications Acknowledged");
                //select ncompass app
                Driver.FindElement(By.Id("liNcompass")).Click();
            }

            catch (Exception)

            {
                //select ncompass app
                Driver.FindElement(By.Id("liNcompass")).Click();

                //Print that sign in step has passed
                ComplianceSmokeTestReport.Log(LogStatus.Pass, "Signed in Successfully");
            }

            //select compliance module
            Driver.FindElement(By.Id("ctl00_leftPanel_liCompliance")).Click();
            System.Threading.Thread.Sleep(3000);

            //Acknowledge Location Alet popup
            try
            {
                //Wait untill the button appears
                WebDriverWait Wait = new WebDriverWait(Driver, new TimeSpan(0, 0, 10));
                Wait.Until(ExpectedConditions.ElementIsVisible(By.Id("btnacknowledge")));
                System.Threading.Thread.Sleep(2000);
                Driver.FindElement(By.Id("btnacknowledge")).Click();
                ComplianceSmokeTestReport.Log(LogStatus.Pass, "Location Alert Popup Acknowledged");
            }

            catch (Exception)
            {
                ComplianceSmokeTestReport.Log(LogStatus.Fail, "Location Alert Popup did not Appear");
            }


            //Click Add New Link in the center widgets
            System.Threading.Thread.Sleep(5000);
            Driver.FindElement(By.XPath("//*[@id='middle']/div[1]/div[2]/span/a[1]")).Click();

            try
            {
                //Wait for the Div to appear
                WebDriverWait WaitforWidgetDiv = new WebDriverWait(Driver, new TimeSpan(0, 0, 5));
                WaitforWidgetDiv.Until(ExpectedConditions.ElementIsVisible(By.ClassName("WidgetBackgound")));

                //Loop to Add All Widgets
                int RemainingWidgetCount = Driver.FindElements(By.XPath("//*[@id='dv-popup-content']/div[1]/div[1]/span/input")).Count();
                while (RemainingWidgetCount > 0)
                {
                    Driver.FindElement(By.XPath("//*[@id='dv-popup-content']/div[1]/div[1]/span/input")).Click();
                    WaitforWidgetDiv.Until(ExpectedConditions.ElementIsVisible(By.Id("divPopup_Alert")));
                    Driver.FindElement(By.Id("BtnCancel_Alert")).Click();
                    RemainingWidgetCount = Driver.FindElements(By.XPath("//*[@id='dv-popup-content']/div[1]/div[1]/span/input")).Count();
                }

                Driver.FindElement(By.Id("btnCancel")).Click();
                ComplianceSmokeTestReport.Log(LogStatus.Pass, "All Widgets Added Successfully");
            }

            catch (Exception)
            {
                Driver.FindElement(By.Id("btnCancel_InfoBox")).Click();
                ComplianceSmokeTestReport.Log(LogStatus.Info, "There was no widget to Add");
            }

            //Deleting the Widgets
            try
            {
                Driver.FindElement(By.XPath("//*[@id='middle']/div[1]/div[2]/span/a[2]")).Click();
                //Wait for the Div to appear
                WebDriverWait Wait = new WebDriverWait(Driver, new TimeSpan(0, 0, 5));
                Wait.Until(ExpectedConditions.ElementIsVisible(By.Id("EditRightPanelDiv")));

                //Loop to Delete All Widgets
                int RemainingWidgetCount = Driver.FindElements(By.XPath("//*[@id='EditRightPanelDiv']/div[1]/div[3]/img")).Count();

                while (RemainingWidgetCount > 0)
                {
                    Driver.FindElement(By.XPath("//*[@id='EditRightPanelDiv']/div[1]/div[3]/img")).Click();
                    RemainingWidgetCount = Driver.FindElements(By.XPath("//*[@id='EditRightPanelDiv']/div[1]/div[3]/img")).Count();
                }

                Driver.FindElement(By.Id("btnUpdateAll")).Click();
                ComplianceSmokeTestReport.Log(LogStatus.Pass, "All Widgets Deleted Successfully");
            }

            catch (Exception)
            { ComplianceSmokeTestReport.Log(LogStatus.Info, "There was no widget to Delete"); }

            System.Threading.Thread.Sleep(3000);
            Driver.FindElement(By.Id("liLocationListFranMgmt")).Click();
            Driver.FindElement(By.Id("ctl00_cntMain_txtSearch")).SendKeys(Keys.NumberPad5 + Keys.NumberPad5 + Keys.NumberPad5 + Keys.Enter);
            System.Threading.Thread.Sleep(7000);
            try
            {
                Driver.FindElement(By.Id("ctl00_cntMain_lstLocation_ctrl0_lbllocationname")).Click();

                System.Threading.Thread.Sleep(3000);
                Driver.FindElement(By.Id("spnEdit")).Click();

                IWebElement SaveButton = Driver.FindElement(By.XPath("//*[@id='form1']/div[5]/div[33]/div/input[1]"));
                Actions     Scroll     = new Actions(Driver);
                Scroll.MoveToElement(SaveButton).Build().Perform();
                SaveButton.Click();

                System.Threading.Thread.Sleep(3000);
                IWebElement Ownership = Driver.FindElement(By.LinkText("Ownership"));
                Scroll.MoveToElement(Ownership).Build().Perform();
                Ownership.Click();

                System.Threading.Thread.Sleep(2000);
                Driver.FindElement(By.LinkText("Lease")).Click();
                System.Threading.Thread.Sleep(2000);
                Driver.FindElement(By.LinkText("Managers")).Click();
                System.Threading.Thread.Sleep(2000);
                Driver.FindElement(By.LinkText("Pools")).Click();
                System.Threading.Thread.Sleep(2000);
                Driver.FindElement(By.LinkText("Vehicle Information")).Click();
                System.Threading.Thread.Sleep(2000);
                Driver.FindElement(By.LinkText("Flag/Alerts")).Click();
                System.Threading.Thread.Sleep(2000);
                Driver.FindElement(By.LinkText("Login Access")).Click();
                System.Threading.Thread.Sleep(2000);
                Driver.FindElement(By.LinkText("Financial Information")).Click();
                System.Threading.Thread.Sleep(2000);
                Driver.FindElement(By.LinkText("Notes")).Click();
                System.Threading.Thread.Sleep(2000);
                Driver.FindElement(By.LinkText("Photo Gallery")).Click();
                System.Threading.Thread.Sleep(2000);
                Driver.FindElement(By.LinkText("Documents")).Click();
                System.Threading.Thread.Sleep(3000);
                Driver.FindElement(By.LinkText("History Log")).Click();
                System.Threading.Thread.Sleep(2000);

                WebDriverWait WaitForDemographics = new WebDriverWait(Driver, new TimeSpan(0, 0, 10));
                WaitForDemographics.Until(ExpectedConditions.ElementExists(By.LinkText("Demographics")));
                IWebElement Demographics = Driver.FindElement(By.LinkText("Demographics"));
                Scroll.MoveToElement(Demographics).Build().Perform();
                Demographics.Click();

                ComplianceSmokeTestReport.Log(LogStatus.Pass, "All Location Info Links are Working");
            }

            catch (Exception)

            { ComplianceSmokeTestReport.Log(LogStatus.Fail, "Some Location Info Links were not Working"); }

            //Going to Reports Section
            System.Threading.Thread.Sleep(5000);
            Driver.FindElement(By.Id("liReportFranMgmt")).Click();

            try
            {
                System.Threading.Thread.Sleep(3000);
                IWebElement ExportToExcel = Driver.FindElement(By.Id("btnExcel"));
                System.Threading.Thread.Sleep(2000);
                WebDriverWait WaitForVisibility = new WebDriverWait(Driver, new TimeSpan(0, 0, 10));
                WaitForVisibility.Until(ExpectedConditions.ElementExists(By.Id("btnExcel")));
                Actions Scroll = new Actions(Driver);
                Scroll.MoveToElement(ExportToExcel).Build().Perform();
                ExportToExcel.Click();

                WaitForVisibility.Until(ExpectedConditions.ElementExists(By.LinkText("Location List by Status")));
                Driver.FindElement(By.LinkText("Location List by Status")).Click();
                System.Threading.Thread.Sleep(3000);
                WaitForVisibility.Until(ExpectedConditions.ElementExists(By.XPath("//*[@id='dvStoreListByStatus']/table/tbody/tr[3]/td[2]/input")));
                IWebElement ExportToExcelButton = Driver.FindElement(By.XPath("//*[@id='dvStoreListByStatus']/table/tbody/tr[3]/td[2]/input"));
                Scroll.MoveToElement(ExportToExcelButton).Build().Perform();
                ExportToExcelButton.Click();
                System.Threading.Thread.Sleep(2000);

                WaitForVisibility.Until(ExpectedConditions.ElementExists(By.LinkText("Owners Deleted")));
                Driver.FindElement(By.LinkText("Owners Deleted")).Click();
                System.Threading.Thread.Sleep(3000);
                WaitForVisibility.Until(ExpectedConditions.ElementExists(By.Id("btnExcel")));
                ExportToExcel = Driver.FindElement(By.Id("btnExcel"));
                Scroll.MoveToElement(ExportToExcel).Build().Perform();
                ExportToExcel.Click();
                System.Threading.Thread.Sleep(2000);

                WaitForVisibility.Until(ExpectedConditions.ElementExists(By.LinkText("Location Status History Report")));
                Driver.FindElement(By.LinkText("Location Status History Report")).Click();
                System.Threading.Thread.Sleep(3000);
                WaitForVisibility.Until(ExpectedConditions.ElementExists(By.Id("btnExcel")));
                ExportToExcel = Driver.FindElement(By.Id("btnExcel"));
                Scroll.MoveToElement(ExportToExcel).Build().Perform();
                ExportToExcel.Click();
                System.Threading.Thread.Sleep(2000);

                WaitForVisibility.Until(ExpectedConditions.ElementExists(By.LinkText("Transfer History Report")));
                Driver.FindElement(By.LinkText("Transfer History Report")).Click();
                System.Threading.Thread.Sleep(3000);
                WaitForVisibility.Until(ExpectedConditions.ElementExists(By.Id("btnExcel")));
                ExportToExcel = Driver.FindElement(By.Id("btnExcel"));
                Scroll.MoveToElement(ExportToExcel).Build().Perform();
                ExportToExcel.Click();
                System.Threading.Thread.Sleep(2000);

                WaitForVisibility.Until(ExpectedConditions.ElementExists(By.LinkText("Multi-Unit Enterprise Report")));
                Driver.FindElement(By.LinkText("Multi-Unit Enterprise Report")).Click();
                System.Threading.Thread.Sleep(3000);
                WaitForVisibility.Until(ExpectedConditions.ElementExists(By.Id("btnExcel")));
                ExportToExcel = Driver.FindElement(By.Id("btnExcel"));
                ExportToExcel.Click();
                System.Threading.Thread.Sleep(2000);

                WaitForVisibility.Until(ExpectedConditions.ElementExists(By.LinkText("Multi-Unit Enterprise Revenue Report")));
                Driver.FindElement(By.LinkText("Multi-Unit Enterprise Revenue Report")).Click();
                System.Threading.Thread.Sleep(3000);
                WaitForVisibility.Until(ExpectedConditions.ElementExists(By.Id("btnExcel")));
                ExportToExcel = Driver.FindElement(By.Id("btnExcel"));
                ExportToExcel.Click();
                System.Threading.Thread.Sleep(2000);

                WaitForVisibility.Until(ExpectedConditions.ElementExists(By.LinkText("Single-Unit Enterprise Report")));
                Driver.FindElement(By.LinkText("Single-Unit Enterprise Report")).Click();
                System.Threading.Thread.Sleep(3000);
                WaitForVisibility.Until(ExpectedConditions.ElementExists(By.Id("btnExcel")));
                ExportToExcel = Driver.FindElement(By.Id("btnExcel"));
                ExportToExcel.Click();
                System.Threading.Thread.Sleep(2000);

                WaitForVisibility.Until(ExpectedConditions.ElementExists(By.LinkText("Owner List By Religion")));
                Driver.FindElement(By.LinkText("Owner List By Religion")).Click();
                System.Threading.Thread.Sleep(3000);
                WaitForVisibility.Until(ExpectedConditions.ElementExists(By.Id("btnExcel")));
                ExportToExcel = Driver.FindElement(By.Id("btnExcel"));
                ExportToExcel.Click();
                System.Threading.Thread.Sleep(2000);

/*
 *                         WaitForVisibility.Until(ExpectedConditions.ElementExists(By.LinkText("Franchisee Areas Report")));
 *                         Driver.FindElement(By.LinkText("Franchisee Areas Report")).Click();
 *                         System.Threading.Thread.Sleep(3000);
 *                         WaitForVisibility.Until(ExpectedConditions.ElementExists(By.Id("btnPdf")));
 *                         IWebElement ExportToPDF = Driver.FindElement(By.Id("btnPdf"));
 *                         Scroll.MoveToElement(ExportToPDF).Build().Perform();
 *                         ExportToPDF.Click();
 *                         System.Threading.Thread.Sleep(2000);
 */
                WaitForVisibility.Until(ExpectedConditions.ElementExists(By.LinkText("Demographics")));
                Driver.FindElement(By.LinkText("Demographics")).Click();
                System.Threading.Thread.Sleep(3000);
                WaitForVisibility.Until(ExpectedConditions.ElementExists(By.Id("btnExcel")));
                ExportToExcel = Driver.FindElement(By.Id("btnExcel"));
                Scroll.MoveToElement(ExportToExcel).Build().Perform();
                ExportToExcel.Click();
                System.Threading.Thread.Sleep(2000);

                WaitForVisibility.Until(ExpectedConditions.ElementExists(By.LinkText("FDD Location List Report")));
                Driver.FindElement(By.LinkText("FDD Location List Report")).Click();
                System.Threading.Thread.Sleep(3000);
                WaitForVisibility.Until(ExpectedConditions.ElementExists(By.XPath("//*[@id='dvFDDStoreList']/table/tbody/tr[3]/td/input")));
                ExportToExcel = Driver.FindElement(By.XPath("//*[@id='dvFDDStoreList']/table/tbody/tr[3]/td/input"));
                ExportToExcel.Click();

                ComplianceSmokeTestReport.Log(LogStatus.Pass, "All Reports Generated Successfully");
            }

            catch (Exception)

            { ComplianceSmokeTestReport.Log(LogStatus.Fail, "Some Reports were not Generated"); }


            System.Threading.Thread.Sleep(2000);
            Driver.FindElement(By.Id("liFranmgmtZone")).Click();

            System.Threading.Thread.Sleep(2000);
            Driver.FindElement(By.Id("btnAddNew")).Click();

            System.Threading.Thread.Sleep(2000);
            Driver.FindElement(By.Id("ctl00_cntMain_spnBack")).Click();
            ComplianceSmokeTestReport.Log(LogStatus.Pass, "New Zone Button is Working");
            System.Threading.Thread.Sleep(2000);

            try
            {
                Driver.FindElement(By.XPath("//*[@id='ctl00_cntMain_pnlGroup']/table/tbody/tr[2]/td[3]/div/a[1]")).Click();
                System.Threading.Thread.Sleep(2000);
                Driver.FindElement(By.Id("ctl00_cntMain_spnBack")).Click();
                ComplianceSmokeTestReport.Log(LogStatus.Pass, "Zone Edit is Working");
            }
            catch (Exception)
            { ComplianceSmokeTestReport.Log(LogStatus.Info, "No Zones Exist"); }

            System.Threading.Thread.Sleep(2000);
            Driver.FindElement(By.Id("liTermAndCondition")).Click();

            System.Threading.Thread.Sleep(2000);
            Driver.FindElement(By.Id("ctl00_cntMain_dvEdit")).Click();

            System.Threading.Thread.Sleep(2000);
            Driver.FindElement(By.Id("Span1")).Click();
            ComplianceSmokeTestReport.Log(LogStatus.Pass, "Term and Conditions link working");
            System.Threading.Thread.Sleep(2000);

            try
            {
                Driver.FindElement(By.Id("ctl00_cntMain_dvEdit")).Click();
                System.Threading.Thread.Sleep(2000);

                Driver.FindElement(By.Id("ctl00_leftPanel_liEuEnrollments")).Click();
                System.Threading.Thread.Sleep(2000);

                Driver.FindElement(By.XPath("//*[@id='ctl00_cntMain_ddlSession']/option[4]")).Click();
                System.Threading.Thread.Sleep(2000);

                Driver.FindElement(By.XPath("//*[@id='ctl00_cntMain_ddlStatus']/option[3]")).Click();
                System.Threading.Thread.Sleep(2000);

                Driver.FindElement(By.XPath("//*[@id='ctl00_cntMain_pnlGroup']/div[1]/div[2]/div/span[4]/input")).Click();
                System.Threading.Thread.Sleep(2000);

                Driver.FindElement(By.Id("spnEnrollmentSessions")).Click();
                System.Threading.Thread.Sleep(2000);

                Driver.FindElement(By.Id("spnArchived")).Click();
                ComplianceSmokeTestReport.Log(LogStatus.Pass, "EU Enrollment Links are Working");
                System.Threading.Thread.Sleep(2000);
            }

            catch
            { ComplianceSmokeTestReport.Log(LogStatus.Pass, "Non-EA Clients do not have EU Enrollment"); }

            try
            { Driver.FindElement(By.Id("ctl00_leftPanel_liSemEnrollments")).Click();
              ComplianceSmokeTestReport.Log(LogStatus.Pass, "SEM Links Verified"); }
            catch (Exception)
            { ComplianceSmokeTestReport.Log(LogStatus.Info, "Non-EA Clients do not have SEM"); }

            System.Threading.Thread.Sleep(2000);
            Driver.FindElement(By.Id("liMoreFranMgmt")).Click();
            System.Threading.Thread.Sleep(2000);

            Driver.FindElement(By.Id("spnCompanies")).Click();
            System.Threading.Thread.Sleep(2000);

            Driver.FindElement(By.Id("spnMaster")).Click();
            System.Threading.Thread.Sleep(2000);

            Driver.FindElement(By.Id("spnBS")).Click();
            System.Threading.Thread.Sleep(2000);

            Driver.FindElement(By.Id("spnEO")).Click();
            System.Threading.Thread.Sleep(2000);

            Driver.FindElement(By.Id("spnRB")).Click();
            System.Threading.Thread.Sleep(2000);

            Driver.FindElement(By.Id("spnTemplates")).Click();
            System.Threading.Thread.Sleep(2000);

            Driver.FindElement(By.Id("ctl00_leftPanel_liCompliance")).Click();
            System.Threading.Thread.Sleep(2000);

            ComplianceSmokeTestReport.Log(LogStatus.Pass, "Test Case Passed");
            TestReport.EndTest(ComplianceSmokeTestReport);
        }
Example #18
0
        private void ArmarEstado(List <string> opcions, IWebDriver web)
        {
            Excel.Application miExcel = new Excel.Application();
            miExcel.DisplayAlerts = false;
            miExcel.Visible       = true;
            Excel.Workbook  libro = miExcel.Workbooks.Add();
            Excel.Worksheet hojaExcel;
            foreach (string item in opcions)
            {
                libro.Worksheets.Add();
                ((Excel.Worksheet)miExcel.Sheets[1]).Select();
                hojaExcel = (Excel.Worksheet)libro.ActiveSheet;
                hojaExcel.Columns.EntireColumn.NumberFormat = "@";
                hojaExcel.Cells["1", "A"] = "CIA";
                hojaExcel.Cells["1", "B"] = "Id Mov";
                hojaExcel.Cells["1", "C"] = "Tienda";
                hojaExcel.Cells["1", "D"] = "Depto";
                hojaExcel.Cells["1", "E"] = "Folio";
                hojaExcel.Cells["1", "F"] = "Factura";
                hojaExcel.Cells["1", "G"] = "F. Recibo";
                hojaExcel.Cells["1", "H"] = "F. Vencimiento";
                hojaExcel.Cells["1", "I"] = "Importe";
                hojaExcel.Cells["1", "J"] = "Estatus";
                hojaExcel.Cells["1", "K"] = "Orden Compra";
                new SelectElement(web.FindElement(By.Id("ddlDepVend"))).SelectByValue(item);
                WebDriverWait wait    = new WebDriverWait(web, TimeSpan.FromSeconds(10));
                IWebElement   element = wait.Until(ExpectedConditions.ElementExists(By.Id("btnSearch")));
                element.Click();
                wait = new WebDriverWait(web, TimeSpan.FromSeconds(10));
                wait.Until(ExpectedConditions.ElementExists(By.Id("tb_grid")));
                Thread.Sleep(1500);
                element = web.FindElement(By.Id("tb_grid"));
                string   texto          = "";
                char[]   delimiterChars = { '\r', '\n' };
                string[] lineas         = new string[100];
                texto  = element.GetAttribute("innerHTML");
                lineas = texto.Split(delimiterChars);
                texto  = texto.Replace("\r", "♥");
                texto  = texto.Replace("\t", "♦");
                texto  = texto.Replace("</tr><tr class=\"celdaCont\" align=\"right\">", "");
                texto  = texto.Replace("</tr><tr align=\"right\">", "");
                texto  = texto.Replace("<td>", "♠");
                texto  = texto.Replace("</td>", "•");
                texto  = texto.Replace("</tr><tr align=\"right\" class=\"celdatot\">", "");
                texto  = texto.Replace("<td colspan=\"8\">", "");
                texto  = texto.Replace("</tr>", "");
                texto  = texto.Replace("</tbody>", "");
                texto  = texto.Replace("<tr class=\"celdatot\" align=\"right\">", "");
                texto  = texto.Replace("<tbody><tr id=\"row\" align=\"center\" valign=\"middle\" style=\"color:White;background-color:Navy;font-weight:bold;\">", "");
                texto  = texto.Replace("<td id=\"CIA\" key=\"lb_cia_tc\" name=\"Tablecell01\">", "");
                texto  = texto.Replace("<td id=\"MovId\" key=\"lb_mov_tc\" name=\"Tablecell02\">", "");
                texto  = texto.Replace("<td id=\"Shop\" key=\"lb_tienda_tc\" name=\"Tablecell03\">", "");
                texto  = texto.Replace("<td id=\"Dept\" key=\"lb_depto_tc\" name=\"Tablecell04\">", "");
                texto  = texto.Replace("<td id=\"Folio\" key=\"lb_folio_tc\" name=\"Tablecell05\">", "");
                texto  = texto.Replace("<td id=\"Bill\" key=\"lb_factura_tc\" name=\"Tablecell06\">", "");
                texto  = texto.Replace("<td id=\"ReceiptDate\" key=\"lb_fecharec_tc\" name=\"Tablecell07\">", "");
                texto  = texto.Replace("<td id=\"ExpirationDate\" key=\"lb_fechaven_tc\" name=\"Tablecell08\">", "");
                texto  = texto.Replace("<td id=\"Amount\" key=\"lb_importe_tc\" name=\"Tablecell09\">", "");
                texto  = texto.Replace("<td id=\"Status\" key=\"lb_estatus_tc\" name=\"Tablecell12\">", "");
                texto  = texto.Replace("<td id=\"PurchaseOrder\" key=\"lb_ordencpa_tc\" name=\"Tablecell13\">", "");
                texto  = texto.Replace("♦CIA•Id Mov•Tienda•Depto•Folio•Factura•Fecha Recibo•Fecha Vencimiento•Importe•Estatus•Orden Compra•", "");
                texto  = texto.Replace("♥\n♦♦♥\n", "");
                texto  = texto.Replace("•♦♦♦♠", Environment.NewLine);
                texto  = texto.Replace("•♠", "\t");
                texto  = texto.Replace("♦♦♦♦♦♠", "");
                texto  = texto.Replace("•♦♦♦", Environment.NewLine);
                texto  = texto.Replace("••♦", "");
                Clipboard.Clear();
                Clipboard.SetText(texto);
                Thread.Sleep(1000);
                hojaExcel.Cells[2, 1].PasteSpecial();
                hojaExcel.Cells[1].EntireRow.Font.Color     = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.White);
                hojaExcel.Cells[1].EntireRow.Interior.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.DarkBlue);
                hojaExcel.Cells[1].EntireRow.Font.Bold      = true;
                hojaExcel.Name = item;
                hojaExcel.Columns.EntireColumn.AutoFit();
            }

            for (int i = 1; i <= libro.Worksheets.Count; i++)
            {
                if (libro.Worksheets[i].name.Contains("Hoja"))
                {
                    libro.Worksheets[i].Delete();
                    i = 0;
                }
            }

            String rutaEscritorio = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);

            if (!Directory.Exists(rutaEscritorio + @"\Archivos Generados\"))
            {
                Directory.CreateDirectory(rutaEscritorio + @"\Archivos Generados\");
            }
            string nombre = "Walmart Estado de Cuenta " + nombreAleatorio() + ".xlsx";

            libro.SaveAs(rutaEscritorio + @"\Archivos Generados\" + nombre);
        }
Example #19
0
        public void WhenIPressAdd()
        {
            var input = _wait.Until(ExpectedConditions.ElementExists(By.Id("submit")));

            input.Click();
        }
Example #20
0
        public static IWebElement WaitForElementToAppear(IWebDriver driver, int waitTime, By waitingElement)
        {
            IWebElement wait = new WebDriverWait(driver, TimeSpan.FromSeconds(waitTime)).Until(ExpectedConditions.ElementExists(waitingElement));

            return(wait);
        }
Example #21
0
        internal void WaitForAppear(By by)
        {
            WebDriverWait wait = new WebDriverWait(_driver, TimeSpan.FromSeconds(10));

            wait.Until(ExpectedConditions.ElementExists(by));
        }
Example #22
0
 public void WaitUntilNextBtnIsVisible()
 {
     var wait = new WebDriverWait(_driver, TimeSpan.FromSeconds(timeToWait)).Until(ExpectedConditions.ElementExists(By.XPath(_nextBtn)));
 }
 public IWebElement Title()
 {
     return(explicitWait.Until(ExpectedConditions.ElementExists(title)));
 }
Example #24
0
 public void WaitUntilCountryPlaceholderIsVisible()
 {
     var wait = new WebDriverWait(_driver, TimeSpan.FromSeconds(timeToWait)).Until(ExpectedConditions.ElementExists(By.XPath(_countryPlaceholder)));
 }
 public IWebElement AcceptTillDate()
 {
     return(explicitWait.Until(ExpectedConditions.ElementExists(acceptTillDate)));
 }
Example #26
0
        public void ProductsPrices()
        {
            driver.Url = "http://localhost/litecart/en/";
            wait.Until(ExpectedConditions.ElementExists(By.CssSelector("div#logotype-wrapper")));

            //for Product Name
            IWebElement firstProduct     = driver.FindElement(By.XPath(".//*[@id='box-campaigns']//ul/li[1]"));
            IWebElement firstProductName = firstProduct.FindElement(By.CssSelector("div.name"));
            string      productName      = firstProductName.GetAttribute("textContent");

            //for Product Old Grey Price
            IWebElement productPriceOld     = firstProduct.FindElement(By.CssSelector("s.regular-price"));
            string      productPriceOldText = productPriceOld.GetAttribute("textContent");
            string      productPriceOldCl   = productPriceOld.GetAttribute("class");
            string      productPriceOldCol  = productPriceOld.GetCssValue("color");
            string      productPriceOldDec  = productPriceOld.GetCssValue("text-decoration-line");
            string      productPriceOldS    = productPriceOld.GetAttribute("tagName");
            string      productPriceOldSA   = "S";
            string      productPriceOldSz   = productPriceOld.GetCssValue("font-size");

            //for Product Auction Red Price
            IWebElement productPriceNew     = firstProduct.FindElement(By.CssSelector("strong.campaign-price"));
            string      productPriceNewText = productPriceNew.GetAttribute("textContent");
            string      productPriceNewCl   = productPriceNew.GetAttribute("class");
            string      productPriceNewCol  = productPriceNew.GetCssValue("color");
            string      productPriceNewDec  = productPriceNew.GetAttribute("tagName");
            string      productPriceNewSA   = "STRONG";
            string      productPriceNewSz   = productPriceNew.GetCssValue("font-size");

            //Click on Product Name -> Page with details
            firstProductName.Click();
            wait.Until(ExpectedConditions.ElementExists(By.CssSelector("div#box-product h1")));

            //Duplicate options into
            IWebElement boxForProduct        = driver.FindElement(By.CssSelector("div#box-product"));
            IWebElement firstProductNameInto = driver.FindElement(By.CssSelector("div#box-product h1"));
            string      firstProductNameIn   = firstProductNameInto.GetAttribute("textContent");

            //for Product Old Grey Price into
            IWebElement productPriceOldIn =
                boxForProduct.FindElement(By.CssSelector("s.regular-price"));
            string productPriceOldTextIn = productPriceOldIn.GetAttribute("textContent");
            string productPriceOldClIn   = productPriceOldIn.GetAttribute("class");
            string productPriceOldColIn  = productPriceOldIn.GetCssValue("color");
            string productPriceOldDecIn  = productPriceOldIn.GetCssValue("text-decoration-line");
            string productPriceOldSIn    = productPriceOldIn.GetAttribute("tagName");
            string productPriceOldSAIn   = "S";
            string productPriceOldSzIn   = productPriceOldIn.GetCssValue("font-size");

            //for Product Auction Red Price into
            IWebElement productPriceNewIn =
                boxForProduct.FindElement(By.CssSelector("strong.campaign-price"));
            string productPriceNewTextIn = productPriceNewIn.GetAttribute("textContent");
            string productPriceNewClIn   = productPriceNewIn.GetAttribute("class");
            string productPriceNewColIn  = productPriceNewIn.GetCssValue("color");
            string productPriceNewDecIn  = productPriceNewIn.GetAttribute("tagName");
            string productPriceNewSAIn   = "STRONG";
            string productPriceNewSzIn   = productPriceNewIn.GetCssValue("font-size");

            //Color
            string colorAss = "0";

            //Assertions
            Assert.AreEqual(productName, firstProductNameIn);

            //Old price
            Assert.AreEqual(productPriceOldText, productPriceOldTextIn);
            Assert.AreEqual(productPriceOldCl, productPriceOldClIn);
            Assert.AreEqual(productPriceOldDec, productPriceOldDecIn);
            Assert.AreEqual(productPriceOldS, productPriceOldSA);
            Assert.AreEqual(productPriceOldSIn, productPriceOldSAIn);
            Assert.NotNull(productPriceOldCol);
            Assert.NotNull(productPriceOldColIn);
            Assert.AreEqual(productPriceOldCol.Substring(5, 3),
                            productPriceOldCol.Substring(10, 3), productPriceOldCol.Substring(15, 3));
            Assert.AreEqual(productPriceOldColIn.Substring(5, 3),
                            productPriceOldColIn.Substring(10, 3), productPriceOldColIn.Substring(15, 3));

            //New price
            Assert.AreEqual(productPriceNewText, productPriceNewTextIn);
            Assert.AreEqual(productPriceNewCl, productPriceNewClIn);
            Assert.AreEqual(productPriceNewCol, productPriceNewColIn);
            Assert.AreEqual(productPriceNewDec, productPriceNewSA);
            Assert.AreEqual(productPriceNewDecIn, productPriceNewSAIn);
            Assert.NotNull(productPriceNewCol);
            Assert.NotNull(productPriceNewColIn);
            Assert.AreEqual(productPriceNewCol.Substring(10, 1),
                            productPriceNewCol.Substring(13, 1), colorAss);
            Assert.AreEqual(productPriceNewColIn.Substring(10, 1),
                            productPriceNewColIn.Substring(13, 1), colorAss);

            //Size of Prices
            Assert.Greater(productPriceNewSz, productPriceOldSz);
            Assert.Greater(productPriceNewSzIn, productPriceOldSzIn);
        }
        public static void WaitToBecomeAvailable(this By locator, IWebDriver driver)
        {
            var wait = CreateWait(driver);

            wait.Until(ExpectedConditions.ElementExists(locator));
        }
Example #28
0
 public void SearchCaseTwo(string from, string to, string numberOfPassangers, string departDate, string returnDate)
 {
     Pages.Home home = new Pages.Home(driver);
     home.OpenPage();
     home.SearchInManyPlace(from, to, numberOfPassangers, departDate, returnDate);
     foreach (var windowHandle in driver.WindowHandles)
     {
         if (windowHandle != driver.CurrentWindowHandle)
         {
             driver.SwitchTo().Window(windowHandle);
             IWebElement dynamicElement = (new WebDriverWait(driver, TimeSpan.Parse("60"))).Until(ExpectedConditions.ElementExists(By.XPath("//H3[@small=''][text()='Oops!  Something went wrong!']")));
             Assert.IsTrue(dynamicElement.Text.Contains("Oops! Something went wrong!"));
         }
     }
 }
Example #29
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="gridDivId"></param>
        /// <param name="driver"></param>
        /// <returns></returns>
        public static List <string> BuildTable(string gridDivId, IWebDriver driver)
        {
            // Thread.Sleep(2000);
            var waitForTable = (new WebDriverWait(driver, TimeSpan.FromSeconds(20))).Until(ExpectedConditions.ElementExists(By.Id(gridDivId)));

            return(waitForTable.FindElements(By.XPath(string.Format("//div[@id='{0}']//table/tbody/tr/th", gridDivId))).Select(x => x.Text).ToList());
        }
Example #30
0
        public void Zad12_AddNewProductInAdmin()
        {
            this.LoginInAdminPanel();
            driver.Navigate().GoToUrl($"{AdminLiteCartUrl}/?app=catalog&doc=catalog");
            var UniqNumber = GiveUniqNum();
            var UniqName   = "Another Duck №" + UniqNumber;
            var AddProduct = driver.FindElement(By.XPath(".//a[@class='button' and contains(text(),'Add New Product')]"));

            AddProduct.Click();
            new WebDriverWait(driver, TimeSpan.FromSeconds(15)).Until(
                ExpectedConditions.ElementExists(By.XPath(".//div[@class='tabs']")));

            //general
            var status             = driver.FindElement(By.XPath(".//input[@name='status' and @value='1']"));
            var name               = driver.FindElement(By.XPath(".//strong[text()='Name']/..//input"));
            var Code               = driver.FindElement(By.XPath(".//strong[text()='Code']/..//input"));
            var Category           = driver.FindElement(By.XPath(".//strong[text()='Categories']/..//input[@data-name='Root']"));
            var ProductGroupUnisex = driver.FindElement(By.XPath(".//strong[text()='Product Groups']/..//td[text()='Unisex']/..//input"));
            var Quantity           = driver.FindElement(By.XPath(".//input[@name='quantity']"));
            var UploadImage        = driver.FindElement(By.XPath(".//strong[text()='Upload Images']/..//input"));
            var DateValidFrom      = driver.FindElement(By.XPath(".//strong[text()='Date Valid From']/..//input"));
            var DateValidTo        = driver.FindElement(By.XPath(".//strong[text()='Date Valid To']/..//input"));

            if (!status.Selected)
            {
                status.Click();
            }
            name.SendKeys(UniqName);
            Code.SendKeys(UniqNumber);
            if (!Category.Selected)
            {
                Category.Click();
            }
            if (!ProductGroupUnisex.Selected)
            {
                ProductGroupUnisex.Click();
            }
            Quantity.Clear();
            Quantity.SendKeys("10");
            string path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Penguins.jpg");

            UploadImage.SendKeys(path);
            DateValidFrom.SendKeys("01.12.2017");
            DateValidTo.SendKeys("01.02.2018");

            //information
            var InfoTab = driver.FindElement(By.XPath(".//div[@class='tabs']//li//a[text()='Information']"));

            InfoTab.Click();
            new WebDriverWait(driver, TimeSpan.FromSeconds(15)).Until(
                ExpectedConditions.ElementExists(By.XPath(".//div[@id='tab-information' and @style='display: block;']")));
            var Manufacturer     = driver.FindElement(By.XPath(".//select[@name='manufacturer_id']"));
            var Keywords         = driver.FindElement(By.XPath(".//input[@name='keywords']"));
            var ShortDescription = driver.FindElement(By.XPath(".//input[@name='short_description[en]']"));
            var Description      = driver.FindElement(By.XPath(".//textarea[@name='description[en]']"));
            var HeadTitle        = driver.FindElement(By.XPath(".//input[@name='head_title[en]']"));

            var selectManufacturer = new SelectElement(Manufacturer);

            selectManufacturer.SelectByValue("1");
            Keywords.SendKeys("Red;Duck");
            ShortDescription.SendKeys("Another Red Duck");
            Description.SendKeys("Another Red Duck with 10$ price! BUY NOW!");
            HeadTitle.SendKeys("Red Duck");

            //price
            var PriceTab = driver.FindElement(By.XPath(".//div[@class='tabs']//li//a[text()='Prices']"));

            PriceTab.Click();
            new WebDriverWait(driver, TimeSpan.FromSeconds(15)).Until(
                ExpectedConditions.ElementExists(By.XPath(".//div[@id='tab-prices' and @style='display: block;']")));
            var Price      = driver.FindElement(By.XPath(".//input[@name='purchase_price']"));
            var Money      = driver.FindElement(By.XPath(".//select[@name='purchase_price_currency_code']"));
            var SaveButton = driver.FindElement(By.XPath(".//button[@name='save']"));

            Price.Clear();
            Price.SendKeys("10");
            var SelectMoney = new SelectElement(Money);

            SelectMoney.SelectByValue("USD");

            SaveButton.Click();

            new WebDriverWait(driver, TimeSpan.FromSeconds(15)).Until(
                ExpectedConditions.ElementExists(By.XPath(".//table[@class='dataTable']")));
            var H1elemennt = driver.FindElement(By.XPath(".//h1"));

            Assert.IsTrue(H1elemennt.Text == "Catalog");
            var CreatedProduct = driver.FindElements(By.XPath(".//table[@class='dataTable']//tr[@class='row']//a[text()='" + UniqName + "']"));

            Assert.IsTrue(CreatedProduct.Count > 0);
        }