Id() public static method

Gets a mechanism to find elements by their ID.
public static Id ( string idToFind ) : By
idToFind string The ID to find.
return By
Esempio n. 1
0
        ///
        //Methods
        //
        public void SetupGatedAccess()
        {
            driver.FindElement(_featuresLeftPanelIcon).Click();
            driver.FindElement(_hardwareACT365FeatureCheckbox).Click();
            driver.FindElement(_hardwareLightingFeatureCheckbox).Click();
            driver.FindElement(_featureSaveButton).Click();
            driver.FindElement(_bookingLeftPanelIcon).Click();
            driver.FindElement(_bookingSettingsHyperLink).Click();
            driver.FindElement(_manageBasicSettingsOnBookingPageButton).Click();

            IReadOnlyCollection <IWebElement> elements = driver.FindElements(By.CssSelector(".panel:nth-child(2) h2"));

            Console.WriteLine(elements);
            Assert.IsTrue(elements.Count > 0);
            Assert.IsTrue(driver.FindElement(By.CssSelector(".radio-inline .checked")).Enabled);
            var value = driver.FindElement(By.Id("select2-Hardware_Act365_SiteID-container")).Text;

            Assert.AreEqual("SportLabs", value);

            driver.FindElement(_saveBasicSettings).Click();
            driver.FindElement(_bookingSettingsHyperLink).Click();
            driver.FindElement(_bookingManageCourtsLink).Click();
            driver.FindElement(By.CssSelector(".select2-container--focus .select2-selection__rendered")).Click();
            var gateValueText = driver.FindElement(By.CssSelector(".select2-container--focus .select2-selection__choice")).Text;

            Assert.AreSame("Door Controller-3(Circuit-1)", gateValueText);
            driver.FindElement(By.CssSelector(".form-actions > .btn")).Click();
            IReadOnlyCollection <IWebElement> elements1 = driver.FindElements(By.CssSelector(".modal-title:nth-child(2)"));

            Console.WriteLine(elements1);

            Assert.IsTrue(elements1.Count > 0);

            driver.FindElement(_featuresLeftPanelIcon).Click();
            driver.FindElement(_hardwareACT365FeatureCheckbox).Click();
            driver.FindElement(_hardwareLightingFeatureCheckbox).Click();
            driver.FindElement(_featureSaveButton).Click();
        }
Esempio n. 2
0
        public void WhenIEnterUsernameAndPassword(string username, string password)
        {
            //Username
            try
            {
                WebDriver
                .FindElement(By.Id("login"))
                .SendKeys(username);
            }
            catch
            {
            }

            //Password
            try
            {
                WebDriver
                .FindElement(By.Id("password"))
                .SendKeys(password);
            }
            catch
            {
            }
        }
Esempio n. 3
0
 public IWebElement FindNonExistentElement(int timeoutInSeconds)
 {
     return(Find().Element(By.Id("RandomElement"), TimeSpan.FromSeconds(timeoutInSeconds)));
 }
 /// <summary>
 /// Gets a mechanism to find elements by their ID.
 /// </summary>
 /// <param name="idToFind">The ID to find.</param>
 /// <returns>A <see cref="OpenQA.Selenium.By"/> object the driver can use to find the elements.</returns>
 public static new SeleniumBy Id(string idToFind) => SeleniumBy.Id(idToFind);
 private void ClickOnElementWhichRecordsEvents(IWebDriver focusedDriver)
 {
     focusedDriver.FindElement(By.Id("plainButton")).Click();
 }
 public void ShouldNotThrowIfEventHandlerThrows()
 {
     driver.Url = javascriptPage;
     driver.FindElement(By.Id("throwing-mouseover")).Click();
 }
Esempio n. 7
0
 public void ShouldSelectChildFramesByChainedCalls()
 {
     driver.Url = framesetPage;
     driver.SwitchTo().Frame("fourth").SwitchTo().Frame("child2");
     Assert.AreEqual("11", driver.FindElement(By.Id("pageNumber")).Text);
 }
        public void ShouldBeAbleToSwitchToTheTopIfTheFrameIsDeletedFromUnderUs()
        {
            driver.Url = deletingFrame;
            driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromMilliseconds(1000));
            driver.SwitchTo().Frame("iframe1");

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

            killIframe.Click();
            driver.SwitchTo().DefaultContent();

            bool     frameExists = true;
            DateTime timeout     = DateTime.Now.Add(TimeSpan.FromMilliseconds(4000));

            while (DateTime.Now < timeout)
            {
                try
                {
                    driver.SwitchTo().Frame("iframe1");
                }
                catch (NoSuchFrameException)
                {
                    frameExists = false;
                    break;
                }
            }

            Assert.IsFalse(frameExists);

            IWebElement addIFrame = driver.FindElement(By.Id("addBackFrame"));

            addIFrame.Click();

            timeout = DateTime.Now.Add(TimeSpan.FromMilliseconds(4000));
            while (DateTime.Now < timeout)
            {
                try
                {
                    driver.SwitchTo().Frame("iframe1");
                    break;
                }
                catch (NoSuchFrameException)
                {
                }
            }

            try
            {
                WaitFor(() =>
                {
                    IWebElement success = null;
                    try
                    {
                        success = driver.FindElement(By.Id("success"));
                    }
                    catch (NoSuchElementException)
                    {
                    }

                    return(success != null);
                });
            }
            catch (WebDriverException)
            {
                Assert.Fail("Could not find element after switching frame");
            }
        }
Esempio n. 9
0
 public void WhenClickOnTheButton(string button)
 {
     WebDriver
     .FindElement(By.Id("btnlogin"))
     .Click();
 }
Esempio n. 10
0
 private void ClickOnElementWhichRecordsEvents()
 {
     driver.FindElement(By.Id("plainButton")).Click();
 }
Esempio n. 11
0
 public void ShouldGetCoordinatesOfAnInvisibleElement()
 {
     driver.Url = EnvironmentManager.Instance.UrlBuilder.WhereIs("coordinates_tests/page_with_invisible_element.html");
     Assert.AreEqual(new Point(0, 0), GetLocationInViewPort(By.Id("box")));
     Assert.AreEqual(new Point(0, 0), GetLocationOnPage(By.Id("box")));
 }
Esempio n. 12
0
 public void ShouldGetCoordinatesOfAnElement()
 {
     driver.Url = EnvironmentManager.Instance.UrlBuilder.WhereIs("coordinates_tests/simple_page.html");
     Assert.AreEqual(new Point(10, 10), GetLocationInViewPort(By.Id("box")));
     Assert.AreEqual(new Point(10, 10), GetLocationOnPage(By.Id("box")));
 }
 public void ShouldThrowExceptionOnNonExistingElement()
 {
     driver.Url = simpleTestPage;
     Assert.Throws <NoSuchElementException>(() => driver.FindElement(By.Id("doesnotexist")));
 }