Exemplo n.º 1
0
 public void ExplicitWaitElementUntilClickableByXpath(IWebDriver webDriver, int seconds, string XPath)
 {
     webDriverWait = new WebDriverWait(webDriver, TimeSpan.FromSeconds(seconds));
     webDriverWait.Until(ExpectedConditions.ElementToBeClickable(By.XPath(XPath)));
 }
Exemplo n.º 2
0
        public void RemoteSelenium(string Name, string DriverPort, string VNCPort, int TTL)
        {
            string[] SearchDict = new string[4] {
                "World Cup", "Mac Miller", "Donald Trump", "Kate Spade"
            };


            try
            {
                var aTimer = new CustomTimer
                {
                    _name          = Name,
                    _DC            = DC,
                    _containerID   = ContainerID_1,
                    _currentThread = Thread.CurrentThread,
                    _driver        = driver,
                    Interval       = TTL * 1000 //ms
                };

                Random r = new Random();
                SearchString = SearchDict[r.Next(0, 4)];

                aTimer.Elapsed += aTimer.OnTimedEvent;
                aTimer.Start();


                driver.Manage().Timeouts().PageLoad = TimeSpan.FromMinutes(5);

                driver.Manage().Timeouts().AsynchronousJavaScript = TimeSpan.FromMinutes(5);

                driver.Manage().Window.Maximize(); // WINDOWS, DO NOT WORK FOR LINUX/firefox. If Linux/firefox set window size, max 1920x1080, like driver.Manage().Window.Size = new Size(1920, 1080);
                                                   // driver.Manage().Window.Size = new Size(1920, 1080); // LINUX/firefox

                driver.Navigate().GoToUrl("https://www.bing.com/");

                var wait = new WebDriverWait(driver, TimeSpan.FromMinutes(5));

                wait.Until(ExpectedConditions.ElementExists((By.XPath("//input[@id='sb_form_q']"))));


                IJavaScriptExecutor ex = (IJavaScriptExecutor)driver;

                string str = driver.PageSource;

                IWebElement element = driver.FindElement(By.XPath("//input[@id='sb_form_q']"));

                element.Click();
                element.Clear();
                //Enter some text in search text box
                element.SendKeys(SearchString);

                wait.Until(ExpectedConditions.ElementExists((By.XPath("//input[@id='sb_form_go']"))));
                element = driver.FindElement(By.XPath("//input[@id='sb_form_go']"));
                element.Submit();


                wait.Until(ExpectedConditions.ElementExists((By.Id("b_content"))));

                if (!DoneTakeSS)
                {
                    try
                    {
                        Screenshot ss = ((ITakesScreenshot)driver).GetScreenshot();
                        ss.SaveAsFile(@"D:\data\SS\" + Name + ".jpg", ScreenshotImageFormat.Jpeg);
                        DoneTakeSS = true;
                    }
                    catch (Exception exSS) { }
                }
                for (int i = 0; i < 50; i++)
                {
                    int triesNo = 0;

                    for (int j = 0; j < 4; j++)
                    {
                        try
                        {
                            IWebElement NextPageElement = wait.Until(ExpectedConditions.ElementToBeClickable((By.XPath("//a[contains(@title,'Next page')]"))));
                            ex.ExecuteScript("arguments[0].click();", NextPageElement);
                            break;
                        }
                        catch (Exception ex1)
                        {
                            driver.Navigate().Refresh();
                            wait.Until(ExpectedConditions.ElementExists((By.Id("b_content"))));
                            triesNo++;
                        }
                    }

                    if (triesNo > 2)
                    {
                        break;
                    }

                    wait.Until(ExpectedConditions.ElementExists((By.Id("b_results"))));
                    Thread.Sleep(1000);

                    var webElements = driver.FindElements(By.TagName("h2"));
                    for (int j = 0; j < webElements.Count; j++)
                    {
                        using (System.IO.StreamWriter file =
                                   new System.IO.StreamWriter(@"D:\data\" + Name + ".log", true))
                        {
                            file.WriteLine($"{webElements[j].GetAttribute("innerText")}");
                        }
                    }

                    Thread.Sleep(10000);
                }


                Console.WriteLine($"{Name}:{VNCPort} done capturing!");

                Thread.Sleep(3600000);

                driver.Quit();
                Task d = DC.DisposeContainerAsync(ContainerID_1);
                d.Wait();
            }
            catch (Exception ex)
            {
                if (ex is ThreadAbortException)
                {
                }
                else
                {
                    if (driver != null)
                    {
                        driver.Quit();
                    }
                }
                Task d = DC.DisposeContainerAsync(ContainerID_1);
                d.Wait();

                Console.WriteLine($"{Name}:{VNCPort} {ex.Message}");
            }
        }
Exemplo n.º 3
0
 public void ExplicitWait(IWebElement element, int miliseconds)
 {
     new WebDriverWait(driver, TimeSpan.FromMilliseconds(miliseconds)).
     Until(ExpectedConditions.ElementToBeClickable(element));
 }
        public void AddNewTaskTestCase()
        {
            // Navigating to TopPanel for creating new task
            topPanelPageObject.PlusTaskButton.Click();

            // Assigning random name to task
            taskTitle = "Task_" + identificationNumber;

            // Filling all fields of the task
            addTaskPageObject.TaskTitle.SendKeys(taskTitle);
            addTaskPageObject.TaskDescription.SendKeys(TASK_DESCRIPTION);
            addTaskPageObject.TeamField.Click();
            addTaskPageObject.TeamInput.SendKeys(TASK_TEAM + Keys.Enter);
            addTaskPageObject.TaskStartDate.Clear();
            addTaskPageObject.TaskStartDate.SendKeys(TASK_STARTDATE);
            addTaskPageObject.TaskEndDate.Clear();
            addTaskPageObject.TaskEndDate.SendKeys(TASK_ENDDATE);
            addTaskPageObject.TaskPriorityListComboBox.SelectByText(TASK_PRIORITY);

            // List of assignees
            assigneesList = addTaskPageObject.AssigneesList;

            foreach (var user in assigneesList)
            {
                var userName      = user.UserName;
                var name          = userName.Text;
                var keyresultList = user.KeyResults;

                foreach (var keyresult in keyresultList)
                {
                    var keyresultInstance = keyresult.Text;
                    var inputSet          = keyresult.FindElement(By.TagName(KEY_RESULT_TAGNAME));

                    // Checking checkboxes with corresponding keyresults
                    if (!inputSet.Selected &&
                        (name == ASSIGNED_PERSON_1 && keyresultInstance == ASSIGNED_PERSON_1_KEY_RESULT_1) ||
                        (name == ASSIGNED_PERSON_2 && keyresultInstance == ASSIGNED_PERSON_2_KEY_RESULT_1))
                    {
                        inputSet.SendKeys(Keys.Space);
                    }
                }
            }

            addTaskPageObject.CreateTaskButton.SendKeys(Keys.Enter);

            // Clicking button 'MyTasks'
            for (int i = 0; i < RETRYING_ITERATION_COUNT; i++)
            {
                try
                {
                    sideBarMenuPageObject.MyTasks.Click();

                    if (myTasksPageObject.MyTasksTitleLabel.Displayed)
                    {
                        isNotStaleElement = true;
                    }
                }
                catch (Exception)
                {
                    isNotStaleElement = false;
                }

                if (isNotStaleElement && myTasksPageObject.MyTasksTitleLabel.Text == "My tasks")
                {
                    break;
                }
            }

            // Assigning the value to the variable taskList
            for (int i = 0; i < RETRYING_ITERATION_COUNT; i++)
            {
                try
                {
                    wait.Until(driver => myTasksPageObject.TaskList.Count > 0);
                    wait.Until(ExpectedConditions.ElementToBeClickable(myTasksPageObject.TaskList[0].TaskName));

                    // List of all tasks for this user
                    taskList = myTasksPageObject.TaskList;
                }
                catch (Exception)
                {
                }

                if (taskList.Count > 0)
                {
                    break;
                }
            }

            // Checking result of additing new task
            Assert.AreEqual(taskList.First().TaskName.Text, taskTitle);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Aguarda até que o elemento esteja sendo exibido na interface.
        /// </summary>
        /// <param name="element"> Elemento da interface.</param>
        /// <param name="ngDriver"> ngWebDriver utilizado.</param>
        /// <param name="timeout"> Tempo limite até que o elemento seja exibido, padrão é 20 segundos.</param>
        public static void WaitUntilVisibleOn(this IWebElement element, NgWebDriver ngDriver, TimeSpan?timeout = null)
        {
            var wait = new WebDriverWait(ngDriver, timeout ?? TimeSpan.FromSeconds(20));

            wait.Until(ExpectedConditions.ElementToBeClickable(element));
        }
 public void ClickOnElement(IWebElement element)
 {
     wait.Until(ExpectedConditions.ElementToBeClickable(element));
     element.Click();
 }
 public void waitForClickabiity(IWebElement element)
 {
     wait.Until(ExpectedConditions.ElementToBeClickable(element));
 }
Exemplo n.º 8
0
        public static void phraseCapturepoint3(string point3)
        {
            WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));

            wait.Until(ExpectedConditions.ElementToBeClickable(By.XPath("//label[@id = 'id_pff2']/..//input[@id = 'pff3']"))).SendKeys(point3);
        }
Exemplo n.º 9
0
        public static void getphrase2()
        {
            WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));

            tphrase2 = wait.Until(ExpectedConditions.ElementToBeClickable(By.XPath("//label[@id = 'id_pff2']/..//input[@id = 'pff2']"))).GetAttribute("value");
        }
