Inheritance: MonoBehaviour
Example #1
0
 public MethodRewriteFixture()
 {
     this.browser = new Browser(with =>
     {
         with.Module<MethodRewriteModule>();
     });
 }
        public void TC01_TestLaunchDispose()
        {
            Browser browser = new Browser();

            Assert.IsFalse(browser.Opened, "The initial Browser state should be non-opened but it was not!");
            Assert.AreEqual(BrowserType.None, browser.BrowserType, "The initial browser type should be None but it was not!");
            //Assert.Throws(Exception, browser.WebDriver, "When the browser state is non-opened, getting the WebDriver reference should result in an exception but it did not!");

            try
            {
                // Launch a web browser instance.
                browser.Launch(this.browserType);
                Assert.IsTrue(browser.Opened, "After successfully launching a web browser instance, the Browser state should be opened but it was not!");
                Assert.AreEqual(this.browserType, browser.BrowserType, "After opening a web browser, the current browser type should match but it did not!");
                Assert.IsNotNull(browser.WebDriver, "After opening a web browser, the WebDriver reference should not be null but it was!");
            }
            finally
            {
                // Always dispose the browser no matter whether it was successfully launched or not.
                browser.Dispose();
            }

            Assert.IsFalse(browser.Opened, "After disposing (i.e., closing the opened web browser instance) the Browser state should be non-opened but it was not!");
            Assert.AreEqual(BrowserType.None, browser.BrowserType, "After disposing (i.e., closing the opened web browser instance), the current browser type should be null but it was not!");
            //Assert.Throws(Exception, browser.WebDriver, "After disposing (i.e., closing the opened web browser instance), getting the WebDriver reference should result in an exception but it did not!");

            // Disposing more than once should be allowed (no exception).
            browser.Dispose();
        }
Example #3
0
        // transform 0.04s linear, opacity 0.04s linear, visibility 0.04s linear;
        // -webkit-transform 0.04s linear, opacity 0.04s linear, visibility 0.04s linear;

        public static CssValue PatchValue(CssValue value, Browser browser)
        {
            if (value.Kind != NodeKind.ValueList) return value;

            var a = (CssValueList)value;

            var list = new CssValueList(a.Seperator);

            foreach (var node in a)
            {
                if (node.Kind == NodeKind.ValueList) // For comma seperated componented lists
                {
                    list.Add(PatchValue(node, browser));
                }
                else if (node.Kind == NodeKind.String && node.ToString() == "transform")
                {
                    list.Add(new CssString(browser.Prefix.Text + "transform"));
                }
                else
                {
                    list.Add(node);
                }
            }

            return list;
        }
Example #4
0
        public void TestUsercanceldiscont(Browser browser,string raid,string raname)
        {
            browser.Link(Find.ByText("平台管理")).Click();
            browser.WaitUntilContainsText("请在左边的菜单选择您要进行的操作。 如有疑问,请点击下面相关链接查看操作流程图或查看交易指南");
            Assert.IsTrue(browser.ContainsText("请在左边的菜单选择您要进行的操作。 如有疑问,请点击下面相关链接查看操作流程图或查看交易指南"));

            browser.Link(Find.ByText("销售折扣管理")).Click();
            browser.WaitUntilContainsText("折扣设置");
            Assert.IsTrue(browser.ContainsText("折扣设置"));

            //状态生效

            browser.RadioButton(Find.ById(raid)).Checked = true;

            WatiN.Core.DialogHandlers.ConfirmDialogHandler dh4 = new WatiN.Core.DialogHandlers.ConfirmDialogHandler();

            browser.AddDialogHandler(dh4);

            browser.Button(Find.ById("ctl00_ContentPlaceHolder1_btnDelete")).ClickNoWait();
            dh4.WaitUntilExists(15);//
            dh4.OKButton.Click();//

            browser.RemoveDialogHandler(dh4);
            Thread.Sleep(1000);
            Assert.IsFalse(browser.ContainsText(raname));
        }
