Esempio n. 1
0
        public static void WaitUntilWebElementEnabledAndDispalyed(this AutomatedElement ele, IWebDriver _driver, double waitingSec)
        {
            WebDriverWait wait = new WebDriverWait(_driver, TimeSpan.FromSeconds(waitingSec));

            try
            {
                wait.IgnoreExceptionTypes(typeof(NoSuchElementException));
                wait.Until <IWebElement>((d) =>
                {
                    IWebElement element = d.FindElement(ele.ByElement);
                    if (element.Displayed &&
                        element.Enabled)
                    {
                        return(element);
                    }

                    return(null);
                });
            }
            catch (Exception e)
            {
                AutomatedLogger.Log("Element Name: " + ele.Name + " - Element Locator: " + ele.ByElement.ToString() + " Not Exists" + "and Exception is " + e.Message);
                throw;
            }
        }
Esempio n. 2
0
 public void TeardownTest()
 {
     //Close the Browser : EndTest
     AutomatedBrowser.TearDown();
     TestReport.GenerateReport();
     AutomatedLogger.Log("Main Test: Teardown Tests");
 }
Esempio n. 3
0
        }//end method ReadConfigs

        /// <summary>
        /// Initialize the test configurations
        /// </summary>
        public static void Init()
        {
            if (!IsTestConfigsInitialized)
            {
                string automationConf = PathOfCurrentContext + "automation.conf";

                //Read the automated app configs
                ReadConfigs(automationConf);

                AutomatedLogger.Init(LogFile);
                AutomatedLogger.Log("Test that logging is working!");

                AutomatedLogger.Log("WebPath: " + automationConf);

                //Initialize your configs: messages, test data, logger, ...
                ExcelDataParser.Init(TestConfigs.TestDataFile);
                //TODO: this should be json data object
                //data = JsonDataParser.ParseJsonData(TestConfigs.TestDataFile);

                //Initialize the report here
                //TestReport.Initialize(TestConfigs.ReportingDirectory);

                IsTestConfigsInitialized = true;
            } //endif
        }     //end method
Esempio n. 4
0
        public void TestCommons_Setup(string automationConfigs)
        {
            AutomatedLogger.Log("Entering the Common Setup method");

            //Read the Test Configs (including the ones in app.config)
            TestConfigs.Init(automationConfigs);
            ApplicationConfigs.ReadConfigs(TestConfigs.PathOfCurrentContext);

            //Start a new Browser : Initialize
            ActiveBrowser = new AutomatedBrowser(TestConfigs.Browser, isGridEnabled: false);

            //Open Website in the browser started by Selenium
            if (!string.IsNullOrEmpty(TestConfigs.Url))
            {
                AutomatedActions.NavigationActions.NavigateToUrl(TestConfigs.Url);

                // Login
                //WindowsLogin();
                AutomatedActions.WindowActions.Maximize();
            }



            AutomatedLogger.Log("Exiting Common Setup method");
        }//end method Common Setup
Esempio n. 5
0
        public void SetupTest()
        {
            //AutomatedLogger.Log("Main Test: Setup Tests");
            //commented by asmaa: Common_Setup();

            _applicationCommons = new AppCommons();
            _applicationCommons.Common_Setup();

            //Implement logic that has to run before executing each scenario
            //Here, within the test context - this is the place that you can get where you are running.

            string currentPath = TestContext.CurrentContext.WorkDirectory.Replace("bin\\Debug", "");

            currentPath = currentPath.Replace("Test.Automation", "?");
            currentPath = currentPath.Replace("Automated.Tests", "?");
            currentPath = currentPath.Remove(currentPath.LastIndexOf('?'));

            TestConfigs.PathOfCurrentContext = currentPath;
            string automationConf = currentPath + "automation.conf";

            //Setup the Test Commons
            TestCommons_Setup(automationConf);

            AutomatedLogger.Log("Main Test: Setup Tests");

            //TestReport.Report_init(automationConf+".dir");

            //Create new test log with its title in the final report
            TestReport.test = TestReport.extent.CreateTest(TestContext.CurrentContext.Test.Name);
        }
