public void ShouldAllowSendingKeysWithShiftPressed()
        {
            driver.Url = javascriptPage;

            IWebElement keysEventInput = driver.FindElement(By.Id("theworks"));

            keysEventInput.Click();

            Actions actionProvider = new Actions(driver);
            IAction pressShift = actionProvider.KeyDown(keysEventInput, Keys.Shift).Build();
            pressShift.Perform();

            IAction sendLowercase = actionProvider.SendKeys(keysEventInput, "ab").Build();
            sendLowercase.Perform();

            IAction releaseShift = actionProvider.KeyUp(keysEventInput, Keys.Shift).Build();
            releaseShift.Perform();

            AssertThatFormEventsFiredAreExactly("focus keydown keydown keypress keyup keydown keypress keyup keyup");

            Assert.AreEqual("AB", keysEventInput.GetAttribute("value"));
        }
    public void KeyboardKeysExample()
    {
        Driver.Navigate().GoToUrl("http://the-internet.herokuapp.com/key_presses");

        // Option 1
        Driver.FindElement(By.Id("content")).SendKeys(Keys.Space);
        Assert.That(Driver.FindElement(By.Id("result")).Text.Equals("You entered: SPACE"));

        // Option 2
        Actions Builder = new Actions(Driver);
        Builder.SendKeys(Keys.Left).Build().Perform();
        Assert.That(Driver.FindElement(By.Id("result")).Text.Equals("You entered: LEFT"));
    }
        public void ShouldAllowBasicKeyboardInput()
        {
            driver.Url = javascriptPage;

            IWebElement keyReporter = driver.FindElement(By.Id("keyReporter"));

            Actions actionProvider = new Actions(driver);
            IAction sendLowercase = actionProvider.SendKeys(keyReporter, "abc def").Build();

            sendLowercase.Perform();

            Assert.AreEqual("abc def", keyReporter.GetAttribute("value"));
        }
 public virtual void IfNoObjectInClipboardCtrlVRevertsToBrowserBehaviour() {
     GeminiUrl("home?m1=EmployeeRepository&d1=CreateNewEmployeeFromContact&f1_contactDetails=null");
     WaitForView(Pane.Single, PaneType.Home);
     var home = WaitForCss(".title");
     Actions action = new Actions(br);
     action.DoubleClick(home); //Should put "Home"into browser clipboard
     action.SendKeys(Keys.Control + "c");
     action.Perform();
     Thread.Sleep(500);
     //home.SendKeys(Keys.Control + "c");
     string selector = "input.value";
     var target = WaitForCss(selector);
     Assert.AreEqual("", target.GetAttribute("value"));
     target.Click();
     target.SendKeys(Keys.Control + "v");
     Assert.AreEqual("Home", target.GetAttribute("value"));
 }
