/// <summary>
        /// Zoom at the specified point
        /// </summary>
        /// <param name="x">x screen location</param>
        /// <param name="y">y screen location</param>
        public void Zoom(int x, int y)
        {
            var touchAction1 = new TouchActions(this);
            touchAction1.Down(x, y).Move(x, y - 100).Up(x, y - 100);

            var touchAction2 = new TouchActions(this);
            touchAction2.Down(x, y).Move(x, y + 100).Up(x, y + 100);

            var multiTouchAction = new MultiTouchAction(this);
            multiTouchAction.Add(touchAction1);
            multiTouchAction.Add(touchAction2);
            PerformMultiTouchAction(multiTouchAction);
        }
예제 #2
0
        public void Execute(IDictionary<string, object> variables, Dictionary<string, ObjectInfo> library, string[] parameters)
        {
            Console.WriteLine("DragAndDrop.Execute");

            var browser = (IWebDriver)variables["BrowserInstance"];
            if (browser != null)
            {
                ObjectInfo objInfo = null;
                ObjectInfo objInfo2 = null;
                IWebElement el = null;
                IWebElement el2 = null;

                //Find Element #1
                switch (parameters[0])
                {
                    case "library":
                    {
                        objInfo = library[parameters[1]];

                        break;
                    }
                    default:
                    {
                        objInfo = new ObjectInfo() {Name = "", Type = parameters[0], Value = parameters[1]};
                        break;
                    }
                }

                if (objInfo != null)
                {
                    switch (objInfo.Type)
                    {
                        case "id":
                            el = browser.FindElement(By.Id(objInfo.Value));
                            break;
                        case "xpath":
                            el = browser.FindElement(By.XPath(objInfo.Value));
                            break;
                        case "name":
                            el = browser.FindElement(By.Name(objInfo.Value));
                            break;
                        case "cssselector":
                            el = browser.FindElement(By.CssSelector(objInfo.Value));
                            break;
                        case "classname":
                            el = browser.FindElement(By.ClassName(objInfo.Value));
                            break;
                        case "linktext":
                            el = browser.FindElement(By.LinkText(objInfo.Value));
                            break;
                        case "partiallinktext":
                            el = browser.FindElement(By.PartialLinkText(objInfo.Value));
                            break;
                    }

                    if (el == null) throw new TestingException("Element #1 not found!");
                }
                else throw new TestingException("Element #1 invalid parameters!");

                //find Element #2
                switch (parameters[2])
                {
                    case "library":
                        {
                            objInfo2 = library[parameters[3]];

                            break;
                        }
                    default:
                        {
                            objInfo2 = new ObjectInfo() { Name = "", Type = parameters[2], Value = parameters[3] };
                            break;
                        }
                }

                if (objInfo2 != null)
                {
                    switch (objInfo2.Type)
                    {
                        case "id":
                            el2 = browser.FindElement(By.Id(objInfo2.Value));
                            break;
                        case "xpath":
                            el2 = browser.FindElement(By.XPath(objInfo2.Value));
                            break;
                        case "name":
                            el2 = browser.FindElement(By.Name(objInfo2.Value));
                            break;
                        case "cssselector":
                            el2 = browser.FindElement(By.CssSelector(objInfo2.Value));
                            break;
                        case "classname":
                            el2 = browser.FindElement(By.ClassName(objInfo2.Value));
                            break;
                        case "linktext":
                            el2 = browser.FindElement(By.LinkText(objInfo2.Value));
                            break;
                        case "partiallinktext":
                            el2 = browser.FindElement(By.PartialLinkText(objInfo2.Value));
                            break;
                    }

                    if (el2 == null) throw new TestingException("Element #2 not found!");
                }
                else throw new TestingException("Element #2 invalid parameters!");

                //dragdrop(browser, el, el2);
                var touch = new TouchActions(browser);
                touch.Down(el.Location.X + 5, el.Location.Y + 5).MoveToElement(el2).Release().Build().Perform();
                //Actions myMouse = new Actions(browser);
                //myMouse.MoveToElement(el, 5, 5).ClickAndHold().MoveToElement(el2, 5, 5).Release().Build().Perform();
                ////myMouse.DragAndDrop(el, el2);
            }
            else
            {
                throw new TestingException("Browser Instance not found!");
            }
        }