Пример #1
0
 /// <summary>Sends keys to an element.</summary>
 /// <param name="keys"></param>
 /// <param name="webelement">Element to send keys. If None, send keys to the current mouse position.</param>
 /// <returns></returns>
 public Actions sendKeys(string keys, WebElement webelement = null)
 {
     if (webelement == null)
     {
         _actions.SendKeys(keys);
     }
     else
     {
         _actions.SendKeys(webelement._webElement, keys);
     }
     return(this);
 }
        /// <summary>
        /// Scrolls down a web page using the page down key.
        /// </summary>
        /// <param name="timesToScroll">An abstract quantification of how much to scroll</param>
        public static void ScrollPage(this RemoteWebDriver remoteWebDriver, int timesToScroll)
        {
            // Webdriver examples had scrolling by executing Javascript. That approach seemed troublesome because the
            // browser is scrolling in a way very different from how it would with a real user, so we don't do it.
            // Page down seemed to be the best compromise in terms of it behaving like a real user scrolling, and it
            // working reliably across browsers.
            // Use the page down key.

            var userAction = new OpenQA.Selenium.Interactions.Actions(remoteWebDriver);

            userAction.SendKeys(Keys.PageDown);

            for (int i = 0; i < timesToScroll; i++)
            {
                ScenarioEventSourceProvider.EventLog.ScrollEvent();
                if (remoteWebDriver.ToString().ToLower().Contains("firefoxdriver"))
                {
                    // Send the commands to the body element for Firefox.
                    IWebElement body = remoteWebDriver.FindElementByTagName("body");
                    body.SendKeys(Keys.PageDown);
                }
                else
                {
                    userAction.Perform();
                }
                Thread.Sleep(1000);
            }
        }
Пример #3
0
        protected static void SendKeys(PageElement pageElement, params string[] keys)
        {
            var actions =
                new OpenQA.Selenium.Interactions.Actions(SeleniumDriver.Driver);

            foreach (var key in keys)
            {
                pageElement.GoToFrame();
                actions.SendKeys(SeleniumDriver.Driver.FindElement(pageElement.Locator), key).Build().Perform();
                Thread.Sleep(1000);
            }
        }
Пример #4
0
        public void How_To_Enter_Text_Caps_Lock()
        {
            OpenQA.Selenium.Interactions.Actions action = new OpenQA.Selenium.Interactions.Actions(chromedriver);
            //action.KeyDown(object, "SHIFT");
            action.KeyDown(Keys.Shift);
            action.SendKeys("ab");
            action.Build().Perform();
            string pageTitle = chromedriver.Title;

            //driver.FindElements(By.XPath("")).Count();
            OpenQA.Selenium.Support.UI.SelectElement selectElement = new OpenQA.Selenium.Support.UI.SelectElement(chromedriver.FindElement(By.XPath("")));
            //selectElement.
        }