Exemplo n.º 10
0
        public HeatmapCellModel GetCellInformation(IWebElement cell)
        {
            HeatmapCellModel result = new HeatmapCellModel();

            new WebDriverWait(webdriver, TimeSpan.FromSeconds(Constants.WAIT_TIME_DEFAULT)).Until(ExpectedConditions.ElementToBeClickable(cell));

            IList <IWebElement> statusAreas = cell.FindElements(statusElementsLocator);

            foreach (IWebElement color in statusAreas)
            {
                var colorRawKey   = color.GetAttribute("class");
                var colorRawValue = color.GetAttribute("style");

                var colorKey   = colorRawKey.Replace("status-", "");
                var colorValue = colorRawValue
                                 .Replace("width: 100%; height: ", "")
                                 .Replace("%;", "")
                                 .Replace("width: 0px; height: ", "")
                                 .Replace("px;", "")
                                 .Trim();

                result.colors.Add(colorKey, colorValue);
            }
            result.CalculateVisibleColors();

            return(result);
        }
Exemplo n.º 11
0
        public void Task()
        {
            test = extent.CreateTest("Task2");
            test.Log(Status.Info, "URL is Opened");

            Page.Desktop.Click();
            Page.Desktop_All.Click();
            Execute.ExecuteScript("arguments[0].scrollIntoView(true);", Page.Sony_VAIO);
            Page.Sony_VAIO.Click();
            Page.Qty.Click();
            Page.Qty.Clear();
            Page.Qty.SendKeys(Qty);
            Page.Add_To_Cart.Click();
            Page.Shopping_Cart.Click();
            Assert.IsTrue(webDriver.FindElement(By.XPath("//td[@class='text-center' and contains(.,'Image')]")).Displayed);
            Assert.IsTrue(webDriver.FindElement(By.XPath("//td[@class='text-left' and contains(.,'Product Name')]")).Displayed);
            Assert.IsTrue(webDriver.FindElement(By.XPath("//td[@class='text-left' and contains(.,'Model')]")).Displayed);
            Assert.IsTrue(webDriver.FindElement(By.XPath("//td[@class='text-left' and contains(.,'Quantity')]")).Displayed);
            Assert.IsTrue(webDriver.FindElement(By.XPath("//td[@class='text-right' and contains(.,'Unit Price')]")).Displayed);
            Assert.IsTrue(webDriver.FindElement(By.XPath("//table[@class='table table-bordered']/thead/tr/td[@class='text-right' and contains(.,'Total')]")).Displayed);
            Page.Checkout.Click();
            Page.Continue.Click();
            wait.Until(ExpectedConditions.ElementToBeClickable(By.XPath("//input[@id='input-payment-firstname']")));
            Page.FirstName.Click();
            Page.FirstName.SendKeys(FirstName);
            Page.LastName.Click();
            Page.LastName.SendKeys(LastName);
            Page.Email.Click();
            Page.Email.SendKeys(Email);
            Page.Telephone.Click();
            Page.Telephone.SendKeys(Telephone);
            Page.Address1.Click();
            Page.Address1.SendKeys(Address);
            Page.City.Click();
            Page.City.SendKeys(City);
            Page.Postal.Click();
            Page.Postal.SendKeys(Postal);
            Page.Country.Click();
            SelectElement Select_Country = new SelectElement(Page.Country);

            Select_Country.SelectByText(Country);
            Page.State.Click();
            SelectElement Select_State = new SelectElement(Page.State);

            Select_State.SelectByText(State);
            Page.Pass.Click();
            Page.Pass.SendKeys(Pass);
            Page.ConfirmPass.Click();
            Page.ConfirmPass.SendKeys(ConfirmPass);
            Page.Checkbox.Click();
            Page.Continue1.Click();
            wait.Until(ExpectedConditions.ElementToBeClickable(By.XPath("//input[@id='button-shipping-address']")));
            Page.Continue2.Click();
            wait.Until(ExpectedConditions.ElementToBeClickable(By.XPath("//input[@id='button-shipping-method']")));
            Page.Continue3.Click();
            wait.Until(ExpectedConditions.ElementToBeClickable(By.XPath("//input[@id='button-payment-method']")));
            Page.Checkbox2.Click();
            Page.Continue4.Click();
            wait.Until(ExpectedConditions.ElementToBeClickable(By.XPath("//input[@id='button-confirm']")));
            Page.ConfirmOrder.Click();
        }