Example #5
0
        public void SearchingAnInputElementBySeveralSelectingMethods()
        {
            Browser b = new Browser();
            b.SetContent(Helper.GetFromResources("SimpleBrowser.UnitTests.SampleDocs.SimpleForm.htm"));

            var colorBox = b.Find("colorBox"); // find by id
            Assert.That(colorBox.Count() == 1, "There should be exactly 1 element with ID colorBox");

            colorBox = b.Find("input", new {name="colorBox", type="color"}); // find by attributes
            Assert.That(colorBox.Count() == 1, "There should be exactly 1 element with name colorBox and type color");

            colorBox = b.Find("input", new { name = "colorBox", type = "Color" }); // find by attributes
            Assert.That(colorBox.Count() == 1, "There should be exactly 1 element with name colorBox and type color");

            colorBox = b.Find("input", new { name = "colorBox", type = "Colors" }); // find by attributes
            Assert.That(colorBox.Exists == false, "There should be no element with name colorBox and type Colors");

            colorBox = b.Find(ElementType.TextField, new { name = "colorBox", type = "Color" }); // find by attributes
            Assert.That(colorBox.Count() == 0, "Input elements with types other than text, password and hidden should not be found");

            colorBox = b.Find("input", FindBy.Name, "colorBox"); // find by FindBy
            Assert.That(colorBox.Count() == 1, "There should be exactly 1 element with name colorBox");

            colorBox = b.Select("input[name=colorBox]"); // find by Css selector
            Assert.That(colorBox.Count() == 1, "There should be exactly 1 element with name colorBox");

            colorBox = b.Select("input[type=color]"); // find by Css selector
            Assert.That(colorBox.Count() == 1, "There should be exactly 1 element with type color");

            colorBox = b.Select("input[type=Color]"); // find by Css selector
            Assert.That(colorBox.Count() == 0, "There should be no element for the expression input[type=Color] (CSS is case sensitive)");

            var clickLink = b.Select(".clickLink"); // find by Css selector
            Assert.That(clickLink.Count() == 1, "There should be one element for the expression .clickLink");
        }
 public AWBProfilesForm(Browser.WebControl Browser)
 {
     InitializeComponent();
     loginAsThisAccountToolStripMenuItem.Visible = true;
     loginAsThisAccountToolStripMenuItem.Click += lvAccounts_DoubleClick;
     webBrowser = Browser;
 }
        /// <summary>
        /// Method to Add a Bad Actor
        /// See AddVerticalEdit for param description
        /// </summary>
        /// <param name="browser">WatiN Browser Object</param>
        /// <param name="name"></param>
        /// <param name="level"></param>
        /// <param name="efrom"></param>
        /// <param name="eto"></param>
        /// <param name="exception"></param>
        /// <param name="errortype"></param>
        /// <param name="days"></param>
        /// <param name="errcount"></param>
        /// <param name="countat"></param>
        /// <param name="recprob"></param>
        /// <param name="source"></param>
        /// <param name="errorlevel"></param>
        /// <param name="reqcon"></param>
        /// <param name="configpath"></param>
        /// <param name="basematches"></param>
        /// <param name="associatedmatches"></param>
        /// <param name="commit"></param>
        /// <param name="save"></param>
        /// 
        public void AddBadActor(Browser browser, string name, string level, string efrom, string eto, string exception, string errortype, string days, string errcount, 
          string countat,  string recprob, string source, string errorlevel, string reqcon, string configpath, bool basematches, bool associatedmatches, bool commit, bool save)
        {
            XmlDocument xmldoc = new XmlDocument();
            xmldoc.Load(configpath);

            XmlNode xn = xmldoc.SelectSingleNode("//config/admin/matchpath");
            string basepath = xn.InnerText;

            browser.Button(Find.ById(new Regex("ctl00_MainContent_rpEdits_cmdNewBA"))).Click();

            browser.WaitUntilContainsText("Effective From");

            EditDetails(browser, name, level, efrom, eto, exception, errortype, recprob, source, errorlevel);

            browser.TextField(Find.ById(new Regex("ctl00_MainContent_rpEditDetails_tBoxTSID"))).SetAttributeValue("value", days);
            browser.TextField(Find.ById(new Regex("ctl00_MainContent_rpEditDetails_tBoxNoOfTimes"))).SetAttributeValue("value", errcount);
            browser.RadioButton(Find.ByLabelText(countat)).Checked = true;

            if (basematches == true)
            {
                EditBaseMatches(browser, basepath, commit);
            }

            SaveDetails(browser, save);
        }
        private EnvironmentManager()
        {
            browser = (Browser)Enum.Parse(typeof(Browser), GetSettingValue("Drivertype"));
            browserName = (BrowserName)Enum.Parse(typeof(BrowserName), GetSettingValue("BrowserName"));
            switch (browser)
            {
                case Browser.Remote:
                    // todo get config
                    // todo validate config
                    ReadRemoteConfiguration();
                    //if(GetSettingValue("AutoStart"))

                    //throw new NotImplementedException();
                    var settings = new SeleniumServerSettings { HostName = "localhost", Port = "4444", StandAlonePath = @"C:\Users\Rick\Documents\GitHub\SeleniumExtensions\selenium-server-standalone-3.0.1.jar" };

                    remoteServer = new SeleniumServerProxy(settings);
                    break;
                case Browser.SauceLabs:
                    // todo get config
                    // todo validate config
                    ReadRemoteConfiguration();
                    Assembly executingAssembly = Assembly.GetExecutingAssembly();
                    string assemblyLocation = executingAssembly.Location;
                    string currentDirectory = Path.GetDirectoryName(assemblyLocation);
                    break;
                case Browser.IPhone:
                case Browser.Android:
                case Browser.WindowsPhone:
                    throw new NotImplementedException("No mobile support at this time");
                default: //all other cases are local drivers
                    break;
            }
        }