Exemplo n.º 5
0
        static public async Task<bool> launchAttack( string IP, string time )
        {

            #region UNUSED
            /*
            bool launchAttack = false;

            while( !launchAttack ) {

                IList<IWebElement> infoBlock;
                IWebElement limit;

                try {
                    infoBlock = driver.FindElements( By.ClassName( "infoblock" ) );
                    limit = infoBlock[3].FindElement( By.TagName("small") ); // there are 4 infoblocks.
                }catch( NoSuchElementException e ) {
                    MessageBox.Show( "Can't find infoblock!" );
                    return true;
                }

            
                if( limit.Text.Length >= 7 ) {
                    string      sCurrentAttacks  = limit.Text.Substring( 0,2 ); // find first 2 numbers of string that describe ongoing attacks.
                    string      sMaxAttacks      = limit.Text.Substring( 5,2 );

                    int         curAttacks;
                    int         maxAttacks;

                    try {
                        curAttacks = Int32.Parse( sCurrentAttacks );
                        maxAttacks = Int32.Parse( sMaxAttacks );
                    } catch {
                        MessageBox.Show( "Failed to convert flood attacks to INT32!" );
                        MessageBox.Show( "CurrentAttacks: " + sCurrentAttacks );
                        MessageBox.Show( "CurrentMaxAttacks: " + sMaxAttacks );
                        return true;
                    }

                    if( curAttacks >= maxAttacks ) { // reload site to refresh attack box
                        driver.Navigate().Refresh();
                        await Task.Delay( 4500 );
                        //System.Threading.Thread.Sleep( 4500 );

                        launchAttack = false;
                    } else { launchAttack = true; }
                }
            }
            */
            #endregion

            try { // check if site has crashed
                driver.FindElement( By.ClassName( "cf-wrapper" ) ); // if found, then site has crashed
                Program.formInstance.setAction( "Site has crashed, reloading after 1 minute!" );
                await Task.Delay( TimeSpan.FromMinutes(1) );
                driver.Navigate().Refresh();
                await Task.Delay( TimeSpan.FromSeconds( 10 ) );
            } catch( NoSuchElementException e ) {
                // no action.
            }

            IWebElement inputBox = null;
            try
            {
                inputBox = driver.FindElement( By.ClassName( "block-content-form") );
            } catch( NoSuchElementException e ){
                Program.formInstance.setAction( "Failed to find input box!" );
                return true;
            }

            IList<IWebElement> labels = inputBox.FindElements( By.TagName("label") );
            if( labels.Count <= 0 ) {
                Program.formInstance.setAction( "Failed to find label elements!" );
                return true;
            }

            // INPUTTING DATA INTO BOXES
            IWebElement IPBox   = null; // ip to attack
            IWebElement PortBox = null; // port to attack
            IWebElement TimeBox = null; // how long to attack
            
            foreach( IWebElement e in labels ) {
                if( e.Text.Contains( "Target IP" ) )
                    IPBox = e;

                if( e.Text.Contains( "Target Port" ) )
                    PortBox = e;

                if( e.Text.Contains( "Time" ) )
                    TimeBox = e;
            }

            if( IPBox == null | PortBox == null | TimeBox == null ) {
                Program.formInstance.setAction( "Failed to find all input boxes!" );
                return true;
            }

            Actions action = new Actions( driver ); // make mouse move

            IWebElement temp = IPBox.FindElement( By.TagName("input" ) );
            action.MoveToElement( temp ).Click().Build().Perform();
            action.SendKeys( IP ).Build().Perform();
            await Task.Delay( 500 );

            temp = PortBox.FindElement( By.TagName( "input" ) );
            action.MoveToElement( temp ).Click().Build().Perform();
            action.SendKeys( "80" ).Build().Perform();
            await Task.Delay( 500 );

            temp = TimeBox.FindElement( By.TagName( "input" ) );
            action.MoveToElement( temp ).Click().Build().Perform();
            action.SendKeys( time ).Build().Perform();
            await Task.Delay( 500 );

            temp = inputBox.FindElement( By.TagName( "button" ) );

            try {
                action.MoveToElement( temp ).Click().Build().Perform();
            }catch( Exception e ) {
                return true;
            }

            try {
                WebDriverWait wait = new WebDriverWait( driver, TimeSpan.FromMinutes(1) );
                wait.Until( d => ( (IJavaScriptExecutor)driver ).ExecuteScript( "return document.readyState" ).Equals( "complete" ) );
            } catch( Exception e ) {
                Program.formInstance.setAction( "Failed to wait for page refresh!" );
                return true;
            }


            return false;
        }