Exemplo n.º 12
0
        internal Boolean ClickOnColouredCell(int colorCount)
        {
            Boolean isFound = false;

            new WebDriverWait(webdriver, TimeSpan.FromSeconds(Constants.WAIT_TIME_DEFAULT)).Until(ExpectedConditions.ElementIsVisible(By.CssSelector("div[ng-show='heatmap.showSummaries']")));
            new WebDriverWait(webdriver, TimeSpan.FromSeconds(Constants.WAIT_TIME_DEFAULT)).Until(ExpectedConditions.ElementToBeClickable(cellListLocator));
            IList <IWebElement> cellList = webdriver.FindElements(cellListLocator);

            foreach (IWebElement elementNow in cellList)
            {
                HeatmapCellModel itemData = GetCellInformation(elementNow);

                if (itemData.CalculateVisibleColors() == colorCount)
                {
                    elementNow.Click();
                    isFound = true;
                    break;
                }
            }

            return(isFound);
        }
Exemplo n.º 13
0
        public void GrabCellsColorsData()
        {
            IList <HeatmapCellModel> results = new List <HeatmapCellModel>();

            new WebDriverWait(webdriver, TimeSpan.FromSeconds(Constants.WAIT_TIME_DEFAULT)).Until(ExpectedConditions.ElementIsVisible(By.CssSelector("div[ng-show='heatmap.showSummaries']")));
            new WebDriverWait(webdriver, TimeSpan.FromSeconds(Constants.WAIT_TIME_DEFAULT)).Until(ExpectedConditions.ElementToBeClickable(cellListLocator));
            IList <IWebElement> cellList = webdriver.FindElements(cellListLocator);

            foreach (IWebElement elementNow in cellList)
            {
                HeatmapCellModel itemData = GetCellInformation(elementNow);
                results.Add(itemData);
            }
        }