Example #9
0
        public BrowserFixture()
        {
            var bootstrapper =
                new FakeNancyBootstrapper();

            this.browser = new Browser(bootstrapper);
        }
        public IWebDriver LaunchBrowser(Browser browser)
        {
            switch (browser)
            {
                case Browser.IE:
                    driver = StartIEBrowser();
                    break;
                case Browser.Chrome:
                    driver = StartChromeBrowser();
                    break;
                case Browser.Safari:
                    driver = StartSafariBrowser();
                    break;
                case Browser.Firefox:
                default:
                    driver = StartFirefoxBrowser();
                    break;
            }

            driver.Manage().Cookies.DeleteAllCookies();
            SetBrowserSize();
            var eDriver = new EventedWebDriver(driver);

            return eDriver.driver;
        }
        public void Should_fail_to_resolve_route_because_it_does_have_an_invalid_condition()
        {
            // Given
            var cache = new FakeRouteCache(with => {
                with.AddGetRoute("/invalidcondition", "modulekey", ctx => false);
            });

            var bootstrapper = new ConfigurableBootstrapper(with =>{
                with.RouteCache(cache);
            });

            var browser = new Browser(bootstrapper);

            // When
            var timer = new Stopwatch();
            timer.Start();

            for (var i = 0; i < numberOfTimesToResolveRoute; i++)
            {
                var result = browser.Get("/invalidcondition");
                result.StatusCode.ShouldEqual(HttpStatusCode.NotFound);
            }

            timer.Stop();

            // Then
            Debug.WriteLine(" took {0} to execute {1} times", timer.Elapsed, numberOfTimesToResolveRoute);
        }
Example #12
0
 public void UsePlusSelector()
 {
     Browser b = new Browser();
     b.SetContent(Helper.GetFromResources("SimpleBrowser.UnitTests.SampleDocs.SimpleForm.htm"));
     var inputDirectlyUnderForm = b.Select("div + input");
     Assert.That(inputDirectlyUnderForm.Count() == 1); // only one <input> comes directly after a div
 }
		private void HandleRequestLogged(Browser b, HttpRequestLog req)
		{
			if (this.RequestLogged != null)
			{
				this.RequestLogged(b, req);
			}
		}
Example #14
0
        public ModelBindingFixture()
        {
            this.bootstrapper =
                new ConfigurableBootstrapper(with => with.Modules(new[] { typeof(ModelBindingModule) }));

            this.browser = new Browser(bootstrapper);
        }
Example #15
0
        public void TestUserOrderPaymentInfo(Browser browser)
        {
            browser.WaitUntilContainsText("Step 4: Enter Payment Information");
            Assert.IsTrue(browser.ContainsText("Step 4: Enter Payment Information"));

            browser.TextField(Find.ById("ctl00_ctl00_uxContent_ContentPlaceHolder1_txt_user_firstname")).TypeText("christie");

            browser.TextField(Find.ById("ctl00_ctl00_uxContent_ContentPlaceHolder1_txt_user_lastname")).TypeText("Test");

            browser.TextField(Find.ById("ctl00_ctl00_uxContent_ContentPlaceHolder1_txt_user_addr")).TypeText("zhongshanbeiroad");

            browser.TextField(Find.ById("ctl00_ctl00_uxContent_ContentPlaceHolder1_txt_user_city")).TypeText("shanghai");

            browser.SelectList(Find.ById("ctl00_ctl00_uxContent_ContentPlaceHolder1_dl_user_state")).Option(Find.ByValue("AL")).Select();
            browser.TextField(Find.ById("ctl00_ctl00_uxContent_ContentPlaceHolder1_txt_user_zip")).TypeText("11111");

            browser.TextField(Find.ById("ctl00_ctl00_uxContent_ContentPlaceHolder1_ux_phone")).Value="1111111111";
            browser.TextField(Find.ById("ctl00_ctl00_uxContent_ContentPlaceHolder1_ux_phone")).Focus();
            //browser.TextField(Find.ById("ctl00_ctl00_uxContent_ContentPlaceHolder1_ux_phone")).DoubleClick();

            browser.TextField(Find.ById("ctl00_ctl00_uxContent_ContentPlaceHolder1_txt_user_email")).TypeText("*****@*****.**");

            browser.TextField(Find.ById("ctl00_ctl00_uxContent_ContentPlaceHolder1_txt_order_description")).TypeText("ordertest");
            browser.CheckBox(Find.ById("ctl00_ctl00_uxContent_ContentPlaceHolder1_chbAgreement")).Checked = true;
            browser.CheckBox(Find.ById("ctl00_ctl00_uxContent_ContentPlaceHolder1_chb_contactinfo")).Checked = true;
            browser.SelectList(Find.ById("ctl00_ctl00_uxContent_ContentPlaceHolder1_dl_pay_year")).Option("2011").Select();

            browser.TextField(Find.ById("ctl00_ctl00_uxContent_ContentPlaceHolder1_txt_pay_account")).TypeText("4111111111111111");

            browser.TextField(Find.ById("ctl00_ctl00_uxContent_ContentPlaceHolder1_txt_pay_cid")).TypeText("111");
            browser.Link(Find.ById("ctl00_ctl00_uxContent_ContentPlaceHolder1_BottomBtNext")).Click();

            browser.WaitUntilContainsText("Your Order Is Complete");
            Assert.IsTrue(browser.ContainsText("Your Order Is Complete"));
        }
