예제 #1
0
        public DashboardPage SelectDataInterval(string value)
        {
            string xpath = "//span[@aria-haspopup='listbox' and starts-with(@class,'k-widget k-dropdown k-header')]";

            string xpathSelect = $"//div[@class='telerik-blazor k-animation-container ']/child::div[@class='k-popup k-reset']" +
                                 $"/child::div[@class='k-list-scroller']/child::ul[@class='k-list k-reset']/child::li[contains(.,'{value}')]";

            ControlFactory.GetControl <ButtonElement>(Locator.XPath, xpath,
                                                      "Data Interval").Click();

            string attribute = ControlFactory.GetControl <SpanElement>(Locator.XPath, xpath,
                                                                       "Data Interval", PostAction.Sleep).GetAttribute("aria-expanded");

            bool expanded = false;
            int  count    = 0;

            while (!expanded || count == 5)
            {
                if (attribute.ToLower().Trim().Equals("false"))
                {
                    ControlFactory.GetControl <ButtonElement>(Locator.XPath, xpath,
                                                              "Data Interval").Click();

                    attribute = ControlFactory.GetControl <SpanElement>(Locator.XPath, xpath,
                                                                        "Data Interval", PostAction.Sleep).GetAttribute("aria-expanded");
                }
                else
                {
                    expanded = true;
                }
                try
                {
                    SeleniumActions.GetWaitDriver.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementToBeClickable(By.XPath(xpathSelect)));
                }
                catch (Exception)
                {
                    //pending Loger
                }

                count++;
            }

            try
            {
                SeleniumActions.GetWaitDriver.
                Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementToBeClickable(By.XPath(xpathSelect)));
            }
            catch (Exception)
            {
                //pending Loger
            }

            ControlFactory.GetControl <SpanElement>(Locator.XPath, xpathSelect, value, PostAction.Sleep).Click();
            SeleniumActions.WaitForPageToLoad();
            return(this);
        }
예제 #2
0
        public void RegisterRegistesNewUser()
        {
            SeleniumActions.RegisterUser(UserS.PeshoUsername, UserS.PeshoEmail,
                                         UserS.PeshoPassword, this.Browser, this.RootUri);

            var user = this.Context.Users.Single();

            user.UserName.Should().Be(UserS.PeshoUsername);
            user.Email.Should().Be(UserS.PeshoEmail);
        }
예제 #3
0
        public MyProfilePage IsAccountDisplayed()
        {
            SeleniumActions.WaitForPageToLoad();
            string xpath = "//span[@class='small text-uppercase text-muted d-block' and text()='Account']";

            SeleniumActions.GetWaitDriver.
            Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementToBeClickable(By.XPath(xpath)));
            ControlFactory.GetControl <SpanElement>(Locator.XPath, xpath, "Account").IsDisplayed();
            return(this);
        }
예제 #4
0
        public IssuesPage IsTableTitleDisplayed()
        {
            SeleniumActions.WaitForPageToLoad();

            string xpath = "k-indicator-container";

            SeleniumActions.GetWaitDriver.
            Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementToBeClickable(By.ClassName(xpath)));
            ControlFactory.GetControl <SpanElement>(Locator.ClassName, xpath, "Table Title").IsDisplayed();
            return(this);
        }
예제 #5
0
        public LoginPage IsLoginPage()
        {
            SeleniumActions.WaitForPageToLoad();

            string xpath = "//div[@class='signin-form p-5']/child::h1[@id='app-title' and text()='ISSUES']";

            SeleniumActions.GetWaitDriver.
            Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementToBeClickable(By.XPath(xpath)));
            ControlFactory.GetControl <SpanElement>(Locator.XPath, xpath, "ISSUES").IsDisplayed();
            return(this);
        }
예제 #6
0
        /// <summary>
        /// The method helps to take an screen shot when a step in the test cases failed
        /// </summary>
        public static void TakeScreenshot()
        {
            //Path to save the image
            var imagePath     = Path.Combine(ConfigurationVariable.TestCaseResultsImageVideoPath, Util.GetCurrectTc());
            var fullImagePath = Path.Combine(imagePath,
                                             Util.GetCurrectTc() +
                                             DateTime.Now.Ticks.ToString(CultureInfo.InvariantCulture) + ".png");

            ConfigurationVariable.ScreenPath = fullImagePath;
            //Capture Desktop Image
            SeleniumActions.TakeScreenshotAllScreen(fullImagePath);
        }