Exemplo n.º 14
0
        public void ClickUsingAllByMethods()
        {
            By linkText      = By.LinkText("Click this link");
            By clickableLink = By.Name("clickableLink");

            // create a driver
            var           driver = GetChromeDriver();
            WebDriverWait wait   = new WebDriverWait(driver, TimeSpan.FromSeconds(20));

            //            IWebElement linkSuccess = driver.FindElement(By.ClassName("entry-title"));
            //            IWebElement ButtonSuccess = driver.FindElement(By.ClassName("entry-title"));

            driver.Manage().Window.Maximize();
            driver.Navigate().GoToUrl("https://ultimateqa.com/simple-html-elements-for-automation/");

            // click button
            driver.FindElement(By.ClassName("buttonClass")).Click();

            // define success class
            IWebElement SuccessMsg = driver.FindElement(By.ClassName("entry-title"));

            // wait for success mesg
            wait.Until(ExpectedConditions.TextToBePresentInElement(SuccessMsg, "Button success"));
            driver.Navigate().Back();

            // click This button using id
            wait.Until(ExpectedConditions.ElementToBeClickable(By.Id("idExample"))).Click();

            // wait for success link
            driver.FindElement(By.XPath("//h1[.='Button success']"));      // add a wait condition to this.
            wait.Until(ExpectedConditions.ElementToBeClickable(driver.FindElement(By.XPath("//h1[.='Button success']")))).Click();
            //         wait.Until(ExpectedConditions.ElementToBeClickable(driver.FindElement(By.XPath("//h1[.='Button success']"))));

            //         //  wait.Until(ExpectedConditions.TextToBePresentInElement(SuccessMsg, "Button success"));    // not finding the text Button success
            driver.Navigate().Back();

            // Click Link Text "click this link"
            wait.Until(ExpectedConditions.ElementToBeClickable(linkText)).Click();


            // wait for link success
            wait.Until(ExpectedConditions.ElementToBeClickable(driver.FindElement(By.XPath("//h1[.='Link success']"))));
            //     wait.Until(ExpectedConditions.TextToBePresentInElement(SuccessMsg, "Link success"));
            driver.Navigate().Back();

            // click "Click this link"
            wait.Until(ExpectedConditions.ElementToBeClickable(clickableLink)).Click();


            //        IJavaScriptExecutor js = (IJavaScriptExecutor)driver;
            //        js.ExecuteScript("window.scrollTo(0, 0)");


            // wait for link success
            wait.Until(ExpectedConditions.ElementToBeClickable(driver.FindElement(By.XPath("//h1[.='Link success']"))));
            //  wait.Until(ExpectedConditions.TextToBePresentInElement(SuccessMsg, "Link success"));
            driver.Navigate().Back();

            // Click This link
            wait.Until(ExpectedConditions.ElementToBeClickable(By.PartialLinkText("this link"))).Click();

            // wait for success
            //      wait.Until(ExpectedConditions.TextToBePresentInElement(SuccessMsg, "Link success"));
            wait.Until(ExpectedConditions.ElementToBeClickable(driver.FindElement(By.XPath("//h1[.='Link success']"))));
            driver.Navigate().Back();

            // click "click this link
            wait.Until(ExpectedConditions.ElementToBeClickable(By.CssSelector("#simpleElementsLink"))).Click();

            // wait for success
            wait.Until(ExpectedConditions.ElementToBeClickable(driver.FindElement(By.XPath("//h1[.='Link success']"))));
            //      wait.Until(ExpectedConditions.TextToBePresentInElement(SuccessMsg, "Link success"));
            driver.Navigate().Back();

            // click a button
            wait.Until(ExpectedConditions.ElementToBeClickable(By.CssSelector(".buttonClass"))).Click();

            // wait for success
            wait.Until(ExpectedConditions.TextToBePresentInElement(SuccessMsg, "Button success"));
            driver.Navigate().Back();

            // click "click this button using id"
            wait.Until(ExpectedConditions.ElementToBeClickable(By.XPath("//*[@id='idExample']"))).Click();

            // wait for success
            wait.Until(ExpectedConditions.TextToBePresentInElement(SuccessMsg, "Button success"));
            driver.Navigate().Back();

            // scroll to element
            var     element1 = driver.FindElement(By.XPath("//*[@class='buttonClass']"));
            Actions actions  = new Actions(driver);

            actions.MoveToElement(element1);
            actions.Perform();

            // click button using class name
            wait.Until(ExpectedConditions.ElementToBeClickable(By.XPath("//*[@class='buttonClass']"))).Click();

            // wait for success
            wait.Until(ExpectedConditions.TextToBePresentInElement(SuccessMsg, "Button success"));

            driver.Close();
        }
Exemplo n.º 15
0
 public static IWebElement WaitUntilClickable(this IWebDriver driver, By selector, int seconds = defaultWaitSeconds)
 {
     return(driver.WaitForElement(ExpectedConditions.ElementToBeClickable(selector)));
 }