Example #16
0
 public IWebDriver NewWebDriver(Browser browser)
 {
     if (browser == Browser.Firefox)
         return new FirefoxDriver();
     if (browser == Browser.InternetExplorer)
     {
         var options = new InternetExplorerOptions
             {
                 IntroduceInstabilityByIgnoringProtectedModeSettings = true,
                 EnableNativeEvents = true
             };
         return new InternetExplorerDriver(options);
     }
     if (browser == Browser.Chrome)
         return new ChromeDriver();
     if (browser == Browser.Android)
         return new AndroidDriver();
     if (browser == Browser.HtmlUnit)
         return new RemoteWebDriver(DesiredCapabilities.HtmlUnit());
     if (browser == Browser.HtmlUnitWithJavaScript) {
         DesiredCapabilities desiredCapabilities = DesiredCapabilities.HtmlUnit();
         desiredCapabilities.IsJavaScriptEnabled = true;
         return new RemoteWebDriver(desiredCapabilities);
     }
     if (browser == Browser.PhantomJS)
         return new PhantomJSDriver();
     return browserNotSupported(browser,null);
 }
Example #17
0
        public void SetMapDesiredCount(int CountNumber, Browser browser)
        {
            browser.TextField("ctl00_ctl00_uxContent_ContentPlaceHolder1_gvOrderResults_ctl02_tbDesQty").WaitUntilExists(20);
            browser.TextField("ctl00_ctl00_uxContent_ContentPlaceHolder1_gvOrderResults_ctl02_tbDesQty").TypeText(CountNumber.ToString());

            browser.Span((Find.ById("ctl00_ctl00_uxContent_ContentPlaceHolder1_tbTolDesQty")) && (Find.ByText(CountNumber.ToString()))).WaitUntilExists(30);
        }
Example #18
0
        public void When_Testing_Referer_AlwaysMode_Secure_Transition()
        {
            string startingUrl = "https://www.example.com/";

            Browser b = new Browser();
            b.RefererMode = Browser.RefererModes.Always;
            Assert.AreEqual(b.RefererMode, Browser.RefererModes.Always);

            b.Navigate(startingUrl);
            Assert.IsNotNull(b.CurrentState);
            Assert.IsNull(b.Referer);

            var link = b.Find(ElementType.Anchor, FindBy.Text, "More information...");
            Assert.IsNotNull(link);

            string targetHref = link.GetAttribute("href");
            Assert.AreEqual(targetHref, "http://www.iana.org/domains/example");

            link.Click();
            Assert.IsNotNull(b.CurrentState);
            Assert.AreEqual(b.Referer.ToString(), startingUrl);

            // This explicitly tests that a 300 redirect preserves the original referrer.
            Assert.AreEqual(b.CurrentState.Url.ToString(), "http://www.iana.org/domains/reserved");
            Assert.AreNotEqual(b.Referer.ToString(), targetHref);
        }