Exemplo n.º 6
0
        static void Main(string[] args)
        {
            driver = new ChromeDriver();

            driver.Manage().Window.Maximize();

            driver.Navigate().GoToUrl(baseURL + "/");

            Login();

            Thread.Sleep(2000);
            driver.FindElement(By.Id("epi-quickNavigator-clickHandler")).Click();
            Thread.Sleep(1000);
            driver.FindElement(By.XPath("//ul[@id='epi-quickNavigator']//li[@class='epi-quickNavigator-dropdown']//ul[@id='epi-quickNavigator-menu']//a[text()='CMS Edit']")).Click();

            Thread.Sleep(2000);
            NavigateToNewCatalogUI();

            Thread.Sleep(2000);

            ToggleNavigationPan();
            //ExpandCatalogRoot();
            ExpandCategory(
            new string[]{
                "Catalog Root", "Departmental Catalog", "Departments", "Media", "Music",
            });
            HoverCategoryTree("Music-Soundtrack");
            Click_Tab_AllProperties("Assets");
            //PlaceOrder();

            //var ul = driver.FindElement(By.Id("epi-quickNavigator-menu"));
            //Console.WriteLine(ul.GetAttribute("style"));
            //var links = ul.FindElements(By.TagName("a"));
            //var li = ul.FindElements(By.TagName("li"));
            //foreach (var link in links)
            //{
            //    Console.WriteLine(link.Text);
            //}

            //var dashBoardLink = links.First(element => element.Text == "Dashboard");
            //Console.WriteLine(dashBoardLink.Location);

            //var cmsEditLink = links.First(element => element.Text == "CMS Edit");
            //Console.WriteLine(cmsEditLink.Location);

            //OpenGlobalMenu();
            return;

            var span = driver.FindElement(By.Id("uniqName_26_46"));

            Console.WriteLine(span != null);
            var sParent = span.FindElement(By.XPath("./parent::*"));
            if (sParent != null)
            {
                Console.WriteLine("hjeheheheh");
                Console.WriteLine(sParent.GetAttribute("data-dojo-attach-event"));
                Actions actions = new Actions(driver);
                actions.MoveToElement(sParent);//.Build().Perform();
                actions.Click().Perform();
                var pin = driver.FindElement(By.Id("dijit_form_ToggleButton_6"));
                var pPin = pin.FindElement(By.XPath("./parent::*"));
                if (pPin != null)
                {
                    Console.WriteLine(pPin.GetAttribute("data-dojo-attach-event"));
                    actions.MoveToElement(pPin);//.Build().Perform();
                    actions.Click().Perform();
                }
            }
            var treeDiv = driver.FindElement(By.Id("navigation"));
            if (treeDiv != null)
            {
                Actions actions1 = new Actions(driver);
                Console.WriteLine("left tree can be recorgnied");
                var homePageNode = treeDiv.FindElement(By.XPath("//span[contains(@title, '2526')]"));
                actions1.MoveToElement(homePageNode.FindElement(By.XPath("./parent::*")));
                actions1.Click().Perform();

                //Create content
                var createButton = driver.FindElement(By.XPath("//span[contains(@title, 'Create content')]"));
                actions1.MoveToElement(createButton.FindElement(By.XPath("./parent::*")));
                actions1.Click().Perform();

                var newPageRow = driver.FindElement(By.Id("uniqName_26_47"));
                actions1.MoveToElement(newPageRow);
                actions1.Click().Perform();
                driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(10));
                //data-dojo-attach-point="namePanel"
                var namePanelDiv = driver.FindElement(By.XPath("//div[contains(@data-dojo-attach-point, 'namePanel')]//div[contains(@class, 'dijitReset dijitInputField dijitInputContainer')]"));

                if (namePanelDiv != null)
                {
                    //dijitReset dijitInputField dijitInputContainer
                    var newPageInput = namePanelDiv.FindElement(By.TagName("input"));
                    Console.WriteLine(newPageInput.GetAttribute("id"));

                    actions1.MoveToElement(newPageInput);
                    actions1.Click().Perform();

                    actions1.SendKeys(Keys.Backspace);
                    actions1.SendKeys(Keys.Backspace);
                    actions1.SendKeys(Keys.Backspace);
                    actions1.SendKeys(Keys.Backspace);
                    actions1.SendKeys(Keys.Backspace);
                    actions1.SendKeys(Keys.Backspace);
                    actions1.SendKeys(Keys.Backspace);
                    actions1.SendKeys(Keys.Backspace);

                    actions1.SendKeys("TestPage");
                    var homePage = driver.FindElement(By.XPath("//h3[contains(text(), 'Home Page')]")).FindElement(By.XPath("./parent::*"));

                    actions1.MoveToElement(homePage);
                    actions1.Click().Perform();

                    Thread.Sleep(5000);

                    var tiny = driver.FindElement(By.ClassName("epi-overlay-bracket"));
                    actions1.MoveToElement(tiny);
                    actions1.Click().Perform();

                    Thread.Sleep(3000);
                    var winHandleBefore = driver.CurrentWindowHandle;
                    driver.SwitchTo().Frame("uniqName_110_0_editorFrame_ifr");

                    var p = driver.FindElement(By.Id("tinymce")).FindElement(By.TagName("p"));
                    actions1.MoveToElement(p);
                    actions1.SendKeys("skdfj sjlfdkjsl djfklj sldfkj").Perform();
                    Thread.Sleep(3000);

                    driver.SwitchTo().Window(winHandleBefore);

                    //dijit dijitReset dijitInline epi-mediumButton epi-modeButton dijitToggleButton
                    var toggleButton =
                        driver.FindElement(
                            By.XPath(
                                "//span[contains(@class, 'dijit dijitReset dijitInline epi-mediumButton epi-modeButton dijitToggleButton')]")).FindElement(By.TagName("span"));
                    actions1.MoveToElement(toggleButton);
                    actions1.Click().Perform();

                    Thread.Sleep(3000);
                    var form = driver.FindElement(By.XPath("//form[@class='epi-formArea']"));
                    var div =
                        form.FindElement(By.TagName("div"));

                    Console.WriteLine(div.GetAttribute("class"));
                    var div1 = div.FindElement(By.XPath("//div[@class='dijitTabPaneWrapper dijitTabContainerTop-container']"));
                    Console.WriteLine(div1.GetAttribute("aria-labelledby"));

                    var ul = div1.FindElement(By.XPath(".//ul"));
                    var lis = ul.FindElements(By.XPath(".//li"));
                    Console.WriteLine("li count: " + lis.Count.ToString());

                    var label = lis[0].FindElement(By.XPath(".//label"));

                    Console.WriteLine(lis[1].FindElement(By.XPath(".//label[contains(.,'StringField')]")).GetAttribute("for"));
                    Console.WriteLine("for: " + label.GetAttribute("for"));

                    var labelChild = label.FindElements(By.XPath("*"));
                    Console.WriteLine("label child count: " + labelChild.Count.ToString());

                    //var label = driver.FindElement(By.XPath("//label[contains(text(), 'PayPalPaymentPage')]"));
                    //if (label != null)
                    //{
                    //    Console.WriteLine("PayPalPaymentPage label found");
                    //}
                }
                //span[contains(@title, 'Home Page')]
                // //div[contains(@class, 'v-table-body')]
            }

            // driver.Quit();
            //driver.FindElement(By.XPath("//span[@id='uniqName_26_46']/span")).Click();
            //driver.FindElement(By.XPath("//span[@id='uniqName_26_46']/span")).Click();
            //uniqName_26_46
            //IWebElement elem = driver.FindElement(By.XPath(".//*[@id='epi-quickNavigator-menu']/a[text()='CMS Edit']"));

            //Actions actions = new Actions(driver);

            //actions.MoveToElement(elem).Build().Perform();

            //actions.MoveToElement(cmsEditLink).Build().Perform();
            //cmsEditLink.Click();
            //actions.Click().Perform();
            //Console.ReadKey();
        }
