Exemplo n.º 1
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();
        }
 public void SeleniumGracefulMissingBrowserHandling()
 {
     _selenium.SetBrowser("none");
     Assert.IsTrue(string.IsNullOrEmpty(_selenium.PageSource), "PageSource without browser");
     Assert.IsTrue(string.IsNullOrEmpty(_selenium.Title()), "Title without browser");
     Assert.IsFalse(_selenium.Close(), "closing without browser");
     Assert.IsFalse(_selenium.ClosePage(), "close page without browser");
     Assert.IsFalse(_selenium.ElementExists("any"), "Element Exists without browser");
     Assert.AreEqual(0, _selenium.CountOfElements("any"), "Count Of Elements without browser");
     Assert.IsTrue(string.IsNullOrEmpty(_selenium.Title()), "Title without browser");
     try
     {
         _selenium.Open(new Uri("http://localhost"));
         Assert.Fail("No exception thrown for Open without browser");
     }
     catch (StopTestException)
     {
     }
 }
        public void SeleniumIeTest()
        {
            var selenium = new Selenium();
            var options  = Selenium.NewOptionsFor("ie") as InternetExplorerOptions;

            Assert.IsNotNull(options, "Options is not null");
            Console.WriteLine(options.ToString());
            selenium.SetBrowserWithOptions("ie", options);
            selenium.Open(new Uri("http://www.google.com?hl=en"));
            selenium.Close();
        }
Exemplo n.º 4
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();
     }
 }
Exemplo n.º 5
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();
        }
 public void ExtractTableValuesCleanup() => _selenium.Close();
Exemplo n.º 8
0
 public void afterClass()
 {
     Driver.Close();
     Selenium.Close();
 }
 public void SeleniumTestCleanup()
 {
     _selenium.Close();
     Selenium.SetProxyType("System");
 }