Example #19
0
        public void Should_not_leak_memory_across_requests()
        {
            // Given
            var browser = new Browser(c => c.Module<SerializerTestModule>());

            SendRequest(browser); // Warm up

            var checkPoint = dotMemory.Check();

            // When
            for (var i = 0; i < 100; i++)
            {
                SendRequest(browser);
            }

            // Then
            dotMemory.Check(memory =>
            {
                var objectsCount = memory
                    .GetDifference(checkPoint)
                    .GetNewObjects()
                    .SizeInBytes;

                Assert.InRange(objectsCount, 0, 500);
            });
        }
        /// <summary>
        /// construct an ActionManager
        /// </summary>
        /// <param name="parent">the Automation object</param>
        public SeleniumActionManager(IAutomation parent, Browser browser)
            : base(parent)
        {
            switch (browser)
            {
                case Browser.Chrome:
                    {
                        OpenQA.Selenium.Chrome.ChromeDriverService service = OpenQA.Selenium.Chrome.ChromeDriverService.CreateDefaultService();
                        service.HideCommandPromptWindow = true;
                        WebDriver = new OpenQA.Selenium.Chrome.ChromeDriver(service, new OpenQA.Selenium.Chrome.ChromeOptions());
                        break;
                    }
                case Browser.FireFox:
                    WebDriver = new OpenQA.Selenium.Firefox.FirefoxDriver();
                    break;
                case Browser.Safari:
                    WebDriver = new OpenQA.Selenium.Safari.SafariDriver();
                    break;
                default:
                    WebDriver = new OpenQA.Selenium.IE.InternetExplorerDriver();
                    break;
            };
            WebDriver.Manage().Timeouts().ImplicitlyWait(WaitTime);

            RegisterAction(new ActionClick(WebDriver));
            RegisterAction(new ActionOpenURL(WebDriver));
            RegisterAction(new ActionRefresh(WebDriver));
            RegisterAction(new ActionGoBack(WebDriver));
            RegisterAction(new ActionEnter(WebDriver));

            RegisterAction(new ActionCheckControlProperty(WebDriver));
            RegisterAction(new ActionSet(WebDriver));
        }
Example #21
0
        static void Main(string[] args)
        {
            ExamplePresenter.Init();

            Browser browser = new Browser();
            Application.Run(browser);
        }
 public void Register(Browser browser, List<FuzzyAction> actions)
 {
     foreach (var radioButton in browser.RadioButtons)
     {
         actions.Add(new RadioButtonAction(radioButton));
     }
 }
Example #23
0
 public WebPage()
 {
     this.browser = new Browser();
     this.browser.Size = new Size(1024, 800);
     this.browser.ScrollBarsEnabled = false;
     this.browser.ObjectForScripting = new Callback.External();
 }
        public static void AddFriend(Browser browser)
        {
            loginPage = new LoginPage(browser);
            loginPage.LoginUser(TelerikUser.Related1);

            mainPage = new MainPage(browser);
            mainPage.NavigateTo(TelerikUser.Related2.Url);

            userPage = new UserProfilePage(browser);
            if (userPage.AddFriendButton != null && userPage.AddFriendButton.IsVisible())
            {
                userPage.ClickAddFriendButton();
                mainPage.ClickLogout();

                mainPage.NavigateTo(loginPage.Url);
                loginPage.LoginUser(TelerikUser.Related2);

                friendsPage = new FriendsPage(browser);
                mainPage.NavigateTo(friendsPage.Url);
                friendsPage.ClickApproveFriendshipIcon();
            }

            mainPage.ClickLogout();
            mainPage.NavigateTo(loginPage.Url);
            loginPage.LoginUser(TelerikUser.Related1);
        }
        /// <summary>
        /// Resolving a browser exe path based on the Setting.
        /// </summary>
        /// <param name="browser"><see cref="Broser"/> type.</param>
        /// <returns>Path to the exe for specific browser.</returns>
        public static string GetBrowserExePath(Browser browser)
        {
            var path = string.Empty;
            var settings = Properties.Settings.Default;

            switch (browser)
            {
                case Browser.IE:
                    path = settings.IeExePath;
                    break;
                case Browser.Chrome:
                    path = settings.ChromeExePath;
                    break;
                case Browser.Firefox:
                    path = settings.FirefoxExePath;
                    break;
                case Browser.Opera:
                    path = settings.OperaExePath;
                    break;
                default:
                    path = settings.IeExePath;
                    break;
            }

            if (string.IsNullOrWhiteSpace(path))
            {
                throw new InvalidOperationException(string.Format("Path to the browser exe for {0} can not be empty.", browser.ToString()));
            }

            return path;
        }