Exemplo n.º 16
0
        //Method should be called after user has conirmed payment method on banking app
        public static void makepay()
        {
            WebDriverWait wait  = new WebDriverWait(driver, TimeSpan.FromSeconds(10));
            WebDriverWait wait1 = new WebDriverWait(driver, TimeSpan.FromMinutes(3));

            wait1.Until(ExpectedConditions.InvisibilityOfElementLocated(By.XPath("//div[text() = 'Seconds remaining']")));

            // wait.Until(ExpectedConditions.ElementToBeClickable(By.XPath("//input[@id = 'addBeneficiary-externalAccount']"))).Click();

            wait.Until(ExpectedConditions.ElementToBeClickable(By.XPath("//input[@name = 'fullName']"))).SendKeys("Traverse");

            wait.Until(ExpectedConditions.ElementToBeClickable(By.XPath("//input[@placeholder= 'Capture and select bank name']"))).SendKeys("STANDARD BANK SA LTD");

            // wait.Until(ExpectedConditions.ElementIsVisible(By.XPath("//span[text() = 'STANDARD BANK SA LTD']"))).Click();

            wait.Until(ExpectedConditions.ElementToBeClickable(By.XPath("//input[@placeholder= 'Capture and select bank name']"))).SendKeys(Keys.ArrowDown);

            wait.Until(ExpectedConditions.ElementToBeClickable(By.XPath("//input[@placeholder= 'Capture and select bank name']"))).SendKeys(Keys.Enter);

            wait.Until(ExpectedConditions.ElementToBeClickable(By.XPath("//input[@placeholder= 'Capture and select the Branch name or Branch code']"))).SendKeys("051001");

            //wait.Until(ExpectedConditions.ElementIsVisible(By.XPath("//span[text() = '051001']")));

            wait.Until(ExpectedConditions.ElementToBeClickable(By.XPath("//input[@placeholder= 'Capture and select the Branch name or Branch code']"))).SendKeys(Keys.ArrowDown);

            wait.Until(ExpectedConditions.ElementToBeClickable(By.XPath("//input[@placeholder= 'Capture and select the Branch name or Branch code']"))).SendKeys(Keys.Enter);

            wait.Until(ExpectedConditions.ElementToBeClickable(By.XPath("//input[@name = 'accountNumber']"))).SendKeys("270657282");

            wait.Until(ExpectedConditions.ElementToBeClickable(By.XPath("//a[@id= 'accountType']"))).Click();

            wait.Until(ExpectedConditions.ElementToBeClickable(By.XPath("//span[text() = 'Cheque Account']"))).Click();

            wait.Until(ExpectedConditions.ElementToBeClickable(By.XPath("//input[@name = 'amount']"))).SendKeys("1");

            wait.Until(ExpectedConditions.ElementToBeClickable(By.XPath("//input[@name = 'myReference']"))).SendKeys("MyRef1");

            wait.Until(ExpectedConditions.ElementToBeClickable(By.XPath("//input[@name = 'beneficiaryReference']"))).SendKeys("BenRef1");

            wait.Until(ExpectedConditions.ElementToBeClickable(By.XPath("//button[text() = 'Next']"))).Click();

            wait.Until(ExpectedConditions.ElementToBeClickable(By.XPath("//h1[text() = ' This beneficiary already exists']/../..//span[@class = 'radio-control__indicator']"))).Click();

            wait.Until(ExpectedConditions.ElementToBeClickable(By.XPath("//button[text() = ' Use existing beneficiary ']"))).Click();

            wait.Until(ExpectedConditions.ElementToBeClickable(By.XPath("//button[text() = 'Confirm']"))).Click();

            /*  wait.Until(ExpectedConditions.ElementToBeClickable(By.XPath("//select[@id = 'paymentNotification-notBenType']//option[text() = 'E-mail']"))).Click();
             *
             * wait.Until(ExpectedConditions.ElementToBeClickable(By.XPath("//input[@id = 'paymentNotification-notBenEmail']"))).SendKeys("*****@*****.**");
             *
             * wait.Until(ExpectedConditions.ElementToBeClickable(By.XPath("//input[@id = 'paymentNotification-notBenName']"))).SendKeys("Reece");
             *
             * wait.Until(ExpectedConditions.ElementToBeClickable(By.XPath("//*[@id='ui-wizard-body1']/div/form/div[3]/div[5]/div/button[3]/div/div/div"))).Click();
             *
             * wait.Until(ExpectedConditions.ElementToBeClickable(By.XPath("//div[@class = 'ui-button-left']//div[text() = 'Add']/.."))).Click();
             *
             * wait.Until(ExpectedConditions.ElementIsVisible(By.XPath("//div[@class = 'ui-button-left']//div[text() = 'Pay this beneficiary']/.."))).Click();
             *
             * wait.Until(ExpectedConditions.ElementToBeClickable(By.XPath("//input[@id = 'paySingle-amount']"))).SendKeys("1");
             *
             * wait.Until(ExpectedConditions.ElementToBeClickable(By.XPath("//*[@id='ui-wizard-body1']/div/form/div[2]/div[4]/div/button[3]/div/div/div"))).Click();
             *
             * wait.Until(ExpectedConditions.ElementToBeClickable(By.XPath("//div[@class = 'ui-button-left']//div[text() = 'Pay']/.."))).Click();*/

            wait.Until(ExpectedConditions.ElementIsVisible(By.XPath("//div[text() = 'Seconds remaining']")));
        }
