Пример #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();
        }