Esempio n. 6
0
        public void TeardownTest()
        {
            //Close the Browser
            ActiveBrowser.TearDown();

            AutomatedLogger.Log("TestMain: TeardownTest");

            AutomatedLogger.Log("TestMain: Teardown: Copy Output directory to test.");
        }
Esempio n. 7
0
        public void TeardownTest()
        {
            //Close the Browser
            AutomatedBrowser.TearDown();

            //Finalize and generate the report
            AutomationReport.GenerateTestReport();

            AutomatedLogger.Log("TestMain: TeardownTest");
        }
Esempio n. 8
0
        protected void OneTimeSetup()
        {
            AutomatedLogger.Log("TestMain: OneTimeSetup");

            InitializeConfigs();

            //Initialize the report and attach the html reporter to it
            AutomationReport = new TestReport(TestConfigs.ReportingDirectory);
            number           = _random.Next(0, 100).ToString();
            email            = "mohamed.test" + number + "@test.com";
        }
Esempio n. 9
0
        protected void OneTimeSetup()
        {
            AutomatedLogger.Log("TestMain: OneTimeSetup");

            //Read the Test Configs(including the ones in app.config)
            string applicationName = Assembly.GetExecutingAssembly().GetName().Name;

            InitializeConfigs(applicationName);

            //Initialize the report and attach the html reporter to it
            AutomationReport = new TestReport(TestConfigs.ReportingDirectory);
        }
Esempio n. 10
0
        public void SetupTest()
        {
            AutomatedLogger.Log("TestMain : SetupTest");

            //Create a new test entry for this test in the report
            AutomationReport.CreateTest();

            //Setup the Test Commons
            OpenApplication();

            //Simple Assert at the beginning of each test. It checks the loading of the entry page of the test.
            IsEntryPageLoaded();
        }
Esempio n. 11
0
        /// <summary>
        /// Open the application url specified in the configs.
        /// Must be called after initializing the configs.
        /// </summary>
        public void OpenApplication()
        {
            AutomatedLogger.Log("OpenApplication: Go to the application url provided in the configs");

            //Start a new Browser : Initialize
            ActiveBrowser = new AutomatedBrowser(TestConfigs.Browser, isGridEnabled: false);

            //Open Website in the browser started by Selenium
            if (!string.IsNullOrEmpty(TestConfigs.Url))
            {
                AutomatedActions.NavigationActions.NavigateToUrl(ActiveBrowser.WebDriverInstance, TestConfigs.Url);
                AutomatedActions.WindowActions.Maximize(ActiveBrowser.WebDriverInstance);
            }

            AutomatedLogger.Log("Exiting OpenApplication");
        }//end method Common Setup
Esempio n. 12
0
        }//end method ReadConfigs

        /// <summary>
        /// Initialize the test configurations
        /// </summary>
        public static void Init()
        {
            if (!IsTestConfigsInitialized)
            {
                //Read the automated app configs
                ReadConfigs();

                //Initialize your configs: messages, test data, logger, ...
                ExcelDataParser.Init(TestConfigs.TestDataFile);
                AutomatedLogger.Init(LogFile);

                //Initialize the report here
                TestReport.Report_init(TestConfigs.ReportingDirectory);

                IsTestConfigsInitialized = true;
            } //endif
        }     //end method
Esempio n. 13
0
        public static IReadOnlyCollection <IWebElement> RetryingFindElements(By by)
        {
            IReadOnlyCollection <IWebElement> elements = null;
            int attempts = 0;

            while (attempts < 3)
            {
                try
                {
                    elements = AutomatedBrowser.WebDriverInstance.FindElements(by);
                    break;
                }
                catch (StaleElementReferenceException e)
                {
                    AutomatedLogger.Log(e.Message);
                }
                attempts++;
            }
            return(elements);
        }
Esempio n. 14
0
        public static bool RetryingFinds(By by)
        {
            bool result   = false;
            int  attempts = 0;

            while (attempts < 3)
            {
                try
                {
                    AutomatedBrowser.WebDriverInstance.FindElements(by);
                    result = true;
                    break;
                }
                catch (StaleElementReferenceException e)
                {
                    AutomatedLogger.Log(e.Message);
                }
                attempts++;
            }
            return(result);
        }