Example #26
0
        public void TestUserspecialtylists(Browser browser)
        {
            browser.WaitUntilContainsText("Please complete the short form below and a Data Specialist will follow up with you");
            Assert.IsTrue(browser.ContainsText("Please complete the short form below and a Data Specialist will follow up with you"));

            browser.TextField(Find.ById("ctl00_ctl00_uxContent_ContentPlaceHolder1_ux_fir_name")).TypeText("bobby");

            browser.TextField(Find.ById("ctl00_ctl00_uxContent_ContentPlaceHolder1_ux_last_name")).TypeText("wang");

            //browser.TextField(Find.ById("ctl00_ctl00_uxContent_ContentPlaceHolder1_txt_user_addr")).TypeText("zhongshanbeiroad");

            //browser.TextField(Find.ById("ctl00_ctl00_uxContent_ContentPlaceHolder1_txt_user_city")).TypeText("shanghai");

            //browser.SelectList(Find.ById("ctl00_ctl00_uxContent_ContentPlaceHolder1_dl_user_state")).Option(Find.ByValue("AL")).Select();
            //browser.TextField(Find.ById("ctl00_ctl00_uxContent_ContentPlaceHolder1_txt_user_zip")).TypeText("11111");

            browser.TextField(Find.ById("ctl00_ctl00_uxContent_ContentPlaceHolder1_ux_phone")).TypeText("1111111111");
            browser.TextField(Find.ById("ctl00_ctl00_uxContent_ContentPlaceHolder1_ux_phone")).Focus();

            browser.TextField(Find.ById("ctl00_ctl00_uxContent_ContentPlaceHolder1_ux_email")).TypeText("*****@*****.**");
            browser.SelectList(Find.ById("ctl00_ctl00_uxContent_ContentPlaceHolder1_uxHowMany")).Option(Find.ByValue("1,001 - 5,000")).Select();
            browser.SelectList(Find.ById("ctl00_ctl00_uxContent_ContentPlaceHolder1_uxHowSoon")).Option(Find.ByValue("Immediately")).Select();
            browser.SelectList(Find.ById("ctl00_ctl00_uxContent_ContentPlaceHolder1_uxInterest")).Option(Find.ByValue("Ailments")).Select();
            browser.TextField(Find.ById("ctl00_ctl00_uxContent_ContentPlaceHolder1_uxTarget")).TypeText("test");
            browser.Image(Find.ById("ctl00_ctl00_uxContent_ContentPlaceHolder1_ImageButton1")).Click();

            browser.WaitUntilContainsText("Thank you! We have received your request and we will follow up with you within the next business day");
            Assert.IsTrue(browser.ContainsText("Thank you! We have received your request and we will follow up with you within the next business day"));
        }
        public static void Bootstrap(Browser browser)
        {
            SeleniumWebDriver.SelectedBrowser = browser;

            FluentAutomation.Settings.Registration = (container) =>
            {
                container.Register<ICommandProvider, CommandProvider>();
                container.Register<IExpectProvider, ExpectProvider>();
                container.Register<ICaptureProvider, CaptureProvider>();
                container.Register<IFileStoreProvider, LocalFileStoreProvider>();

                switch (SeleniumWebDriver.SelectedBrowser)
                {
                    case Browser.InternetExplorer:
                        EmbeddedResources.UnpackFromAssembly("IEDriverServer.exe", Assembly.GetAssembly(typeof(SeleniumWebDriver)));
                        container.Register<IWebDriver, OpenQA.Selenium.IE.InternetExplorerDriver>().AsMultiInstance();
                        break;
                    case Browser.Firefox:
                        container.Register<IWebDriver, OpenQA.Selenium.Firefox.FirefoxDriver>().AsMultiInstance();
                        break;
                    case Browser.Chrome:
                        EmbeddedResources.UnpackFromAssembly("chromedriver.exe", Assembly.GetAssembly(typeof(SeleniumWebDriver)));
                        container.Register<IWebDriver, OpenQA.Selenium.Chrome.ChromeDriver>().AsMultiInstance();
                        break;
                }
            };
        }
        public void HtmlElement_Comment()
        {
            Browser b = new Browser();
            b.SetContent(Helper.GetFromResources("SimpleBrowser.UnitTests.SampleDocs.CommentElements.htm"));
            b.Find("link1");

            var comments = from node in b.XDocument.Elements().DescendantNodesAndSelf()
                           where node.NodeType == XmlNodeType.Comment
                           select node as XComment;

            var comment = comments.First();
            Assert.That(comment.ToString(), Is.EqualTo("<!-- Valid comment -->"));

            comment = comments.Skip(1).First();
            Assert.That(comment.ToString(), Is.EqualTo("<!-- Malformed comment -->"));

              // Nr 3 is a comment inside a script block

            comment = comments.Skip(3).First();
            Assert.That(comment.ToString(), Is.EqualTo("<!--[if gt IE 9]-->"));

            comment = comments.Skip(4).First();
            Assert.That(comment.ToString(), Is.EqualTo("<!--[endif]-->"));

            comment = comments.Skip(5).First();
            Assert.That(comment.ToString(), Is.EqualTo("<!--[if gt IE 10]>\r\n<a id=\"link2\" href=\"http://www.microsoft.com\">Downlevel-hidden conditional comment test</a>\r\n<![endif]-->"));
        }