Пример #5
0
 public void Añadir_producto_circuito_de_capacidad_sin_campos_oblitatorios() //solo vamoa a rellenar el tipo de producto
 {
     Utils.SearchWebElement("Producto.buttonAgregarProducto").Click();       //pulsamos sobre agregar producto
     Thread.Sleep(2000);
     Utils.SearchWebElement("Producto.inputProductoExistente");
     accionesSelenium.SendKeys(Keys.Enter).Perform();
     Thread.Sleep(2000);
     accionesSelenium.SendKeys(Keys.ArrowDown).Perform();
     accionesSelenium.SendKeys(Keys.Enter).Perform();
     Utils.SearchWebElement("Producto.buttonGuardaryCerrar").Click();//Guarda y cierra
 }
 /// <summary>
 /// Sends keystrokes to the browser. Not to a specific element.
 /// </summary>
 /// <param name="keys">Keystrokes to send to the browser.</param>
 public static void SendKeys(this RemoteWebDriver remoteWebDriver, string keys)
 {
     ScenarioEventSourceProvider.EventLog.SendKeysStart(keys.Length);
     // Firefox driver does not currently support sending keystrokes to the browser.
     // So instead, get the body element and send the keystrokes to that element.
     if (remoteWebDriver.ToString().ToLower().Contains("firefoxdriver"))
     {
         IWebElement body = remoteWebDriver.FindElementByTagName("body");
         body.SendKeys(keys);
     }
     else
     {
         var userAction = new OpenQA.Selenium.Interactions.Actions(remoteWebDriver);
         userAction.SendKeys(keys).Perform();
     }
     ScenarioEventSourceProvider.EventLog.SendKeysStop(keys.Length);
 }
        public void basicInfoTab(String initVidName)
        {
            String videoID_Admin;

            log.Info("inside basicInfoTab " + " at line:" + new StackTrace(true).GetFrame(0).GetFileLineNumber());

            //getting GUID of the current video
            guid_Admin = videoGuidField().GetAttribute("value");

            log.Info("Guid_Admin:: " + guid_Admin);

            videoID_Admin = videoIdField().GetAttribute("value");

            log.Info("VideoID_Admin:: " + videoID_Admin);

            //getting the uique name for the video title
            //videoName = "vid" + uf.getShortGuid().Substring(0, 10);
            videoName = initVidName + uf.getShortGuid();
            log.Info("Video name  : " + videoName);

            //Store the video details in sysconfig.xml file
            //cf.writingIntoXML("AdminPortal", "VideoManagement", "VideoName", videoName, "SysConfig.xml");
            cf.writingIntoXML("Admin", "External Management", "VideoName", videoName, "TestCopy.xml");

            cf.writingIntoXML("AdminPortal", "VideoManagement", "VideoID", videoID_Admin, "SysConfig.xml");
            cf.writingIntoXML("AdminPortal", "VideoManagement", "Guid", guid_Admin, "SysConfig.xml");

            //Enter data in Title field

            videoTitleField().SendKeys(videoName);

            videoTitleUsedInRecentVideoSection = videoName;

            //Enter data in ShortDescription field
            videoDescription().SendKeys("This field is for writing Description");

            int size = driver.FindElements(By.TagName("iframe")).Count();

            Console.WriteLine("Total Frames:" + size);

            Thread.Sleep(5000);

            //Enter data into abstract field
            iWait.Until(ExpectedConditions.ElementExists((OR.GetElement("VideoManagement", "Abstract", "TVAdminPortalOR.xml"))));

            IWebElement abstract_frame = driver.FindElement((OR.GetElement("VideoManagement", "Abstract", "TVAdminPortalOR.xml")));

            driver.SwitchTo().Frame(abstract_frame);

            IWebElement editor_body = driver.FindElement(By.TagName("body"));

            OpenQA.Selenium.Interactions.Actions action = new OpenQA.Selenium.Interactions.Actions(driver);
            action.SendKeys(editor_body, abstractContent).Build().Perform();
            driver.SwitchTo().DefaultContent();

            SelectElement VideoTypeSelector = new SelectElement(videoType());

            VideoTypeSelector.SelectByIndex(3);
            String selectedVideoType = VideoTypeSelector.SelectedOption.Text.Trim();

            String videoCreatedDate = driver.FindElement((OR.GetElement("VideoManagement", "VideoCreatedDT", "TVAdminPortalOR.xml"))).GetAttribute("value");

            log.Info("videoCreatedDate   :" + videoCreatedDate);

            cf.writingIntoXML("AdminPortal", "VideoManagement", "CreatedDate", videoCreatedDate, "SysConfig.xml");
        }
Пример #8
0
 public IKeyActions SendKeys(BaseElement element, string keysToSend)
 {
     actions.SendKeys(element.IWebElement, keysToSend);
     return(this);
 }
Пример #9
0
 public static IWebElement TabAndReturnFocusedElement(this IWebDriver WebDriver)
 {
     OpenQA.Selenium.Interactions.Actions press = new OpenQA.Selenium.Interactions.Actions(WebDriver);
     press.SendKeys(Keys.Tab).Perform();
     return(WebDriver.SwitchTo().ActiveElement());
 }
Пример #10
0
 public static void KeyboardSendKeys(string code)
 {
     Console.WriteLine("Send key '" + code + "' from keyboard");
     var builder = new OpenQA.Selenium.Interactions.Actions(Driver);
     builder.SendKeys(code).Perform();
 }