Beispiel #1
0
        internal static void SwitchTo(WebPage webPage)
        {
            BrowserHoster   browser   = BrowserHoster.getInstance();
            RemoteWebDriver webDriver = browser.WebDriver;

            if (string.IsNullOrEmpty(webPage.WindowHandle))
            {
                browser.SwitchToURL(webPage.RelayObject.Properties[WebControlKeys.URL]);
                webPage.WindowHandle = webDriver.CurrentWindowHandle;
                return;
            }
            if (webPage.WindowHandle.Equals(webDriver.CurrentWindowHandle))
            {
                return;
            }

            try
            {
                webDriver.SwitchTo().Window(webPage.WindowHandle);
            }
            catch (OpenQA.Selenium.NoSuchWindowException)
            {
                browser.SwitchToURL(webPage.RelayObject.Properties[WebControlKeys.URL]);
                webPage.WindowHandle = webDriver.CurrentWindowHandle;
            }
        }
        public virtual void Drop(int x = -1, int y = -1)
        {
            ActionsHelper actionsHelper = ActionsHelper.getInstance();

            actionsHelper.Drop(RelayObject.SEWebElement, x, y);
            bool droppable = Convert.ToBoolean(BrowserHoster.getInstance().WebDriver.ExecuteScript(_jsDrop, RelayObject.SEWebElement));

            if (!droppable)
            {
                actionsHelper.Drop(RelayObject.SEWebElement, x, y);
            }
        }
        protected T GetTo <T>(string nodeName) where T : IWebElement, new()
        {
            IWebElement webElement = _ccs[nodeName];

            if (webElement == null)
            {
                AppModel     model = AppModel.Current;
                SETestObject seTO  = model.GetTestObject(nodeName) as SETestObject;
                seTO.WebDriver         = BrowserHoster.getInstance().WebDriver;
                webElement             = new T();
                webElement.RelayObject = seTO;
            }
            return((T)webElement);
        }
        public virtual void DragAndDrop(IWebElement target)
        {
            ActionsHelper    actionsHelper = ActionsHelper.getInstance();
            RemoteWebElement webElement    = RelayObject.SEWebElement;
            string           draggable     = webElement.GetAttribute("draggable");

            if (!string.IsNullOrEmpty(draggable) && draggable.ToLower().Equals("true"))
            {
                BrowserHoster.getInstance().WebDriver.ExecuteScript(_jsDnD, RelayObject.SEWebElement, target.RelayObject.SEWebElement);
            }
            else
            {
                actionsHelper.DragAndDrop(RelayObject.SEWebElement, target.RelayObject.SEWebElement);
            }
        }
Beispiel #5
0
 public void Back()
 {
     SwithToMe();
     BrowserHoster.getInstance().WebDriver.Navigate().Back();
 }
Beispiel #6
0
 public void Navigate(string URL)
 {
     SwithToMe();
     BrowserHoster.getInstance().WebDriver.Navigate().GoToUrl(URL);
 }
Beispiel #7
0
 public void Refresh()
 {
     SwithToMe();
     BrowserHoster.getInstance().WebDriver.Navigate().Refresh();
 }
Beispiel #8
0
 public void Forward()
 {
     SwithToMe();
     BrowserHoster.getInstance().WebDriver.Navigate().Forward();
 }