예제 #7
0
        public FromDeleteAccuntPopupTo ClickDeleteAccount()
        {
            string className = "//div[@class='k-dialog-wrapper']/child::div[@class='k-widget k-window k-window-wrapper telerik-blazor k-centered  ' " +
                               "and @aria-modal='true']" +
                               "/child::div[@class='k-content k-window-content k-dialog-content']" +
                               "/descendant::button[text()='Delete Account']";

            ControlFactory.GetControl <ButtonElement>(Locator.XPath, className, "Delete Account").Click();

            SeleniumActions.SwitchToDefaultContent();

            return(new FromDeleteAccuntPopupTo());
        }
        public void IncidentFlow()
        {
            // *********** Launch Browser *******************
            SeleniumActions.InitializeWebDriver();
            Assert.AreEqual(TestData.LoginPageTestData.HomePageTitle, SeleniumActions.getBrowserTitle(), "Title is NOT matched ");
            // *********** Switch to Frame  ******************
            st.Start();
            SeleniumActions.switchToFrame(PageObjects.LoginPage.frmNavFrame);
            // *********** Perform Login  ******************
            SeleniumActions.waitForElement(PageObjects.LoginPage.txtUserNameby);
            SeleniumActions.sendText(PageObjects.LoginPage.txtUserName, TestData.LoginPageTestData.UserName);
            SeleniumActions.sendText(PageObjects.LoginPage.txtPassword, TestData.LoginPageTestData.Password);
            SeleniumActions.waitClick(PageObjects.LoginPage.btnLogin);
            // ********* click on  Incidents  Page ***********************
            SeleniumActions.switchToDefaultFrame();
            SeleniumActions.switchToFrame(PageObjects.HomePage.frmNavFrame);
            SeleniumActions.waitForElement(PageObjects.HomePage.lnkUserInterface);
            SeleniumActions.switchToDefaultFrame();
            SeleniumActions.waitForElement(PageObjects.HomePage.lnkIncidentsBy);
            st.Stop();
            Trace.WriteLine($"took {st.ElapsedMilliseconds / 1000} seconds to launch browseload home page");
            SeleniumActions.waitClick(PageObjects.HomePage.lnkIncidents);
            SeleniumActions.switchToFrame(PageObjects.HomePage.frmNavFrame);
            SeleniumActions.waitClick(PageObjects.HomePage.btnNew);
            string dynatxt = SeleniumActions.getText(PageObjects.HomePage.txtIncNum);

            Trace.WriteLine("Dyna text:" + dynatxt);
            SeleniumActions.sendText(PageObjects.HomePage.txtShortDescription, TestData.HomePageTestData.IncidetnShotdesc);
            SeleniumActions.sendText(PageObjects.HomePage.txtLongDescription, TestData.HomePageTestData.IncidetnLongdesc);
            SeleniumActions.waitClick(PageObjects.HomePage.btnSubmit);
            PageObjects.HomePage.Dynatext = dynatxt;
            SeleniumActions.waitClick(PageObjects.HomePage.btnDynamicLinktext);
            SeleniumActions.selectDropdownValue(PageObjects.HomePage.ddIncState, TestData.HomePageTestData.IncidetnState);
            SeleniumActions.waitClick(PageObjects.HomePage.btnupdate);

            SeleniumActions.waitClick(PageObjects.HomePage.btnDynamicLinktext);
            Assert.AreEqual(TestData.HomePageTestData.IncidetnState, SeleniumActions.getDropdowntext(PageObjects.HomePage.ddIncState), "Incident state was mismathced");
            SeleniumActions.waitClick(PageObjects.HomePage.btndelete);
            SeleniumActions.takeScreenshot("IncidentEdit");
            SeleniumActions.waitForElement(PageObjects.HomePage.btndeleteConfirmOKBy);
            SeleniumActions.waitClick(PageObjects.HomePage.btndeleteConfirmOK);
            SeleniumActions.waitFirElemToInvisible(PageObjects.HomePage.btndeleteConfirmOKBy);

            SeleniumActions.switchToDefaultFrame();
            SeleniumActions.waitClick(PageObjects.HomePage.spnsysadmin);
            SeleniumActions.waitClick(PageObjects.HomePage.lnklogout);
            // *********** Dispose  ******************
            SeleniumActions.disposeDriver();
        }
