//[DataRow(MajorWebDriver.Edge)] //[DataRow(MajorWebDriver.InternetExplorer)] public void GetWebDriver(MajorWebDriver majorWebDriver) { var driver = WebDriverFactory.CreateDriver( majorWebDriver, WindowSize.DefaultDesktop); using (driver) { var defaultUrl = driver.Url; } }
public void KendoPagerComponentTest(MajorWebDriver driverType) { var driver = WebDriverFactory.CreateDriver( driverType, WindowSize.DefaultDesktop); var serviceCollection = new ServiceCollection(); serviceCollection.AddSingleton(driver); serviceCollection.AddSingleton(new PageOptions { Url = Startup.ServerUrl }); PageObjectFactory = new PageObjectFactory(serviceCollection, true); using (driver) { var homePage = PageObjectFactory.PreparePage <HomePage>(); widgetPage = homePage.GoToWidget("kendo", "2014.1.318", "KPager"); var pagerComponent = PageObjectFactory.PrepareComponent( new KPagerComponent <WidgetPage>( new BaseKendoConfiguration(), By.CssSelector("#pager"), PageObjectFactory, driver, widgetPage)); pagerComponent.Refresh(); var availbleSizes = pagerComponent.GetAvailableItemsPerPage(); var activePageSize = pagerComponent.GetItemsPerPage(); var totalItems = pagerComponent.GetTotalItems(); var initialActivePage = pagerComponent.GetActivePage(); pagerComponent.NextPage(); var secondActivePage = pagerComponent.GetActivePage(); pagerComponent.PrevPage(); pagerComponent.LastPage(); pagerComponent.FirstPage(); CollectionAssert.AreEqual(new[] { 2, 4 }, availbleSizes.ToArray()); Assert.AreEqual(totalItems, 4); Assert.IsTrue(pagerComponent.HasNextPage); Assert.IsFalse(pagerComponent.HasPreviousPage); Assert.AreEqual(initialActivePage, 1); Assert.AreEqual(secondActivePage, 2); Assert.AreEqual(2, activePageSize); } }
/// <summary> /// Creates a new WebDriver instance for one of the major web /// browsers. Will wrap the driver in an /// <see cref="EventFiringWebDriver"/>. /// </summary> /// <param name="majorWebDriver"></param> /// <param name="windowSize"></param> /// <param name="track"> /// If false, will not dispose the driver when the factory is /// disposed. /// </param> /// <returns></returns> public IWebDriver CreateDriver(MajorWebDriver majorWebDriver, Size windowSize, bool track = true) { var driver = default(IWebDriver); var driverOpts = default(DriverOptions); var driverConfig = default(IDriverConfig); switch (majorWebDriver) { case MajorWebDriver.Chrome: driverConfig = new ChromeConfig(); driverOpts = new ChromeOptions(); break; case MajorWebDriver.Edge: driverConfig = new EdgeConfig(); driverOpts = new EdgeOptions(); break; case MajorWebDriver.Firefox: driverConfig = new FirefoxConfig(); driverOpts = new FirefoxOptions(); break; case MajorWebDriver.InternetExplorer: driverConfig = new InternetExplorerConfig(); driverOpts = new InternetExplorerOptions(); break; default: throw new NotImplementedException(); } // Download driver if not available locally. driverManager.SetUpDriver(driverConfig); if (isStandalone) { switch (majorWebDriver) { case MajorWebDriver.Chrome: { var opts = driverOpts as ChromeOptions; opts.BinaryLocation = @"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"; driver = new ChromeDriver(opts); break; } case MajorWebDriver.Edge: { driver = new EdgeDriver(); break; } case MajorWebDriver.Firefox: { var opts = driverOpts as FirefoxOptions; opts.BrowserExecutableLocation = @"C:\Program Files\Mozilla Firefox\firefox.exe"; driver = new FirefoxDriver(opts); break; } case MajorWebDriver.InternetExplorer: { driver = new InternetExplorerDriver(); break; } default: throw new NotImplementedException(); } } else { var d = new RemoteSessionSettings(); d.AddFirstMatchDriverOption(driverOpts); driver = new RemoteWebDriver(d); } // Set the window size. driver.Manage().Window.Size = windowSize; // Wrap with EventFiringWebDriver. //driver = new EventFiringWebDriver(driver); if (track) { trackedDrivers.Add(driver); } return(driver); }