Exemplo n.º 17
0
        public void FF_AWS_Video()
        {
            // going to Products > Storage > S3
            var todo = new Actions(driver);
            var wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));
            var obj  = wait.Until(ExpectedConditions.ElementToBeClickable(By.XPath(".//div[@id='aws-nav-flyout-1-root']/div/div[3]/a")));

            todo.MoveToElement(obj).Click().Perform();
            todo = new Actions(driver);
            wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));
            obj  = wait.Until(ExpectedConditions.ElementToBeClickable(By.XPath(".//div[@id='aws-nav-flyout-2-products']/div/div[2]/a")));
            todo.MoveToElement(obj).Perform();
            todo = new Actions(driver);
            wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));
            obj  = wait.Until(ExpectedConditions.ElementToBeClickable(By.XPath(".//div[@id='aws-nav-flyout-3-storage']/div/div/a")));
            todo.MoveToElement(obj).Click().Perform();

            // expecting a page with specific "Amazon S3" link
            wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));
            wait.Until(ExpectedConditions.ElementExists(By.Id("Get_started_with_Amazon_S3")));
            obj = driver.FindElement(By.XPath(".//div[starts-with(@class,'lb-tiny-iblock')]"));
            jse.ExecuteScript("arguments[0].scrollIntoView(true);", obj);

            // start video
            wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));
            obj  = wait.Until(ExpectedConditions.ElementToBeClickable(By.ClassName("vjs-big-play-button")));
            obj.Click();

            // wait 5 seconds while the video is playing
            WaitTimer(5000);

            // go to video control bar
            todo = new Actions(driver);
            obj  = driver.FindElement(By.XPath(".//div[starts-with(@class,'vjs-control-bar')]"));
            todo.MoveToElement(obj).Perform();

            // go to the volume control icon
            todo = new Actions(driver);
            wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));
            obj  = wait.Until(ExpectedConditions.ElementIsVisible(By.XPath(".//div[starts-with(@class,'vjs-volume-panel')]")));
            todo.MoveToElement(obj).Perform();

            // go to the volume control bar and hit at 40% of its width
            todo = new Actions(driver);
            wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));
            obj  = wait.Until(ExpectedConditions.ElementIsVisible(By.XPath(".//div[starts-with(@class,'vjs-volume-bar')]")));
            int offsetX = (int)(obj.Size.Width * 0.1);

            // volume is set to +50% -10%, so to 40%,
            // because the "Origo" of the current object is its middle zone
            todo.MoveToElement(obj).MoveByOffset(-offsetX, 0).Click().Perform();

            // wait 8 seconds while the video is playing
            WaitTimer(8000);

            // go to video control bar
            todo = new Actions(driver);
            obj  = driver.FindElement(By.XPath(".//div[starts-with(@class,'vjs-control-bar')]"));
            todo.MoveToElement(obj).Perform();

            // pause video
            wait = new WebDriverWait(driver, TimeSpan.FromSeconds(5));
            obj  = wait.Until(ExpectedConditions.ElementToBeClickable(By.XPath(".//button[@title='Pause']")));
            obj.Click();

            // check if it's paused
            wait = new WebDriverWait(driver, TimeSpan.FromSeconds(5));
            obj  = wait.Until(ExpectedConditions.ElementToBeClickable(By.XPath(".//button[@title='Play']")));
        } // Menu_Video
Exemplo n.º 18
0
 public void ICloseCoockieBanner()
 {
     Wait().Until(ExpectedConditions.ElementToBeClickable(By.XPath("//a[@id='CybotCookiebotDialogBodyButtonAccept']"))).Click();
 }
 public void SendText(IWebElement element, string text)
 {
     wait.Until(ExpectedConditions.ElementToBeClickable(element));
     element.SendKeys(text);
 }
Exemplo n.º 20
0
 public void IClickOnMenu()
 {
     Wait().Until(ExpectedConditions.ElementToBeClickable(By.XPath("//button[@class='icon-menu']"))).Click();
 }
Exemplo n.º 21
0
 public static IWebElement ElementToBeClickable(By element)
 {
     try
     {
         Thread.Sleep(TIMEOUTBETWEENEVENTS);
         return(new WebDriverWait(DriverFactory.INSTANCE, TimeSpan.FromSeconds(TIMEOUT)).Until(ExpectedConditions.ElementToBeClickable(element)));
     }
     catch (Exception e)
     {
         var path = GeneralHelpers.TakeScreenshot("Erro");
         TestBase.FailTest(Utilitarios.GetCurrentMethod() + " => " + "ERRO! Elemento esperado não apareceu." + "<pre>" + e.Message + "</pre>");
         DriverFactory.INSTANCE.Quit();
         throw new Exception("SCREENSHOT GENERATED => " + "url(" + path + ")", e.InnerException);
     }
 }