예제 #9
0
        public void RegisterCreatesSettingsAndRootDirectoryeForRegisteredUser()
        {
            SeleniumActions.RegisterUser(UserS.PeshoUsername, UserS.PeshoEmail,
                                         UserS.PeshoPassword, this.Browser, this.RootUri);

            var user = this.Context.Users.Single();

            var settings = this.Context.UsersSettings.Single();

            settings.UserId.Should().Be(user.Id);

            var rootDirectory = this.Context.Directories.Single();

            rootDirectory.UserId.Should().Be(user.Id);
        }
예제 #10
0
        public DashboardPage ValidateDataInterval(string value)
        {
            string xpath = "//span[@aria-haspopup='listbox' and starts-with(@class,'k-widget k-dropdown k-header')]";

            string attribute = ControlFactory.GetControl <SpanElement>(Locator.XPath, xpath,
                                                                       "Data Interval", PostAction.Sleep).GetAttribute("aria-describedby");

            try
            {
                SeleniumActions.GetWaitDriver
                .Until(SeleniumExtras.WaitHelpers.ExpectedConditions.
                       TextToBePresentInElement(SeleniumActions.GetElement(By.Id(attribute)), value));
            }
            catch (Exception)
            {
                //pending Loger
            }

            ControlFactory.GetControl <SpanElement>(Locator.Id, attribute, "Data Interval").ValidateSpan(value);
            return(this);
        }
예제 #11
0
        public void edgeflow()
        {
            SeleniumActions.InitializeWebDriver();
            Assert.AreEqual("EDGE File Dialog test with selenium", SeleniumActions.getBrowserTitle(), "Title is NOT matched ");

            Thread.Sleep(1000);
            //UIAutomation.WinSendText("Open", "File name:", );
            //UIAutomation.WinClickButton("Open", "Open","");
            //System.Windows.Forms.SendKeys.SendWait(@"E:\log1.txt");
            //System.Windows.Forms.SendKeys.SendWait("{Enter}");
            //  SeleniumActions.waitClick(PageObjects.LocalEdgeTest.btnModelFile);
            string txtbeforeuplaod = SeleniumActions.getInnerText(PageObjects.LocalEdgeTest.pconfm);

            Thread.Sleep(1000);
            Assert.AreEqual("Select one or more files.", txtbeforeuplaod, "Before upload mismatch");

            SeleniumActions.UploadFile(PageObjects.LocalEdgeTest.fileControl, @"E:\log1.txt");
            string txtafgteruplaod = SeleniumActions.getInnerText(PageObjects.LocalEdgeTest.pconfm);

            StringAssert.Contains(txtafgteruplaod, "name: log1.txt", "After upload mismatch");
            // *********** Switch to Frame  ******************
        }
예제 #12
0
 public BasicSteps(ScenarioContext scenarioContext, SeleniumActions seleniumActions, WebDriverBuilder webDriverBuilder)
 {
     _scenarioContext  = scenarioContext;
     _seleniumActions  = seleniumActions;
     _webDriverBuilder = webDriverBuilder;
 }
예제 #13
0
 public HomePage(WebDriverBuilder webDriverBuilder, SeleniumActions seleniumActions) : base(webDriverBuilder, seleniumActions)
 {
 }
예제 #14
0
 public RegisterPage(IWebDriver webdriver)
 {
     driver          = webdriver;
     seleniumactions = new SeleniumActions(driver);
 }
예제 #15
0
        static void Main(string[] args)
        {
            Config.DIR     = args[0];
            Config.Browser = args[1];
            Config.Delim   = args[2];
            Config.Time    = Convert.ToInt32(args[3]);
            Config.GUIurl  = args[4];
            Config.BaseUrl = args[5];
            Config.LogFile = args[6];

            //SendKeys.Send("{ESC}");

            GlobalContext.Properties["LogName"] = Config.LogFile;
            ILog log = LogManager.GetLogger(typeof(Program));

            log.Info("Initialising........");
            var csvFiles = Directory.EnumerateFiles(Config.DIR, "*.csv", SearchOption.AllDirectories);
            int filect   = 0;

            foreach (string CSV in csvFiles)
            {
                filect++;
                log.Info(filect + ". " + CSV);
            }

            foreach (string currentFile in csvFiles)
            {
                //RunTesting Testlines = new RunTesting();
                log.Info("Processing file : " + currentFile);

                string[] TestSteps;

                using (StreamReader sr = new StreamReader(currentFile))
                {
                    string TestFile = sr.ReadToEnd();
                    TestSteps = TestFile.Split(new string[] { Environment.NewLine }, StringSplitOptions.None);
                }



                if (Config.Browser != "None")
                {
                    TestRun.Driver = SeleniumActions.GetDriver(Config.Browser);
                }

                RunTesting.Steps(TestSteps, TestRun.Driver);

                log.Info("Testing Summary for file " + currentFile);
                log.Info("===============");
                int passct  = 0;
                int failct  = 0;
                int totalct = 0;
                foreach (var item in RunTesting.Results.Keys)
                {
                    totalct++;
                    if (RunTesting.Results[item] == true)
                    {
                        passct++;
                    }
                    else
                    {
                        failct++;
                    }
                }
                log.Info("Total passes = " + passct);
                log.Info("Total fails  = " + failct);
                log.Info("Total Tests  = " + totalct);
                log.Info("Asta la vista!");
            }
        }
