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; } }
public void TeardownTest() { //Close the Browser ActiveBrowser.TearDown(); AutomatedLogger.Log("TestMain: TeardownTest"); AutomatedLogger.Log("TestMain: Teardown: Copy Output directory to test."); }
public void TeardownTest() { //Close the Browser AutomatedBrowser.TearDown(); //Finalize and generate the report AutomationReport.GenerateTestReport(); AutomatedLogger.Log("TestMain: TeardownTest"); }
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"; }
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); }
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(); }
/// <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
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); }
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); }
}//end method ReadConfigs /// <summary> /// Initialize the test configurations /// </summary> public static void Init(string automationConf) { if (!IsTestConfigsInitialized) { //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.Report_init(TestConfigs.ReportingDirectory); IsTestConfigsInitialized = true; } //endif } //end method