public void ExtractTableValuesSimpleTest()
        {
            _selenium.SetBrowser("chrome");
            _selenium.Open(EndToEndTest.CreateTestPageUri());
            // Tricky stuff happening here - attempts to logon behind the scenes
            _selenium.WaitUntilTitleMatches("SeleniumFixtureTestPage");
            TestTable("XPath://table[@id='normalTable']", 0, new[]
            {
                new[] { new[] { "header1", "value 1" }, new[] { "header2", "10" } },
                new[] { new[] { "header1", "value 2" }, new[] { "header2", "20" } },
                new[] { new[] { "header1", "value 3" }, new[] { "header2", "30" } }
            });

            TestTable("CssSelector: table#tableWithoutHeaders", 0, new[]
            {
                new[] { new[] { "Column 1", "value 4" }, new[] { "Column 2", "40" } },
                new[] { new[] { "Column 1", "value 5" }, new[] { "Column 2", "50" } }
            });

            TestTable("id:tableWithEmptyHeaders", 0, new[]
            {
                new[] { new[] { "Column 1", "value 6" }, new[] { "Column 2", "60" } },
                new[] { new[] { "Column 1", "value 7" }, new[] { "Column 2", "70" } }
            });
        }
Exemple #2
0
        public void DragDropAcrossWindowsTest()
        {
            var driverHandle1 = _selenium.NewBrowser("chrome");
            var url           = EndToEndTest.CreateTestPageUri();

            _selenium.Open(url);
            Assert.IsTrue(_selenium.WaitForElement("dragSource"), "Wait for DragSource in browser 1");
            Assert.IsFalse(_selenium.ElementExists("CssSelector: div#dropTarget > #dragSource"), "Source not dropped in target in driver 1");
            var driver1 = _selenium.Driver;
            var target  = driver1.FindElement(By.Id("dropTarget"));

            var driverHandle2 = _selenium.NewBrowser("chrome");

            _selenium.Open(url);
            Assert.IsTrue(_selenium.WaitForElement("dragSource"), "Wait for DragSource in browser 2");
            var driver2 = _selenium.Driver;
            var source  = driver2.FindElement(By.Id("dragSource"));

            Assert.AreNotEqual(driver1, driver2, "We have two different drivers");

            DragDrop.DragToWindow(driver2, source, driver1, target);
            Assert.IsFalse(_selenium.ElementExists("CssSelector: div#dropTarget > #dragSource"), "Source not dropped in target in driver 2");

            _selenium.SetDriver(driverHandle1);
            Assert.IsTrue(_selenium.ElementExists("CssSelector: div#dropTarget > #dragSource"), "Source was dropped in target in driver 1");
            _selenium.Close();

            _selenium.SetDriver(driverHandle2);
            _selenium.Close();
        }
Exemple #3
0
 public void KeyConverterTestInSelenium()
 {
     try
     {
         _selenium.SetTimeoutSeconds(20);
         Assert.IsTrue(_selenium.SetBrowser("chrome"));
         Assert.IsTrue(_selenium.Open(EndToEndTest.CreateTestPageUri()));
         Assert.IsTrue(_selenium.WaitForElement("text1"));
         Assert.IsTrue(_selenium.SetElementTo("text1", new KeyConverter("^a").ToSeleniumFormat), "Text 1");
         Assert.IsTrue(_selenium.SetElementTo("text1", new KeyConverter("^c").ToSeleniumFormat), "Text 1");
         Assert.IsTrue(_selenium.SetElementTo("text1", new KeyConverter("{DEL}").ToSeleniumFormat), "Text 1");
         Assert.IsTrue(_selenium.SetElementTo("text1", new KeyConverter("My New Text").ToSeleniumFormat), "Text 1");
         Assert.IsTrue(_selenium.SetElementTo("text2", new KeyConverter("^a").ToSeleniumFormat), "Text 2");
         Assert.IsTrue(_selenium.SetElementTo("text2", new KeyConverter("{dEl}^v").ToSeleniumFormat), "Text 2");
     }
     finally
     {
         _selenium.Close();
     }
 }
Exemple #4
0
        public void JavaScriptFunctionTestWithFibonacci()
        {
            // protected mode must be off for this to work in IE
            var selenium = new Selenium();

            try
            {
                Assert.IsTrue(selenium.SetBrowser("firefox"));
                Assert.IsTrue(selenium.Open(EndToEndTest.CreateTestPageUri()));
                selenium.WaitForElement("id:sectionJavaScript");
                var javaScriptFunction = new JavaScriptFunction();
                javaScriptFunction.Reset();
                javaScriptFunction.Set("value", 10);
                Assert.AreEqual(Convert.ToInt64(55), javaScriptFunction.Get("Fibonacci"));
                javaScriptFunction.Reset();
                javaScriptFunction.Set("value", "aq");
                Assert.AreEqual("Input should be numerical", javaScriptFunction.Get("Fibonacci"));
            }
            finally
            {
                Assert.IsTrue(selenium.Close());
            }
        }
        public void SeleniumShowChromeRightClickError()
        {
            var selenium = new Selenium();

            // Chrome cannot interact with context menus. Workaround is using native sendkeys, but we don't want to go there.
            // This test tries to select all in the context meny and then press delete. It just presses delete instead, so the
            // field doesn't get empty. If this test would fail, right click would work
            selenium.SetBrowser("chrome");
            selenium.SetTimeoutSeconds(20);
            const string textboxLocator = "id:text1";

            Assert.IsTrue(selenium.Open(EndToEndTest.CreateTestPageUri()), "Open page");
            Assert.IsTrue(selenium.WaitUntilTitleMatches("Selenium Fixture Test Page"));
            Assert.IsTrue(selenium.RightClickElement(textboxLocator), "Show context menu");
            Selenium.WaitSeconds(0.2); // allow dropdown to expand
            const string selectAllInContextMenuSequence = "{DOWN}a";

            selenium.SendKeysToElement(new KeyConverter(selectAllInContextMenuSequence).ToSeleniumFormat,
                                       textboxLocator);
            selenium.SendKeysToElement("{DELETE}", textboxLocator);
            Assert.IsFalse(string.IsNullOrEmpty(selenium.AttributeOfElement("value", textboxLocator)),
                           "text 1 is empty");
            selenium.Close();
        }
Exemple #6
0
 public void TestInitialize()
 {
     _driverHandle = BrowserDriverContainer.NewDriver("chrome headless", null);
     _driver       = BrowserDriverContainer.Current;
     _driver.Navigate().GoToUrl(EndToEndTest.CreateTestPageUri());
 }
 public void SeleniumIeTimeoutTest()
 {
     Selenium.CommandTimeoutSeconds = 15;
     _selenium.SetBrowser("ie");
     _selenium.Open(EndToEndTest.CreateTestPageUri());
 }