Exemplo n.º 7
0
 public void Type(string text)
 {
     EnsureFocus();
     Actions action = new Actions(this.Driver);
     action.SendKeys(text);
     action.Perform();
 }
Exemplo n.º 8
0
        public void KeysTest()
        {
            List<string> keyComboNames = new List<string>()
            {
                "Control",
                "Shift",
                "Alt",
                "Control + Shift",
                "Control + Alt",
                "Shift + Alt",
                "Control + Shift + Alt"
            };

            List<string> colorNames = new List<string>()
            {
                "red",
                "green",
                "lightblue",
                "yellow",
                "lightgreen",
                "silver",
                "magenta"
            };

            List<List<string>> modifierCombonations = new List<List<string>>()
            {
                new List<string>() { Keys.Control },
                new List<string>() { Keys.Shift },
                new List<string>() { Keys.Alt },
                new List<string>() { Keys.Control, Keys.Shift },
                new List<string>() { Keys.Control, Keys.Alt },
                new List<string>() { Keys.Shift, Keys.Alt },
                new List<string>() { Keys.Control, Keys.Shift, Keys.Alt}
            };

            List<string> expectedColors = new List<string>()
            {
                "rgba(255, 0, 0, 1)",
                "rgba(0, 128, 0, 1)",
                "rgba(173, 216, 230, 1)",
                "rgba(255, 255, 0, 1)",
                "rgba(144, 238, 144, 1)",
                "rgba(192, 192, 192, 1)",
                "rgba(255, 0, 255, 1)"
            };

            bool passed = true;
            string errors = string.Empty;

            driver.Url = EnvironmentManager.Instance.UrlBuilder.WhereIs("keyboard_shortcut.html");
            IWebElement body = driver.FindElement(By.CssSelector("body"));
            Actions actions = new Actions(driver);
            for (int i = 0; i < keyComboNames.Count; i++)
            {
                for (int j = 0; j < modifierCombonations[i].Count; j++)
                {
                    actions.KeyDown(modifierCombonations[i][j]);
                }

                actions.SendKeys("1");
                
                // Alternatively, the following single line of code would release
                // all modifier keys, instead of looping through each key.
                // actions.SendKeys(Keys.Null);
                for (int j = 0; j < modifierCombonations[i].Count; j++)
                {
                    actions.KeyUp(modifierCombonations[i][j]);
                }

                actions.Perform();
                string background = body.GetCssValue("background-color");
                passed = passed && background == expectedColors[i];
                if (background != expectedColors[i])
                {
                    if (errors.Length > 0)
                    {
                        errors += "\n";
                    }

                    errors += string.Format("Key not properly processed for {0}. Background should be {1}, Expected: '{2}', Actual: '{3}'",
                        keyComboNames[i],
                        colorNames[i],
                        expectedColors[i],
                        background);
                }
            }

            Assert.IsTrue(passed, errors);
        }