Example #29
0
        public void TestUserverifylad(Browser browser)
        {
            browser.Link(Find.ById("ctl00_linkTrade")).Click();
            browser.WaitUntilContainsText("请在左边的菜单选择您要进行的操作。 如有疑问,请点击下面相关链接查看操作流程图或查看交易指南");
            Assert.IsTrue(browser.ContainsText("请在左边的菜单选择您要进行的操作。 如有疑问,请点击下面相关链接查看操作流程图或查看交易指南"));

            browser.Link(Find.ByText("我要销售")).Click();
            browser.WaitUntilContainsText("请在左边的菜单选择您要进行的操作");
            Assert.IsTrue(browser.ContainsText("请在左边的菜单选择您要进行的操作"));

            browser.Link(Find.ByText("我的议价信息")).Click();
            browser.WaitUntilContainsText("合同号");
            Assert.IsTrue(browser.ContainsText("合同号"));

            browser.Link(Find.ByText("议价")).Click();

            //WatiN.Core.DialogHandlers.ConfirmDialogHandler dh3 = new WatiN.Core.DialogHandlers.ConfirmDialogHandler();

            //browser.AddDialogHandler(dh3);

            browser.Button(Find.ById("ctl00_ContentPlaceHolder1_btnAccept")).ClickNoWait();
            //dh3.WaitUntilExists(15);//
            //dh3.OKButton.Click();//
            //browser.RemoveDialogHandler(dh3);

            //Thread.Sleep(2000);
        }
 public void HomeModule()
 {
     browser = new Browser (with => with.Module (new HomeModule ()));
     result = browser.Get ("/", with => {
         with.HttpRequest ();
     });
 }
Example #31
0
        internal static void Posts()
        {
            var Posts = Browser.FindByXpath("//*[@id='menu-posts']/a/div[3]").Single();

            Posts.Click();
        }
Example #32
0
 public AboutViewModel()
 {
     Title          = "About";
     OpenWebCommand = new Command(async() => await Browser.OpenAsync("https://aka.ms/xamarin-quickstart"));
 }
 public AboutViewModel()
 {
     Title          = "About";
     OpenWebCommand = new Command(async() => await Browser.OpenAsync("https://xamarin.com"));
     Kaboom         = new Command(async() => CrossToastPopUp.Current.ShowToastMessage("Kaboom!"));
 }
Example #34
0
 public AboutViewModel()
 {
     Title          = "About";
     OpenWebCommand = new Command(async() => await Browser.OpenAsync("https://xamarin.com"));
 }
Example #35
0
 internal static void AssertPage()
 {
     Assert.Contains("Add New", Browser.PageSource());
 }
 public static void StopBrowser()
 {
     Browser.Quit();
     Browser     = null;
     BrowserWait = null;
 }
Example #37
0
        internal static void AddNewPosts()
        {
            var NewPost = Browser.FindByXpath("//*[@id='wpbody-content']/div[3]/a").Single();

            NewPost.Click();
        }
Example #38
0
 public PartnersPage(Browser browser)
     : base(browser)
 {
 }
Example #39
0
 private async void June_Clicked(object sender, EventArgs e)
 {
     Uri url = new Uri("https://triptoestonia.com/obshhaya-informaciya/prazdniki-estonii/den-pobedy/");
     await Browser.OpenAsync(url);
 }
Example #40
0
        void OnButtonClicked(object sender, EventArgs e)
        {
            Uri uri = new Uri("https://xn--riigiphad-v9a.ee/");

            Browser.OpenAsync(uri);
        }
 protected override void InitializeAsyncCore()
 {
     Navigate(ServerPathBase);
     Browser.MountTestComponent <ProtectedBrowserStorageUsageComponent>();
 }
 private async void OvalFigure_Clicked(object sender, EventArgs e)
 {
     Uri ovaluri = new Uri("https://www.webmath.ru/web/prog49_1.php");
     await Browser.OpenAsync(ovaluri);
 }
Example #43
0
 /// <summary>
 /// Initializes an instance of a browser element.
 /// </summary>
 /// <param name="element"> The browser element this is for. </param>
 /// <param name="browser"> The browser this element is associated with. </param>
 /// <param name="collection"> The collection this element is associated with. </param>
 public Metadata(JToken element, Browser browser, ElementCollection collection)
     : base(element, browser, collection)
 {
 }
Example #44
0
 public LogonForm(Browser browser) : base(browser)
 {
 }
Example #45
0
 public void Open(string username, string password)
 {
     //Browser.GoTo($"http://{username}:{password}@the-internet.herokuapp.com/basic_auth");
     Browser.GoTo(string.Format("http://{0}:{1}@the-internet.herokuapp.com/basic_auth", username, password));
 }
Example #46
0
 public static int IndexOf(this UserAgent agent, Browser browser)
 => agent.IndexOf(browser.ToString());
Example #47
0
 private void SetValue(string elementId, string value)
 {
     var element = Browser.FindElement(By.Id(elementId));
     element.Clear();
     element.SendKeys(value);
 }
 public override void Start(Browser browser)
 {
     Console.WriteLine($"Start browser = {Enum.GetName(typeof(Browser), browser)}");
     Driver?.Start(browser);
 }
 /// <summary>
 /// 构造方法
 /// </summary>
 /// <param name="browser">浏览器</param>
 /// <param name="option">选项</param>
 public WebDriverDownloader(Browser browser, Option option) : this(browser, null, 200, option)
 {
 }
 public UnityBrowserFunctionSet(Browser browser)
 {
     _browser = browser;
 }