Exemplo n.º 22
0
 public void IClickOnOurPartners()
 {
     Wait().Until(ExpectedConditions.ElementToBeClickable(By.XPath("//a[@data-om-navcta='Partners']"))).Click();
 }
Exemplo n.º 23
0
        public void WaitForElementClickable(IWebElement element)
        {
            WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));

            wait.Until(ExpectedConditions.ElementToBeClickable(element));
        }
Exemplo n.º 24
0
 public void IClickOnOffices()
 {
     Wait().Until(ExpectedConditions.ElementToBeClickable(By.XPath("//div[@class='site-nav__main__item__title' and text()[contains(.,'Our offices')]]"))).Click();
 }
Exemplo n.º 25
0
 public void Clear_InputText(IWebElement webElement, string value)
 {
     wait.Until(ExpectedConditions.ElementToBeClickable(webElement));
     webElement.Clear();
     webElement.SendKeys(value);
 }
Exemplo n.º 26
0
        public void TestCase()
        {
            Console.WriteLine("1. tekan tombol login google");
            HomePage home = new HomePage(driver);

            home.click();
            var parentWindow = driver.CurrentWindowHandle;
            var googletab    = driver.WindowHandles;

            foreach (var next_tab in googletab)
            {
                if (next_tab != parentWindow)
                {
                    Console.WriteLine("2. Isi email dan password");
                    driver.SwitchTo().Window(next_tab);
                    WebDriverWait wait2 = new WebDriverWait(driver, TimeSpan.FromSeconds(30000));
                    wait2.Until(ExpectedConditions.ElementToBeClickable(By.CssSelector("input[name='identifier'][type='email']"))).SendKeys("*****@*****.**");
                    var next = driver.FindElement(By.Id("identifierNext"));
                    next.Click();

                    var pass = new WebDriverWait(driver, TimeSpan.FromSeconds(30000)).Until(ExpectedConditions.ElementToBeClickable((By.CssSelector("input[name='password'][type='password']"))));
                    pass.SendKeys("7471063kartika");
                    next = driver.FindElement(By.Id("passwordNext"));
                    next.Click();
                }
            }


            driver.SwitchTo().Window(parentWindow);
            home = new HomePage(driver);
            var username = home.username();

            Assert.That(username, Is.Not.Empty, "user berhasil login");

            Console.WriteLine("3. Klik satu berita trending");
            home.FirstTendingClick();

            DetailPage detail = new DetailPage(driver);
            var        title  = detail.titleNews();

            Assert.That(title, Is.Not.Empty, "halaman detail berita berhasil terbuka");

            Console.WriteLine("4. Isi kolum komentar ");
            Console.WriteLine("5. Tekan tombol submit ");
            detail.clickcomment();
            detail.Writecomment("test automation");
            detail.btnComment();
            KomenPage komen     = new KomenPage(driver);
            var       komenNews = komen.lastKomen();

            Assert.That(komenNews, Does.Contain("test automation"), "5. komen berhasil");
        }
        public IWebElement userGeneratedContentLink()
        {
            iWait.Until(ExpectedConditions.ElementToBeClickable(OR.GetElement("UserGeneratedContent", "UserContentLink", "TVAdminPortalOR.xml")));

            return(driver.FindElement((OR.GetElement("UserGeneratedContent", "UserContentLink", "TVAdminPortalOR.xml"))));
        }
Exemplo n.º 28
0
 public static void WaitUntilElementToBeClickable(double secondsValue, IWebElement element)
 {
     CreateExplicitWait(secondsValue).Until(ExpectedConditions.ElementToBeClickable(element));
 }
Exemplo n.º 29
0
 public SearchingTrainResultsPage Search()
 {
     wait.Until(ExpectedConditions.ElementToBeClickable(By.XPath("//p[text()='Время выезда/приезда: местное']"))).Click();
     return(new SearchingTrainResultsPage(driver));
 }