Exemplo n.º 9
0
 public void TypeKeyss(string keys)
 {
     Actions actionProvider = new Actions(driver);
     actionProvider.SendKeys(keys);
 }
        public static void PressKey(string key)
        {
            var builder = new Actions(SeleniumDriver.Instance);

            switch (key.ToLower())
            {
                case "return":
                    builder.SendKeys(Keys.Return);
                    break;
                case "tab":
                    builder.SendKeys(Keys.Tab);
                    break;
                case "arrowdown":
                    builder.SendKeys(Keys.ArrowDown);
                    break;
                case "arrowup":
                    builder.SendKeys(Keys.ArrowUp);
                    break;
                case "arrowleft":
                    builder.SendKeys(Keys.ArrowLeft);
                    break;
                case "arrowright":
                    builder.SendKeys(Keys.ArrowRight);
                    break;
                case "home":
                    builder.SendKeys(Keys.Home);
                    break;
                case "end":
                    builder.SendKeys(Keys.End);
                    break;
                case "pageup":
                    builder.SendKeys(Keys.PageUp);
                    break;
                case "pagedown":
                    builder.SendKeys(Keys.PageDown);
                    break;
            }


            builder.Build().Perform();
        }
 /// <summary>
 /// Presses the keyboard Escape key
 /// </summary>
 public static void PressEscapeKey()
 {
     var action = new Actions(Driver.Instance);
     action.SendKeys(Keys.Escape);
     Driver.Wait(TimeSpan.FromSeconds(1));
 }
Exemplo n.º 12
0
        public void ShouldAllowSendingKeysToActiveElement()
        {
            driver.Url = bodyTypingPage;

            Actions actionProvider = new Actions(driver);
            IAction someKeys = actionProvider.SendKeys("ab").Build();
            someKeys.Perform();

            IWebElement bodyLoggingElement = driver.FindElement(By.Id("body_result"));
            Assert.AreEqual("keypress keypress", bodyLoggingElement.Text);

            IWebElement formLoggingElement = driver.FindElement(By.Id("result"));
            Assert.AreEqual("", formLoggingElement.Text);
        }