예제 #16
0
 public SigninPage(IWebDriver webdriver)
 {
     driver          = webdriver;
     seleniumactions = new SeleniumActions(driver);
 }
예제 #17
0
        //string oldtest = null

        public static bool RunStep(string test, string dep, string Type, string Page, string URL, string load, string reload, string Elem, By str, string disp, string act, string val, string Exp, int pause, int waitParm)
        {
            bool Rtn = true;


            int timer = waitParm;

            if (Type == "GUI" && TestRun.Driver == null)
            {
                log.Error("No web driver has been allocated for browser " + Config.Browser + ". GUI test: " + test + " ,step skipped");
                return(false);
            }

            if (load == "Yes")
            {
                TestRun.Driver.Navigate().GoToUrl(Config.GUIurl + URL);
            }
            if (reload == "Yes")
            {
                TestRun.Driver.Navigate().GoToUrl(TestRun.Driver.Url);
            }

            if (pause > 0)
            {
                Thread.Sleep(pause);
            }

            if (disp == "Yes")
            {
                if (!SeleniumActions.RunTest(str, timer, Elem, TestRun.Driver))
                {
                    log.Error("Error finding element " + Elem);
                    return(false);
                }
            }
            switch (act)
            {
            case "None":
                return(true);

            case "Click":
                Rtn = SeleniumActions.ActionClick(str, TestRun.Driver, Config.Time);
                break;

            case "SendKeys":
                Rtn = SeleniumActions.SendKeys(str, TestRun.Driver, Config.Time, val);
                break;

            case "Submit":
                Rtn = SeleniumActions.ActionSubmit(str, TestRun.Driver, Config.Time);
                break;

            case "Compare Text":
                var eText = SeleniumActions.GetText(str, TestRun.Driver, Config.Time);
                if (eText != Exp)
                {
                    log.Warn("Element Text : " + eText + " : Not equal to expected : " + Exp);
                }
                else
                {
                    log.Info("Text content :'" + eText + "' was expected");
                }
                Rtn = true;
                break;

            case "Hover":
                Rtn = SeleniumActions.ActionHover(str, TestRun.Driver, Config.Time);
                break;

            case "JavaClick":
                Rtn = SeleniumActions.JavaClick(str, TestRun.Driver, Config.Time);
                break;

            case "HttpPost":
                // Http Post is still under construction
                List <KeyValuePair <string, string> > pairstr = new List <KeyValuePair <string, string> >
                {
                    new KeyValuePair <string, string>(TestRun.APIuser, TestRun.APIpass),
                    new KeyValuePair <string, string>("Content", val)
                };
                Rtn = APIFunctions.HttpPost(Config.BaseUrl + TestRun.URL, pairstr);
                break;

            case "GetText":
                string Textval = SeleniumActions.GetText(str, TestRun.Driver, Config.Time);
                UpdateStepValues(TestRun.TestStep, "TextValue", Textval);
                break;

            case "SelectList":
                Rtn = SeleniumActions.SelectFromList(str, TestRun.Driver, Config.Time, val);
                break;

            case "loadGrid":
                Rtn = SeleniumActions.LoadFromGrid(str, TestRun.Driver, Config.Time, val);
                break;

            case "Close":
                if (Config.Browser != "None")
                {
                    log.Info("Closing Browser!");
                    TestRun.Driver.Quit();
                }
                break;

            default:
            {
                log.Error("Unknown 'Action'.  Check spelling and case.");
                Rtn = false;
                break;
            }
            }


            return(Rtn);
        }
예제 #18
0
 public BasePage(WebDriverBuilder webDriverBuilder, SeleniumActions seleniumActions)
 {
     _webDriverBuilder = webDriverBuilder;
     _seleniumActions  = seleniumActions;
 }