Example #51
0
 public PulseForm() : base(By.XPath("//div[@class='pulse-sections']"), "Pulse Page")
 {
     PageFactory.InitElements(Browser.GetDriver(), this);
 }
Example #52
0
 public void Dispose()
 {
     // Make the tests run faster by navigating back to the home page when we are done
     // If we don't, then the next test will reload the whole page before it starts
     Browser.FindElement(By.LinkText("Home")).Click();
 }
Example #53
0
 private void SignInAs(string usernName, string roles, bool useSeparateTab = false) =>
 Browser.SignInAs(new Uri(_serverFixture.RootUri, "/subdir"), usernName, roles, useSeparateTab);
Example #54
0
        public void FullE2eTest()
        {
            Browser.Manage().Window.FullScreen();
            Navigate("/login");
            DisableRecaptcha();
            Assert.Equal("TOSS", Browser.Title);
            //load and redirect to /login
            _webDriveWaitDefault.Until(b => b.FindElement(By.Id("NewEmail")) != null);

            //subscribe
            Browser.FindElement(By.Id("NewEmail")).SendKeys(SubscribeEmail);
            Browser.FindElement(By.Id("NewName")).SendKeys(SubscribeLogin);
            Browser.FindElement(By.Id("NewPassword")).SendKeys(SubscribePassword);
            Browser.FindElement(By.Id("NewConfirmPassword")).SendKeys(SubscribePassword);
            Browser.FindElement(By.Id("BtnRegister")).Click();
            _webDriveWaitDefault.Until(b => b.FindElement(By.Id("NewEmail")).GetAttribute("value") == "");

            //validate subscription
            var confirmationLink = _serverFixture.EmailSender.GetConfirmationLink(SubscribeEmail);

            Browser.Navigate().GoToUrl(confirmationLink);
            DisableRecaptcha();
            _webDriveWaitDefault.Until(b => b.Url.EndsWith("/login"));

            //log in
            Browser.FindElement(By.Id("UserName")).SendKeys(SubscribeLogin);
            Browser.FindElement(By.Id("Password")).SendKeys(SubscribePassword);
            Browser.FindElement(By.Id("BtnLogin")).Click();
            _webDriveWaitDefault.Until(b => b.Url.EndsWith("/"));

            //publish toss
            Browser.FindElement(By.Id("BtnOpenNewToss")).Click();
            _webDriveWaitDefault.Until(b => b.FindElement(By.Id("TxtNewToss")).Displayed);
            string newTossContent = @"lorem ipsum lorem ipsumlorem ipsum lorem ipsumlorem ipsum lorem ipsumlorem ipsum lorem ipsum #test";

            Browser.FindElement(By.Id("TxtNewToss")).SendKeys(newTossContent);
            Browser.FindElement(By.Id("BtnNewToss")).Click();
            _webDriveWaitDefault.Until(b => !b.FindElements(By.CssSelector(".modal-backdrop")).Any());

            //add new toss x 2
            Browser.FindElement(By.Id("BtnOpenNewToss")).Click();
            _webDriveWaitDefault.Until(b => b.FindElement(By.Id("TxtNewToss")).Displayed);
            Browser.FindElement(By.Id("TxtNewToss")).SendKeys(@" lorem ipsum lorem ipsumlorem ipsum lorem ipsumlorem ipsum  lorem ipsumlorem ipsum lorem ipsum #toto");
            Browser.FindElement(By.Id("BtnNewToss")).Click();
            _webDriveWaitDefault.Until(b => !b.FindElements(By.CssSelector(".modal-backdrop")).Any());

            //add new hashtag
            Browser.FindElement(By.Id("TxtAddHashTag")).SendKeys(@"test");
            Browser.FindElement(By.Id("BtnAddHashTag")).Click();
            _webDriveWaitDefault.Until(b => b.FindElements(By.CssSelector(".tag-link")).Any());

            //filter on hashtag
            Browser.FindElement(By.CssSelector(".tag-link")).Click();
            _webDriveWaitDefault.Until(b => b.FindElement(By.CssSelector(".toss .card-text")).Text == newTossContent);

            //sign out

            Browser.FindElement(By.Id("LinkLogout")).Click();
            _webDriveWaitDefault.Until(b => b.Url.EndsWith("/login"));
            //reset password
            //click reset link
            //do reset password
            //connect
        }
Example #55
0
 public void HasHeading()
 {
     Assert.Equal("Hello, world!", Browser.FindElement(By.TagName("h1")).Text);
 }