Exemplo n.º 30
0
        public void CheckComplaintFormSubmitEl()
        {
            driver.Navigate().GoToUrl((ConfigurationManager.AppSettings["QAServerName"]) + "el/contact/complaint-form");  //go to contact form

            //Fill and submit form
            try
            {
                string      nameSelector = "[id$='txtFullName']";
                IWebElement name         = driver.FindElement(By.CssSelector(nameSelector));
                name.SendKeys("TestName");
            }
            catch
            {
                Assert.Fail("Couldn't find Name Field!");
            }
            try
            {
                string      phoneSelector = "[id$='txtPhone']";
                IWebElement phone         = driver.FindElement(By.CssSelector(phoneSelector));
                phone.SendKeys("2102101010");
            }
            catch
            {
                Assert.Fail("Couldn't find Phone Field!");
            }
            try
            {
                string      partenerSelector = "[id$='rbPartener_1']";
                IWebElement partener         = driver.FindElement(By.CssSelector(partenerSelector));
                partener.Click();
            }
            catch
            {
                Assert.Fail("Couldn't find Partener Radio Button!");
            }
            try
            {
                string      contactSelector = "[id$='ContactInterestRadioButtonList_0']";
                IWebElement contact         = driver.FindElement(By.CssSelector(contactSelector));
                contact.Click();
            }
            catch
            {
                Assert.Fail("Couldn't find Contact Radio Button!");
            }
            try
            {
                string      contactBySelector = "[id$='ContactByPhone']";
                IWebElement contactBy         = driver.FindElement(By.CssSelector(contactBySelector));
                contactBy.Click();
            }
            catch
            {
                Assert.Fail("Couldn't find contact by phone radio button!");
            }
            try
            {
                string      aggreementSelector = "[id$='aggreementCheckBox']";
                IWebElement aggreement         = driver.FindElement(By.CssSelector(aggreementSelector));
                aggreement.Click();
            }
            catch
            {
                //Assert.Fail("Couldn't find submit button!");
            }
            try
            {
                string submitSelector = "[id$='btnSubmit']";
                wait.Until(ExpectedConditions.ElementToBeClickable(By.CssSelector(submitSelector)));
                IWebElement submit = driver.FindElement(By.CssSelector(submitSelector));
                submit.Click();
            }
            catch
            {
                //Assert.Fail("Couldn't find submit button!");
            }
            Thread.Sleep(3000);
            driver.Quit();

            //Check if inserted with OK values
            driver = new InternetExplorerDriver(ConfigurationManager.AppSettings["ChromeDriverPath"]);
            driver.Manage().Window.Maximize();                                                                                       //to use the desired width of window
            wait = new WebDriverWait(driver, TimeSpan.FromSeconds(30));
            driver.Navigate().GoToUrl((ConfigurationManager.AppSettings["authQAServerName"]) + "Lists/ComplaintList/AllItems.aspx"); //go to contact list
            Login();
            try
            {
                string sortCreatedSelector = "[id$='Created'";
                wait.Until(ExpectedConditions.ElementIsVisible(By.CssSelector(sortCreatedSelector)));
                wait.Until(ExpectedConditions.ElementToBeClickable(By.CssSelector(sortCreatedSelector)));
                IWebElement sortCreated = driver.FindElement(By.CssSelector(sortCreatedSelector));
                sortCreated.Click();
                wait.Until(ExpectedConditions.ElementToBeClickable(By.CssSelector(sortCreatedSelector)));
                sortCreated.Click();
            }
            catch
            {
                Assert.Fail("Couldn't find sort button!");
            }
            try
            {
                string firstItemSelector = "//*[@class='ms-listviewtable']/tbody/tr";
                wait.Until(ExpectedConditions.ElementToBeClickable(By.XPath(firstItemSelector)));
                IWebElement firstItem = driver.FindElement(By.XPath(firstItemSelector));
                firstItem.Click();
            }
            catch
            {
                Assert.Fail("Couldn't find last item on list!");
            }
            try
            {
                string itemsOnRibbonSelector = "//*[@id='Ribbon.ListItem-title']/a";
                wait.Until(ExpectedConditions.ElementIsVisible(By.XPath(itemsOnRibbonSelector)));
                wait.Until(ExpectedConditions.ElementToBeClickable(By.XPath(itemsOnRibbonSelector)));
                IWebElement itemsOnRibbon = driver.FindElement(By.XPath(itemsOnRibbonSelector));
                itemsOnRibbon.Click();
            }
            catch
            {
                Assert.Fail("Couldn't find Items button on Ribbon!");
            }
            try
            {
                string viewProperiesSelector = "[id^='Ribbon.ListItem.Manage.ViewProperties']";
                wait.Until(ExpectedConditions.ElementToBeClickable(By.CssSelector(viewProperiesSelector)));
                IWebElement viewProperties = driver.FindElement(By.CssSelector(viewProperiesSelector));
                viewProperties.Click();
            }
            catch
            {
                Assert.Fail("Couldn't find View Properties button on Ribbon!");
            }

            //check all the fields to have the correct data
            try
            {
                string nameSelector = "//*[@class='ms-formtable']/tbody/tr[1]/td[2]";
                wait.Until(ExpectedConditions.ElementIsVisible(By.XPath(nameSelector)));
                IWebElement name = driver.FindElement(By.XPath("//*[@class='ms-formtable']/tbody/tr[1]/td[2]"));
                Assert.AreEqual(name.Text, "TestName");

                string      emailSelector = "//*[@class='ms-formtable']/tbody/tr[2]/td[2]";
                IWebElement email         = driver.FindElement(By.XPath(emailSelector));
                Assert.AreEqual(email.Text, "2102101010");

                string      partenerSelector = "//*[@class='ms-formtable']/tbody/tr[8]/td[2]";
                IWebElement partener         = driver.FindElement(By.XPath(partenerSelector));
                Assert.AreEqual(partener.Text, "Όχι");

                string      choiceSelector = "//*[@class='ms-formtable']/tbody/tr[11]/td[2]";
                IWebElement choice         = driver.FindElement(By.XPath(choiceSelector));
                Assert.AreEqual(choice.Text, "Τηλεφωνικά");

                string      contactBySelector = "//*[@class='ms-formtable']/tbody/tr[14]/td[2]";
                IWebElement contactBy         = driver.FindElement(By.XPath(contactBySelector));
                Assert.AreEqual(contactBy.Text, "Ναι");
            }
            catch
            {
                Assert.Fail("Something doesn't match!");
            }
        }