public void FrameSwitchingUsingElementReference()
        {
            IBrowser b = new BrowserWrapper(new Browser(Helper.GetAllways200RequestMocker(
                                                            new List <Tuple <string, string> >()
            {
                Tuple.Create("^/frame", "<html></html>"),
                Tuple.Create("^.*", @"
										<html>
											<body>
												<iframe src=""/frame""/><iframe src=""/frame""/>
											</body>
										</html>"                                        ),
            }
                                                            )));
            var dr = new SimpleBrowserDriver((IBrowser)b);

            b.Navigate("http://blah/");

            //traverse document to init
            var test = dr.FindElement(By.TagName("body"));

            Assert.That(test.TagName == "body");

            Assert.That(dr.WindowHandles.Count >= 3);
            var iframe     = dr.FindElement(By.TagName("iframe"));
            var firstFrame = dr.SwitchTo().Frame(iframe);

            Assert.That(firstFrame.Url == "http://blah/frame");
        }
Esempio n. 2
0
        public void ElementWaitForTimeoutTest()
        {
            var browser = new BrowserWrapper(new MockIWebDriver(), new MockITestBase(), new ScopeOptions());
            var element = new ElementWrapper(new MockIWebElement(), browser);

            element.WaitFor(elm => false, 2000, "test timeouted");
        }
Esempio n. 3
0
        public void BrowserWaitForTimeoutTest2()
        {
            var browser = new BrowserWrapper(new MockIWebDriver(), new MockITestBase(), new ScopeOptions());
            var i       = 0;

            browser.WaitFor(() => i++ == 5, 2000, "test timeouted");
        }
Esempio n. 4
0
 private static void ChangeAndTestLocalization(BrowserWrapper browser)
 {
     browser.First("p").CheckIfInnerTextEquals("This comes from resource file!", false, true);
     // change language
     browser.Last("a").Click();
     browser.First("p").CheckIfInnerTextEquals("Tohle pochází z resource souboru!", false, true);
 }
        public void ClosingWindows()
        {
            IBrowser b = new BrowserWrapper(new Browser(Helper.GetAllways200RequestMocker(
                                                            new List <Tuple <string, string> >()
            {
                Tuple.Create("^/otherpage", "<html></html>"),
                Tuple.Create("^.*", @"
										<html>
											<a href=""/otherpage"" target=""_blank"" id=""blanklink"">click</a>
										</html>"                                        ),
            }
                                                            )));
            var dr = new SimpleBrowserDriver((IBrowser)b);

            dr.Navigate().GoToUrl("http://blah/");
            dr.FindElement(By.Id("blanklink")).Click();
            Assert.That(dr.Url == "http://blah/");
            Assert.That(dr.WindowHandles.Count == 2);
            string otherWindowName = dr.WindowHandles.First(n => n != dr.CurrentWindowHandle);
            var    otherDr         = dr.SwitchTo().Window(otherWindowName);

            Assert.That(otherDr.Url == "http://blah/otherpage");

            // Now we will close the first window and see that everything behaves as expected
            dr.Close();
            Assert.That(otherDr.WindowHandles.Count == 1);
            Assert.That(otherDr.Url == "http://blah/otherpage");             // still there
            Assert.Throws <ObjectDisposedException>(() => { var a = dr.Url; });
        }
Esempio n. 6
0
        public void OpeningOtherWindows()
        {
            IBrowser b = new BrowserWrapper(new Browser(Helper.GetAllways200RequestMocker(
                                                            new List <Tuple <string, string> >()
            {
                Tuple.Create("^/otherpage", "<html></html>"),
                Tuple.Create("^.*", @"
										<html>
											<a href=""/otherpage"" target=""_blank"" id=""blanklink"">click</a>
										</html>"                                        ),
            }
                                                            )));
            var dr = new SimpleBrowserDriver((IBrowser)b);

            dr.Navigate().GoToUrl("http://blah/");
            dr.FindElement(By.Id("blanklink")).Click();
            Assert.That(dr.Url == "http://blah/");
            Assert.That(dr.WindowHandles.Count == 2);
            string otherWindowName = dr.WindowHandles.First(n => n != dr.CurrentWindowHandle);
            var    otherDr         = dr.SwitchTo().Window(otherWindowName);

            Assert.That(otherDr.Url == "http://blah/otherpage");

            // click it again will create a thrid window
            dr.FindElement(By.Id("blanklink")).Click();
            Assert.That(dr.Url == "http://blah/");
            Assert.That(dr.WindowHandles.Count == 3);
        }
Esempio n. 7
0
        public void CheckIfTagName_ArrayTest3()
        {
            var driverMock = new MockIWebDriver { FindElementsAction = () => new List<IWebElement>() { new MockIWebElement() { TagName = "a" } } };
            var browser = new BrowserWrapper(driverMock, new MockITestBase(), new ScopeOptions());

            var element = browser.First("a");
            element.CheckIfTagName(new[] { "frame", "iframe" });
        }
Esempio n. 8
0
        public void BrowserWaitForTimeoutTest5()
        {
            var browser = new BrowserWrapper(new MockIWebDriver(), new MockITestBase(), new ScopeOptions());

            browser.WaitFor(new Action(() =>
            {
                throw new Exception("Condition is not valid.");
            }), 2000, "test timeouted", checkInterval: 100);
        }
Esempio n. 9
0
        public static void  CheckArticleCount(BrowserWrapper browser, string repeaterUiId, int expectedCount)
        {
            var articles = browser.First($"div[data-ui='{repeaterUiId}']").FindElements("article[data-ui='test-article']");

            if (articles.Count != expectedCount)
            {
                throw new UnexpectedElementStateException($"There should be only 2 article in the repeater. There are {articles.Count}");
            }
        }
Esempio n. 10
0
        private void TestLinkButton(BrowserWrapper browser, string id, bool shouldBeEnabled, ref int currentPresses)
        {
            browser.First($"#{id}").Click();
            if (shouldBeEnabled)
            {
                currentPresses++;
            }

            browser.First("#linkbuttons-pressed").CheckIfInnerTextEquals(currentPresses.ToString());
        }
Esempio n. 11
0
        public async Task Source(string url)
        {
            var browser = new BrowserWrapper();

            browser.OpenUrl(url);
            string pageSrc = await browser.Page.GetSourceAsync();

            Console.WriteLine(pageSrc);
            await File.WriteAllTextAsync(@"C:\_temp\cef.txt", pageSrc);
        }
Esempio n. 12
0
        private void CheckSelectAllOnFocus(BrowserWrapper browser, string textBoxDataUi, bool isSelectAllOnFocusTrue = true)
        {
            var textBox = browser.Single(textBoxDataUi, this.SelectByDataUi);

            textBox.Click();
            var selectedText = (string)browser.GetJavaScriptExecutor().ExecuteScript("return window.getSelection().toString();");
            var expectedText = isSelectAllOnFocusTrue ? "Testing text" : "";

            Assert.AreEqual(expectedText, selectedText);
        }
 public static bool IsDotvvmPage(this BrowserWrapper browser)
 {
     try
     {
         return(string.Equals("true",
                              browser.GetJavaScriptExecutor().ExecuteScript("return dotvvm instanceof DotVVM").ToString(),
                              StringComparison.OrdinalIgnoreCase));
     }
     catch (Exception ex)
     {
         return(false);
     }
 }
Esempio n. 14
0
        private void CheckTableRow(BrowserWrapper browser, int row)
        {
            var table = browser.Single("table");

            // get expected value - last column
            var value = table.ElementAt("tr", row).ElementAt("td", 3).GetInnerText();

            // check other columns to contain same value
            table.ElementAt("tr", row).ElementAt("td", 1).CheckIfInnerTextEquals(value, false);
            table.ElementAt("tr", row).ElementAt("td", 2).CheckIfInnerTextEquals(value, false);

            // server binding renders True with capital T, knockout binding renders true with lower case t -> comparison is case insensitive
        }
Esempio n. 15
0
        public void BrowserWaitForTimeoutTest6()
        {
            var browser = new BrowserWrapper(new MockIWebDriver(), new MockITestBase(), new ScopeOptions());
            var i = 0;
            browser.WaitFor(() =>
            {

                if (i++ == 3)
                {
                    return;
                }
                throw new Exception("Not valid.");
            }, 2000, "test timeouted", checkInterval: 100);
        }
Esempio n. 16
0
        private static void PerformSelect2Test(BrowserWrapper browser, ElementWrapper fieldset)
        {
            var select2               = fieldset.Single(".select2");
            var input                 = select2.First("input");
            var result                = fieldset.Single(".result");
            var addItemsButton        = fieldset.ElementAt("button", 0);
            var changeSelectionButton = fieldset.ElementAt("button", 1);
            var submitButton          = fieldset.ElementAt("button", 2);

            // verify the selection at the beginning
            select2.FindElements("li").ThrowIfDifferentCountThan(2);
            result.CheckIfTextEquals("Prague");

            // append tag
            input.SendKeys("Ne");
            input.SendKeys(Keys.Return);
            select2.FindElements("li").ThrowIfDifferentCountThan(3);

            // submit and check the selection on the server
            submitButton.Click().Wait();

            // verify the new tag appeared in the result
            result.CheckIfTextEquals("Prague,New York");

            // check the items offered in the list
            input.Click().Wait();
            browser.FindElements(".select2-container--open li.select2-results__option").ThrowIfDifferentCountThan(4);
            fieldset.Click();

            // add new items to the collection
            addItemsButton.Click().Wait();

            // check the items offered in the list were updated
            input.Click().Wait();
            browser.FindElements(".select2-container--open li.select2-results__option").ThrowIfDifferentCountThan(5);

            // select last item from the list
            browser.Last(".select2-container--open li.select2-results__option").Click();

            // submit and check the selection on the server
            submitButton.Click().Wait();
            result.CheckIfTextEquals("Prague,New York,Berlin");

            // replace the selection on server
            changeSelectionButton.Click().Wait();
            submitButton.Click().Wait();
            result.CheckIfTextEquals("New York,Paris");
        }
Esempio n. 17
0
        private void CheckSeparators(BrowserWrapper browser, string repeaterDataUi)
        {
            var repeater = browser.Single(repeaterDataUi, this.SelectByDataUi);

            for (int i = 0; i < repeater.Children.Count; i++)
            {
                if (i % 2 == 0)
                {
                    repeater.Children[i].CheckAttribute("data-ui", s => s == "item");
                }
                else
                {
                    repeater.Children[i].CheckAttribute("data-ui", s => s == "separator");
                }
            }
        }
Esempio n. 18
0
        public void CheckIfTagName_ArrayTest2()
        {
            var driverMock = new MockIWebDriver {
                FindElementsAction = () => new List <IWebElement>()
                {
                    new MockIWebElement()
                    {
                        TagName = "iframe"
                    }
                }
            };
            var browser = new BrowserWrapper(driverMock, new MockITestBase(), new ScopeOptions());

            var element = browser.First("iframe");

            element.CheckIfTagName(new[] { "frame", "iframe" });
        }
        public void CheckIfTagName_ArrayTest3()
        {
            var driverMock = new MockIWebDriver {
                FindElementsAction = () => new List <IWebElement>()
                {
                    new MockIWebElement()
                    {
                        TagName = "a"
                    }
                }
            };
            var browser = new BrowserWrapper(driverMock, new MockISeleniumTest(), new ScopeOptions());

            var element = browser.First("a");

            AssertUI.CheckIfTagName(element, new[] { "frame", "iframe" });
        }
Esempio n. 20
0
        private void CheckRadioButtonsState(BrowserWrapper browser, RadioButtonValues selectedColor)
        {
            var radios = new List <ElementWrapper>();

            radios.Add(browser.Single("radio-red", this.SelectByDataUi));
            radios.Add(browser.Single("radio-green", this.SelectByDataUi));
            radios.Add(browser.Single("radio-blue", this.SelectByDataUi));
            var selectedColorElement = browser.Single("selected-color", this.SelectByDataUi);

            int checkedRadioIndex = (int)selectedColor;

            radios[checkedRadioIndex].CheckIfIsChecked();
            radios.RemoveAt(checkedRadioIndex);
            radios.ForEach(r => r.CheckIfIsNotChecked());

            selectedColorElement.CheckIfTextEquals(selectedColor.ToString().ToLower());
        }
        override public void UpdateSettings()
        {
            browserConfig.Reload(configElement);

            // unscaled w/h
            Size.X = (float)browserConfig.BrowserSourceSettings.Width;
            Size.Y = (float)browserConfig.BrowserSourceSettings.Height;

            outputColor = 0xFFFFFF | (((uint)(browserConfig.BrowserSourceSettings.Opacity * 255) & 0xFF) << 24);

            if (browser != null)
            {
                browser.CloseBrowser(true);
                browser = null;
            }

            browser = new BrowserWrapper();
            browser.CreateBrowser(this, browserConfig);
        }
Esempio n. 22
0
 protected virtual void Dispose(bool disposing)
 {
     if (disposing)
     {
         // remove any pending texture requests
         lock (pendingTextureLock)
         {
             if (pendingTexture != null && pendingTexture.Texture != null)
             {
                 pendingTexture.Texture.Dispose();
             }
             pendingTexture = null;
         }
         if (browser != null)
         {
             browser.CloseBrowser(true);
             browser = null;
         }
     }
 }
Esempio n. 23
0
        public QCmdHostForm(QcmdConfig config)
        {
            _config = config;

            InitializeComponent();

            _hook             = new KeyboardHook();
            _hook.KeyPressed += KeyPressed;

            _hook.RegisterHotKey(KeyboardHook.ModifierKeys.Win, Keys.Q);
            _hook.RegisterHotKey(KeyboardHook.ModifierKeys.Control | KeyboardHook.ModifierKeys.Alt, Keys.NumPad8);

            _browser = new BrowserWrapper(config.StartPage);
            _browser.HideCallback = ThreadedHide;
            Controls.Add(_browser.Control);

            Closed += (o, s) => CefSharp.Cef.Shutdown();

            CenterToScreen();
            Location = new Point(Location.X, 0);
        }
Esempio n. 24
0
        private void ShowHideControl(BrowserWrapper browser)
        {
            // verify the second pager is hidden
            browser.First(".pagination").CheckIfIsDisplayed();
            browser.ElementAt(".pagination", 1).CheckIfIsNotDisplayed();
            browser.First("ul").FindElements("li").ThrowIfDifferentCountThan(2);
            // verify the second pager appears
            browser.Single("populate-button", this.SelectByDataUi).Click();

            // verify the second pager appears
            browser.First(".pagination").CheckIfIsDisplayed();
            browser.ElementAt(".pagination", 1).CheckIfIsDisplayed();
            browser.First("ul").FindElements("li").ThrowIfDifferentCountThan(3);

            // switch to another page
            browser.First(".pagination").ElementAt("li a", 4).Click();

            // verify the second pager is still visible
            browser.First(".pagination").CheckIfIsDisplayed();
            browser.ElementAt(".pagination", 1).CheckIfIsDisplayed();
            browser.First("ul").FindElements("li").ThrowIfDifferentCountThan(3);
        }
Esempio n. 25
0
        public void IframesShouldLoad()
        {
            IBrowser b = new BrowserWrapper(new Browser(Helper.GetAllways200RequestMocker(
                                                            new List <Tuple <string, string> >()
            {
                Tuple.Create("^/frame", "<html></html>"),
                Tuple.Create("^.*", @"
										<html>
											<iframe src=""/frame""/><iframe src=""/frame""/>
										</html>"                                        ),
            }
                                                            )));
            var dr = new SimpleBrowserDriver((IBrowser)b);

            b.Navigate("http://blah/");
            var test = dr.FindElement(By.TagName("html"));

            Assert.That(dr.WindowHandles.Count == 3);
            var firstFrame = dr.SwitchTo().Frame(0);

            Assert.IsNull(firstFrame.FindElement(By.TagName("iframe")));
        }
Esempio n. 26
0
        private void ReturnedFileDownload(BrowserWrapper browser, string fileContent)
        {
            browser.NavigateToUrl(SamplesRouteUrls.FeatureSamples_ReturnedFile_ReturnedFileSample);
            var jsexec = browser.GetJavaScriptExecutor();

            jsexec.ExecuteScript("var downloadURL = \"\";");
            jsexec.ExecuteScript("DotVVM.prototype.performRedirect = function(url){downloadURL = url};");

            browser.First("textarea").SendKeys(fileContent);
            browser.First("input").SendKeys(Keys.Enter);
            var downloadURL = (string)jsexec.ExecuteScript("return downloadURL");

            Assert.IsNotNull(downloadURL);

            string returnedFile;

            using (var client = new WebClient())
            {
                returnedFile = client.DownloadString(browser.GetAbsoluteUrl(downloadURL));
            }
            Assert.AreEqual(fileContent, returnedFile);
        }
Esempio n. 27
0
        private static void Feature_StaticCommand_ComboBoxSelectionChangedViewModel_Core(BrowserWrapper browser)
        {
            browser.Wait();

            // select second value in the first combo box, the second one should select the second value too
            browser.ElementAt("select", 0).Select(1).Wait();
            browser.ElementAt("select", 0).ElementAt("option", 1).CheckIfIsSelected();
            browser.ElementAt("select", 1).ElementAt("option", 1).CheckIfIsSelected();

            // select third value in the first combo box, the second one should select the third value too
            browser.ElementAt("select", 0).Select(2).Wait();
            browser.ElementAt("select", 0).ElementAt("option", 2).CheckIfIsSelected();
            browser.ElementAt("select", 1).ElementAt("option", 2).CheckIfIsSelected();

            // select first value in the first combo box, the second one should select the first value too
            browser.ElementAt("select", 0).Select(0).Wait();
            browser.ElementAt("select", 0).ElementAt("option", 0).CheckIfIsSelected();
            browser.ElementAt("select", 1).ElementAt("option", 0).CheckIfIsSelected();

            // click the first button - the second value should be selected in the first select, the second select should not change
            browser.ElementAt("input", 0).Click().Wait();
            browser.ElementAt("select", 0).ElementAt("option", 1).CheckIfIsSelected();
            browser.ElementAt("select", 1).ElementAt("option", 0).CheckIfIsSelected();

            // click the second button - the third value should be selected in the second select, the first select should not change
            browser.ElementAt("input", 1).Click().Wait();
            browser.ElementAt("select", 0).ElementAt("option", 1).CheckIfIsSelected();
            browser.ElementAt("select", 1).ElementAt("option", 2).CheckIfIsSelected();

            // click the third button - the first value should be selected in the second select, the first select should not change
            browser.ElementAt("input", 2).Click().Wait();
            browser.ElementAt("select", 0).ElementAt("option", 1).CheckIfIsSelected();
            browser.ElementAt("select", 1).ElementAt("option", 0).CheckIfIsSelected();
        }
Esempio n. 28
0
 public void ElementWaitForTimeoutTest()
 {
     var browser = new BrowserWrapper(new MockIWebDriver(), new MockITestBase(), new ScopeOptions());
     var element = new ElementWrapper(new MockIWebElement(), browser);
     element.WaitFor(elm => false, 2000, "test timeouted");
 }
Esempio n. 29
0
        public void PathAndHostUrlMatchTest4()
        {
            var browser = new BrowserWrapper(new MockIWebDriver(), new MockITestBase(), new ScopeOptions());

            browser.CheckUrl("//localhosta/path1/path2", UrlKind.Absolute, UriComponents.Path, UriComponents.Host);
        }
 public void SchemaUrlMatchTest2()
 {
     var browser = new BrowserWrapper(new MockIWebDriver(), new MockITestBase(), new ScopeOptions());
     browser.CheckUrl("http://ex.com/", UrlKind.Absolute, UriComponents.Scheme);
 }
Esempio n. 31
0
 public void ElementWaitForTimeoutTest5()
 {
     var browser = new BrowserWrapper(new MockIWebDriver(), new MockITestBase(), new ScopeOptions());
     var element = new ElementWrapper(new MockIWebElement(), browser);
     var i = 0;
     element.WaitFor((elm) => elm.CheckIfValue("asdasdasdasd"), 2000, "test timeouted", checkInterval: 100);
 }
Esempio n. 32
0
 private void CheckTreeItems(BrowserWrapper browser, int level, int count)
 {
     browser.FindElements($"[data-ui='offset_{level}']").ThrowIfDifferentCountThan(count);
 }
 public void PathUrlMatchTest2()
 {
     var browser = new BrowserWrapper(new MockIWebDriver(), new MockITestBase(), new ScopeOptions());
     browser.CheckUrl("/path1/path2", UrlKind.Relative, UriComponents.Path);
 }
 public void PathUrlMatchTest4()
 {
     var browser = new BrowserWrapper(new MockIWebDriver(), new MockITestBase(), new ScopeOptions());
     browser.CheckUrl("https://localhost:12345/path1/path2/nonon", UrlKind.Absolute, UriComponents.Path);
 }
Esempio n. 35
0
 public static ElementWrapperCollection ToElementsList(this IEnumerable<IWebElement> elements, BrowserWrapper browserWrapper, string selector, ElementWrapper elementWrapper)
 {
     return new ElementWrapperCollection(elements.Select(s => new ElementWrapper(s, browserWrapper)), selector, elementWrapper, browserWrapper);
 }
 public void PathHostAndPortUrlMatchTest()
 {
     var browser = new BrowserWrapper(new MockIWebDriver(), new MockITestBase(), new ScopeOptions());
     browser.CheckUrl("//localhost:12345/path1/path2", UrlKind.Absolute, UriComponents.Path, UriComponents.HostAndPort);
 }
 public void HostUrlMatchTest2()
 {
     var browser = new BrowserWrapper(new MockIWebDriver(), new MockITestBase(), new ScopeOptions());
     browser.CheckUrl("https://localhosst:12345/", UrlKind.Absolute, UriComponents.Host);
 }
 public void FragmentUrlMatchTest2()
 {
     var browser = new BrowserWrapper(new MockIWebDriver(), new MockITestBase(), new ScopeOptions());
     browser.CheckUrl("#fragment", UrlKind.Relative, UriComponents.Fragment);
 }
 public void ExactUrlMatchTest2()
 {
     var browser = new BrowserWrapper(new MockIWebDriver(), new MockITestBase(), new ScopeOptions());
     browser.CheckUrlEquals("https://localhost:12345/spath1/path2?query=1#fragment");
 }
Esempio n. 40
0
 public void ElementWaitForTimeoutTest4()
 {
     var browser = new BrowserWrapper(new MockIWebDriver(), new MockITestBase(), new ScopeOptions());
     var element = new ElementWrapper(new MockIWebElement(), browser);
     var i = 0;
     element.WaitFor(elm => i++ == 5, 2000, "test timeouted", checkInterval: 100);
 }
Esempio n. 41
0
 public void BrowserWaitForTimeoutTest3()
 {
     var browser = new BrowserWrapper(new MockIWebDriver(), new MockITestBase(), new ScopeOptions());
     var i = 0;
     browser.WaitFor(() => i++ == 5, 2000, "test timeouted", checkInterval: 100);
 }
Esempio n. 42
0
        public void PathUrlMatchTest4()
        {
            var browser = new BrowserWrapper(new MockIWebDriver(), new MockITestBase(), new ScopeOptions());

            browser.CheckUrl("https://localhost:12345/path1/path2/nonon", UrlKind.Absolute, UriComponents.Path);
        }
Esempio n. 43
0
 public void BrowserWaitForTimeoutTest()
 {
     var browser = new BrowserWrapper(new MockIWebDriver(), new MockITestBase(), new ScopeOptions());
     browser.WaitFor(() => false, 2000, "test timeouted");
 }
Esempio n. 44
0
        public void PathUrlMatchTest()
        {
            var browser = new BrowserWrapper(new MockIWebDriver(), new MockITestBase(), new ScopeOptions());

            browser.CheckUrl("/path1/path2", UrlKind.Relative, UriComponents.Path);
        }
 public void QueryUrlMatchTest2()
 {
     var browser = new BrowserWrapper(new MockIWebDriver(), new MockITestBase(), new ScopeOptions());
     browser.CheckUrl("?query=1", UrlKind.Relative, UriComponents.Query);
 }
Esempio n. 46
0
 private void Control_GridViewShowHeaderWhenNoData(BrowserWrapper browser)
 {
     browser.FindElements("[data-ui='ShowHeaderWhenNoDataGrid']").FindElements("th").First().IsDisplayed();
 }
 private static void CheckIfInnerTextEqualsToOne(BrowserWrapper browser, string dataUi)
 {
     browser.FindElements($"[data-ui='{dataUi}']").First().CheckIfInnerTextEquals(1.ToString());
 }
 public void CompareUrlTest()
 {
     var browser = new BrowserWrapper(new MockIWebDriver(), new MockITestBase(), new ScopeOptions());
     Assert.IsTrue(browser.CompareUrl("//localhost:12345", UrlKind.Absolute, UriComponents.Port));
 }