Exemplo n.º 13
0
        private void startWallBoard(object sender, RoutedEventArgs e)
        {
            // Configure the WebDriver path, and set to invisble (avoids annoying cmd prompt pop-up
            DriverService driverService = ChromeDriverService.CreateDefaultService(@".\WebDrivers\");
            driverService.HideCommandPromptWindow = true;

            // Use default chrome options for kiosk mode
            ChromeOptions cOptions = new ChromeOptions();
            //cOptions.AddArgument("--start-maximized --kiosk");
            //cOptions.BinaryLocation = "CHROME DIRECTORY";

            //IWebDriver driver = new ChromeDriver(@".\WebDrivers\");
            IWebDriver driver = new ChromeDriver(service: (ChromeDriverService)driverService, options: cOptions);

            //Create the actions builder
            Actions builder = new Actions(driver);

            //Default Site
            Thread.Sleep(100);
            Debug.Print(driver.CurrentWindowHandle);
            driver.SwitchTo().Window(driver.CurrentWindowHandle);
            Thread.Sleep(100);
            driver.Navigate().GoToUrl("http://www.reddit.com");
            Thread.Sleep(100);

            //Create some tabs
            driver.FindElement(By.CssSelector("body")).SendKeys(Keys.Control + "t");
            Thread.Sleep(200);
            driver.FindElement(By.CssSelector("body")).SendKeys(Keys.Control + "t");
            Thread.Sleep(200);
            driver.FindElement(By.CssSelector("body")).SendKeys(Keys.Control + "t");
            Thread.Sleep(200);

            //List the open tabs
            List<String> openTabs = openTabs = driver.WindowHandles.ToList<string>(); //driver.WindowHandles is a bloody read only collection
            foreach (var item in openTabs)
            {
                Debug.Print(item);
            }
            Debug.Print("TAB list size is  {0} ", openTabs.Count);

            Thread.Sleep(200);
            driver.SwitchTo().Window(openTabs[1]);
            Debug.Print("Switching to {0}", driver.Title);
            driver.Navigate().GoToUrl("http://www.facebook.com");
            Debug.Print("I am now to {0}", driver.Title);

            Thread.Sleep(200);
            driver.SwitchTo().Window(openTabs[2]);
            Debug.Print("Switching to {0}", driver.Title);
            driver.Navigate().GoToUrl("http://www.test.com");
            Debug.Print("I am now to {0}", driver.Title);

            Thread.Sleep(200);
            driver.SwitchTo().Window(openTabs[3]);
            Debug.Print("Switching to {0}", driver.Title);
            driver.Navigate().GoToUrl("http://www.baesystems.com");
            Debug.Print("I am now to {0}", driver.Title);

            Thread.Sleep(200);

            //Go to next tab (loop to first)
            Thread.Sleep(100);
            builder.SendKeys(Keys.Control + Keys.PageDown).Perform();
            driver.SwitchTo().Window(openTabs[0]);
            Thread.Sleep(100);
            driver.SwitchTo().ActiveElement();
            Debug.Print("BOLLOXX {0}", driver.Title);
            Thread.Sleep(100);

            //Hide the main app window
            this.frmMain.WindowState = System.Windows.WindowState.Minimized;
        }
        /// <summary>
        /// Basic inline product addition simulation. Adds one product to an empty MyCart grid.
        /// Uses Selenium Actions to interact with MyCart grid.
        /// </summary>
        /// <param name="pnToAdd">Product number to add. May need to have an extra same starting letter
        /// as the Action is too fast to register the first.
        /// </param>
        /// <returns>Current page</returns>
        internal MyCartPage AddItemInline(string pnToAdd, string affiliation)
        {
            _logger.Trace(" > Attempting to add a product inline...");
            AlertSuccess = false; 
            Thread.Sleep(1000);
            IWebElement PNCell, Outside, Active;
            try
            {
                PNCell = HelperMethods.FindElement(_driver, Constants.SearchType.XPATH, Constants.MyCart.XP.EDITABLE_ROW);
                Outside = HelperMethods.FindElement(_driver, Constants.SearchType.ID, Constants.MyCart.XP.CART_ORDER_GRID);
                // Enter Product Number into cell
                Actions action = new Actions(_driver);
                action.MoveToElement(PNCell).Click().SendKeys(pnToAdd).Perform();
                // Tab over to quantity
                if (affiliation.Equals(Constants.Affiliation.Drake.USER))
                    action.SendKeys(Keys.Tab).SendKeys(Keys.Tab).SendKeys(Keys.Tab).SendKeys(Keys.Tab).SendKeys(Keys.Tab).SendKeys(Keys.Tab).Perform();
                else
                    action.SendKeys(Keys.Tab).Perform();
                // Add quantity and complete product entry
                Thread.Sleep(500);
                Active = HelperMethods.FindElement(_driver, Constants.SearchType.XPATH, Constants.MyCart.XP.ACTIVE_ROW_QTY);
                action.MoveToElement(Active).Click().SendKeys(Keys.Tab).Perform();
                Thread.Sleep(500);
                AlertSuccess = HelperMethods.CheckAlert(_driver);
                if (AlertSuccess.Equals(true))
                    _logger.Info(" > Product added inline!");
                else
                    _logger.Info(" > Problem adding product inline!");
            }
            catch (Exception e)
            {
                _logger.Error(" > Exception encountered AddItemInLine(): " + e.Message);
            }

            return this;
        }
        public String SearchRequiredVideoFromTable(String videoName, String action)
        {
            log.Info("Search for the required video");

            String abstractContent = "Abstract field content";

            uf.isJqueryActive(driver);

            iWait.Until(ExpectedConditions.ElementIsVisible((OR.GetElement("VideoRequestByUser", "SearchVideoTB", "TVAdminPortalOR.xml"))));

            driver.FindElement((OR.GetElement("VideoRequestByUser", "SearchVideoTB", "TVAdminPortalOR.xml"))).SendKeys(videoName);

            //search the required video
            driver.FindElement((OR.GetElement("VideoRequestByUser", "SearchButton", "TVAdminPortalOR.xml"))).Click();

            OverlayWait();

            Thread.Sleep(3000);

            iWait.Until(ExpectedConditions.ElementExists((OR.GetElement("UserGeneratedContent", "VideoStatus", "TVAdminPortalOR.xml"))));

            IWebElement tblVideoListing = driver.FindElement((OR.GetElement("UserGeneratedContent", "VideoStatus", "TVAdminPortalOR.xml")));

            iWait.Until(ExpectedConditions.PresenceOfAllElementsLocatedBy(By.TagName("tr")));

            IList <IWebElement> userContentRowList = (IList <IWebElement>)tblVideoListing.FindElements(By.TagName("tr"));

            Boolean flag = false;

            int i = 0;

            foreach (IWebElement currentRow in userContentRowList)
            {
                //Check Row that have class="GridRowStyle" or class="AltGridStyle"
                if (currentRow.GetAttribute("class").Equals("GridRowStyle") || currentRow.GetAttribute("class").Equals("AltGridStyle"))
                {
                    String columData = currentRow.FindElements(By.TagName("td"))[3].FindElement(By.TagName("span")).Text.Trim();

                    log.Info("Video Title from manage page::" + columData);

                    if (columData.Equals(videoName))
                    {
                        flag = true;

                        if (action.Equals("reject"))
                        {
                            log.Info("Performing reject operation");

                            //click on Reject
                            driver.FindElement(OR.GetElement("UserGeneratedContent", "RejectButton", "TVAdminPortalOR.xml", i)).Click();

                            //driver.SwitchTo().Alert();
                            //VerifySuccessBannerMessage("Record deleted successfully");

                            //////////// new added /////////////
                            iWait.Until(ExpectedConditions.ElementIsVisible((OR.GetElement("VideoRequestByUser", "WarningYesButton", "TVAdminPortalOR.xml"))));

                            driver.FindElement((OR.GetElement("VideoRequestByUser", "WarningYesButton", "TVAdminPortalOR.xml"))).Click();

                            iWait.Until(ExpectedConditions.ElementIsVisible((OR.GetElement("SeriesManagement", "SuccessOkButton", "TVAdminPortalOR.xml"))));

                            driver.FindElement((OR.GetElement("SeriesManagement", "SuccessOkButton", "TVAdminPortalOR.xml"))).Click();
                            //////////// new added /////////////

                            //VerifySuccessBannerMessage("Record deleted successfully");

                            iWait.Until(ExpectedConditions.ElementIsVisible((OR.GetElement("VideoRequestByUser", "SearchVideoTB", "TVAdminPortalOR.xml"))));

                            driver.FindElement((OR.GetElement("VideoRequestByUser", "SearchVideoTB", "TVAdminPortalOR.xml"))).Clear();
                            driver.FindElement((OR.GetElement("VideoRequestByUser", "SearchVideoTB", "TVAdminPortalOR.xml"))).SendKeys(videoName);
                            Thread.Sleep(2000);
                            uf.scrollUp(driver);
                            //search the required video
                            driver.FindElement((OR.GetElement("VideoRequestByUser", "SearchButton", "TVAdminPortalOR.xml"))).Click();

                            OverlayWait();

                            #region verify status at admin table

                            log.Info("verify status at admin table");

                            iWait.Until(ExpectedConditions.ElementIsVisible((OR.GetElement("UserGeneratedContent", "VideoStatus", "TVAdminPortalOR.xml"))));

                            tblVideoListing = driver.FindElement((OR.GetElement("UserGeneratedContent", "VideoStatus", "TVAdminPortalOR.xml")));

                            iWait.Until(ExpectedConditions.PresenceOfAllElementsLocatedBy(By.TagName("tr")));

                            userContentRowList = (IList <IWebElement>)tblVideoListing.FindElements(By.TagName("tr"));

                            flag = false;

                            i = 0;

                            foreach (IWebElement currentRow1 in userContentRowList)
                            {
                                //Check Row that have class="GridRowStyle" or class="AltGridStyle"
                                if (currentRow1.GetAttribute("class").Equals("GridRowStyle") || currentRow1.GetAttribute("class").Equals("AltGridStyle"))
                                {
                                    columData = currentRow1.FindElements(By.TagName("td"))[3].FindElement(By.TagName("span")).Text.Trim();

                                    log.Info("Video Title from manage page::" + columData);

                                    if (columData.Equals(videoName))
                                    {
                                        flag = true;

                                        Assert.AreEqual("Rejected", currentRow1.FindElements(By.TagName("td"))[7].FindElement(By.TagName("span")).Text.Trim());
                                    }

                                    break;
                                }

                                i++;
                            }
                            #endregion
                        }
                        else
                        {
                            //click on Create
                            driver.FindElement(OR.GetElement("UserGeneratedContent", "CreateButton", "TVAdminPortalOR.xml", i)).Click();

                            iWait.Until(ExpectedConditions.ElementIsVisible((OR.GetElement("VideoManagement", "VidNumberTXT", "TVAdminPortalOR.xml"))));

                            //getting GUID of the current video
                            guid_Admin = driver.FindElement((OR.GetElement("VideoRequestByUser", "GuAdminId", "TVAdminPortalOR.xml"))).GetAttribute("value");

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

                            #region Enter abstract data
                            //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"));

                            Thread.Sleep(3000);

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

                            #endregion

                            objAdminVideoMngmnt.channelListTab();

                            objAdminVideoMngmnt.addcopyright();

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

                            iWait.Until(ExpectedConditions.ElementIsVisible((OR.GetElement("VideoManagement", "UploadVidTab", "TVAdminPortalOR.xml"))));
                            //Click on uplaod video tab
                            driver.FindElement((OR.GetElement("VideoManagement", "UploadVidTab", "TVAdminPortalOR.xml"))).FindElement(By.TagName("a")).Click();

                            int    count  = 0;
                            String status = null;;

                            //checking the status of video for 5mins untill it gets Ready
                            while (count < 60)
                            {
                                iWait.Until(ExpectedConditions.InvisibilityOfElementLocated((OR.GetElement("SeriesManagement", "SuccessOkButton", "TVAdminPortalOR.xml"))));

                                status = driver.FindElement((OR.GetElement("VideoManagement", "StatusCSS", "TVAdminPortalOR.xml"))).Text;

                                log.Info("status of the Video:::" + status);

                                if (status.Equals("Status: READY"))
                                {
                                    break;
                                }
                                Thread.Sleep(5000);

                                count = count + 1;

                                IWebElement videoPreviewButton = driver.FindElement((OR.GetElement("VideoManagement", "VidPreviewBTN", "TVAdminPortalOR.xml")));

                                //Click on the preview button
                                executor.ExecuteScript("arguments[0].click();", videoPreviewButton);
                            }

                            Assert.AreEqual("Status: READY", status);

                            Thread.Sleep(2000);

                            objAdminVideoMngmnt.finalPublishVideo("normal");

                            OverlayWait();

                            iWait.Until(ExpectedConditions.ElementIsVisible((OR.GetElement("VideoRequestByUser", "SearchVideoTB", "TVAdminPortalOR.xml"))));

                            driver.FindElement((OR.GetElement("VideoRequestByUser", "SearchVideoTB", "TVAdminPortalOR.xml"))).Clear();
                            driver.FindElement((OR.GetElement("VideoRequestByUser", "SearchVideoTB", "TVAdminPortalOR.xml"))).SendKeys(videoName);

                            //search the required video
                            driver.FindElement((OR.GetElement("VideoRequestByUser", "SearchButton", "TVAdminPortalOR.xml"))).Click();

                            OverlayWait();

                            #region verify status at admin table

                            log.Info("verify status at admin table");

                            iWait.Until(ExpectedConditions.ElementIsVisible((OR.GetElement("UserGeneratedContent", "VideoStatus", "TVAdminPortalOR.xml"))));

                            tblVideoListing = driver.FindElement((OR.GetElement("UserGeneratedContent", "VideoStatus", "TVAdminPortalOR.xml")));

                            iWait.Until(ExpectedConditions.PresenceOfAllElementsLocatedBy(By.TagName("tr")));

                            userContentRowList = (IList <IWebElement>)tblVideoListing.FindElements(By.TagName("tr"));

                            flag = false;

                            i = 0;

                            foreach (IWebElement currentRow1 in userContentRowList)
                            {
                                //Check Row that have class="GridRowStyle" or class="AltGridStyle"
                                if (currentRow1.GetAttribute("class").Equals("GridRowStyle") || currentRow1.GetAttribute("class").Equals("AltGridStyle"))
                                {
                                    columData = currentRow1.FindElements(By.TagName("td"))[3].FindElement(By.TagName("a")).Text.Trim();

                                    log.Info("Video Title from manage page::" + columData);

                                    if (columData.Equals(videoName))
                                    {
                                        flag = true;

                                        Assert.AreEqual("Published", currentRow1.FindElements(By.TagName("td"))[7].FindElement(By.TagName("span")).Text.Trim());
                                    }

                                    break;
                                }

                                i++;
                            }
                            #endregion

                            return(guid_Admin);
                        }
                    }
                }
            }
            return(null);
        }
Exemplo n.º 16
0
 public void KeyboardSendKeys(string code)
 {
     Console.WriteLine("Send key '" + code + "' from keyboard");
     var builder = new Actions(Driver);
     builder.SendKeys(code).Perform();
 }
        public void ShouldAllowSendingKeysToActiveElement()
        {
            driver.Url = bodyTypingPage;

            Actions actionProvider = new Actions(driver);
            IAction someKeys = actionProvider.SendKeys("ab").Build();
            someKeys.Perform();

            AssertThatBodyEventsFiredAreExactly("keypress keypress");
            IWebElement formLoggingElement = driver.FindElement(By.Id("result"));
            AssertThatFormEventsFiredAreExactly(string.Empty);
        }
Exemplo n.º 18
0
            public void Step3()
            {
                var d = new Data.Data.Beneficiary();

                var DOBYearDropdownSelect = new SelectElement(DobYearDropdown);
                var DOBMonthDropdownSelect = new SelectElement(DobMonthDropdown);
                var DOBDayDropdownSelect = new SelectElement(DobDayDropdown);
                var StateDropdownSelect = new SelectElement(StateDropDown);

                FirstNameField.SendKeys(d.FirstName);
                LastNameField.SendKeys(d.LastName);
                SSNField.SendKeys(d.SSN);
                DOBYearDropdownSelect.SelectByText(d.Year);
                DOBMonthDropdownSelect.SelectByText(d.Month);
                DOBDayDropdownSelect.SelectByText(d.Day);
                SSNField.Click();
                Actions builder = new Actions(_driver);
                builder.SendKeys(Keys.Tab).Perform();
                var AgeGradeDropdownSelect = new SelectElement(AgeGradeDropdown);
                AgeGradeDropdownSelect.SelectByIndex(d.AgeGrade);
                Address1Field.SendKeys(d.Address1);
                CityField.SendKeys(d.City);
                StateDropdownSelect.SelectByText(d.State);
                ZipCodeField.SendKeys(d.Zip);
                NextButton.Click();
            }