Example #1
0
        public void TestMethod2()
        {
            var container = new UnityContainer();

            container.RegisterType <IBrowserDriver, WrappedWebDriver>();
            container.RegisterType <IManageCookieService, WrappedWebDriver>();

            container.RegisterType <IManageNavigationService, WrappedWebDriver>();
            container.RegisterType <IUiElementFinderService, WrappedWebDriver>();

            container.RegisterType <IWaitingActionService, WrappedWebDriver>();
            container.RegisterType <IJsExecutor, WrappedWebDriver>();

            container.RegisterType <IUiElement, UiElement>();

            container.RegisterType <IInput, Input>();
            container.RegisterType <IButton, Button>();
            container.RegisterType <ICheckbox, Checkbox>();
            container.RegisterType <IFrame, Frame>();

            container.RegisterInstance(container);
            container.RegisterInstance <WebDriverConfig>(new ChromeDriverConfig {
                GridUri = new Uri("http://127.0.0.1:4444/wd/hub/"), UseGrid = false
            });

            var resolver = new UnityElementResolverService(container);

            container.RegisterInstance <IElementResolver>(resolver);
            var driver = container.Resolve <IBrowserDriver>();

            var logger = new NLogWrapper.Logger("logger");

            driver.Navigate("https://www.w3schools.com/tags/tryit.asp?filename=tryhtml_iframe", logger);

            var page = new Page(driver);

            logger.LOGITEM(LogLevel.INFO, "test message2", @"C:\Users\Aleh_Yanushkevich\Desktop\ddd.txt");

            var value = page.Home.GetAttribute("title", logger);

            var element = page.ChildFrame.Find <IUiElement>(Locator.Id("nav_references"), logger);

            var img = driver.Find <IUiElement>(Locator.XPath("(.//img)[1]"), logger);

            driver.Quit(logger);

            Assert.Pass("Some passed in TestMethod2.");
        }
Example #2
0
        public void TestMethod()
        {
            var container = new UnityContainer();

            container.RegisterType <IBrowserDriver, WrappedWebDriver>();
            container.RegisterType <IManageCookieService, WrappedWebDriver>();

            container.RegisterType <IManageNavigationService, WrappedWebDriver>();
            container.RegisterType <IUiElementFinderService, WrappedWebDriver>();

            container.RegisterType <IWaitingActionService, WrappedWebDriver>();
            container.RegisterType <IJsExecutor, WrappedWebDriver>();

            container.RegisterType <IUiElement, UiElement>();

            container.RegisterType <IInput, Input>();
            container.RegisterType <IButton, Button>();
            container.RegisterType <ICheckbox, Checkbox>();
            container.RegisterType <IFrame, Frame>();


            container.RegisterInstance(container);
            container.RegisterInstance <WebDriverConfig>(
                new ChromeDriverConfig
            {
                GridUri  = new Uri("http://127.0.0.1:4444/wd/hub/"),
                UseGrid  = false,
                Timeouts = new TimeoutSettings
                {
                    ExplicitWait       = 5,
                    HttpCommandTimeout = 120,
                    JavaScriptTimeout  = 60,
                    PoolingInterval    = 0.5
                }
            });

            var resolver = new UnityElementResolverService(container);

            container.RegisterInstance <IElementResolver>(resolver);
            var driver = container.Resolve <IBrowserDriver>();

            var logger = new NLogWrapper.Logger("logger1");

            driver.Navigate("https://www.w3schools.com/tags/tryit.asp?filename=tryhtml_iframe", logger);

            var page = new Page(driver);

            logger.LOGITEM(LogLevel.INFO, "test message", @"C:\Users\Aleh_Yanushkevich\Desktop\node.json");

            var value = page.Home.GetAttribute("title", logger);

            var button = driver.Find <IButton>(Locator.Id("tryhome"), logger);

            button.Description = "Button for returning to Home";

            //page.Home.Click(logger);

            (driver as WrappedWebDriver).JsClick(button, logger);

            //var element = page.ChildFrame.Find<IUiElement>(Locator.Id("nav_references"), logger);

            var img = driver.Find <UiElement>(Locator.XPath("(.//img)[1]"), logger);

            driver.Quit(logger);

            logger.INFO("INFO message", new ArgumentNullException("Argument is null reference!"));

            Assert.Fail("Some faile in TestMethod.");
        }