当前位置: 首页>>代码示例>>C#>>正文


C# IWebElement类代码示例

本文整理汇总了C#中IWebElement的典型用法代码示例。如果您正苦于以下问题:C# IWebElement类的具体用法?C# IWebElement怎么用?C# IWebElement使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


IWebElement类属于命名空间,在下文中一共展示了IWebElement类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetElementLocation

        public static Point GetElementLocation(IWebElement element)
        {
            Point location = GetElementOrigin(element);
            Size size = GetElementSize(element);

            return new Point(location.X + size.Width / 2, location.Y + size.Height / 2);
        }
开发者ID:Hammertime38,项目名称:BumblebeeIOS,代码行数:7,代码来源:InnerConvenience.cs

示例2: UntilVisible

        public static IWebElement UntilVisible(IWebElement element, TimeSpan timeOut)
        {
            Stopwatch sw = new Stopwatch();
            sw.Start();

            while (true)
            {
                WebDriverException lastException = null;
                try
                {
                    if (element.Displayed)
                    {
                        return element;
                    }
                    System.Threading.Thread.Sleep(100);
                }
                catch (ElementNotVisibleException e)     { lastException = e; }
                catch (NoSuchElementException e)         { lastException = e; }
                catch (StaleElementReferenceException e) { lastException = e; }

                if (sw.Elapsed > timeOut)
                {
                    string exceptionMessage = lastException == null ? "" : lastException.Message;
                    string errorMessage = string.Format("Wait.UntilVisible: Element was not displayed after {0} Milliseconds" +
                                                        "\r\n Error Message:\r\n{1}", timeOut.TotalMilliseconds, exceptionMessage);
                    throw new TimeoutException(errorMessage);
                }
            }
        }
开发者ID:Kreisfahrer,项目名称:SWD.Starter,代码行数:29,代码来源:Wait.cs

示例3: generateSequence

        private void generateSequence(
            TranscriptCmdletBase cmdlet,
            System.Collections.Generic.List<IRecordedCodeSequence> recordingsCollection,
            IRecordedCodeSequence codeSequence,
            IWebElement firstElement,
            IWebElement secondElement)
        {
            Recorder.RecordingCollection = recordingsCollection;

            codeSequence = 
                Recorder.RecordCodeSequence(
                    cmdlet,
                    Recorder.RecordingCollection,
                    firstElement,
                    codeSequence);

            if (null != secondElement) {
                codeSequence = 
                    Recorder.RecordCodeSequence(
                        cmdlet,
                        Recorder.RecordingCollection,
                        secondElement,
                        codeSequence);
            }
            
            Recorder.StoreCodeSequenceInCollection(
                cmdlet,
                Recorder.RecordingCollection,
                codeSequence);
        }
开发者ID:apetrovskiy,项目名称:STUPS,代码行数:30,代码来源:RecordCodeSequencyTestFixture.cs

示例4: EnterData

        public void EnterData(ISearchContext context, IWebElement element, object data)
        {
            var options = findOptions(element);
            foreach (var option in options)
            {
                if (option.Text == data.ToString())
                {
                    option.Click();
                    return;
                }
            }

            foreach (var option in options)
            {
                if (option.GetAttribute("value") == data.ToString())
                {
                    option.Click();
                    return;
                }
            }

            var message = "Cannot find the desired option\nThe available options are\nDisplay/Key\n";
            foreach (var option in options)
            {
                message += "\n" + "{0}/{1}".ToFormat(option.Text, option.GetAttribute("value"));
            }

            StoryTellerAssert.Fail(message);
        }
开发者ID:jemacom,项目名称:fubumvc,代码行数:29,代码来源:SelectElementHandler.cs

示例5: BaseEmailEngager

 protected BaseEmailEngager(Context context, IWebElement listItem) : base(context)
 {
     ListItem = listItem;
     DomainName = GetDomainName(listItem);
     CurrentDomain = context.GetDomain(DomainName);
     context.CurrentDomain = CurrentDomain;
 }
开发者ID:c0d3m0nky,项目名称:mty,代码行数:7,代码来源:BaseEmailEngager.cs

示例6: FakeWebElement

 /// <summary>
 /// Like decorator
 /// </summary>
 /// <param name="realWebElement"></param>
 public FakeWebElement(IWebElement realWebElement)
 //public WebElementDecorator(RemoteWebElement realWebElement) // : base(realWebElement.WrappedDriver, "")
 {
     this.DecoratedWebElement = realWebElement as FakeWebElement;
     this.SearchHistory =
         new List<ISearchHistory>();
 }
开发者ID:MatkoHanus,项目名称:STUPS,代码行数:11,代码来源:FakeWebElement.cs

示例7: Execute

 protected override void Execute(IWebDriver driver, dynamic context, IWebElement element)
 {
     if (IsFalseExpected)
         Assert.False(element.Enabled);
     else
         Assert.True(element.Enabled);
 }
开发者ID:MGetmanov,项目名称:Selenite,代码行数:7,代码来源:IsEnabledCommand.cs

示例8: Execute

 protected override void Execute(IWebDriver driver, IWebElement element, CommandDesc command)
 {
     if (element.Selected)
     {
         element.Click();
     }
 }
开发者ID:equilobe,项目名称:SeleneseTestRunner,代码行数:7,代码来源:Uncheck.cs

示例9: ColumnCount

 public int ColumnCount(IWebElement element)
 {
     IList<IWebElement> tableRows = element.FindElements(By.CssSelector("tr"));
     IWebElement headerRow = tableRows[0];
     IList<IWebElement> tableCols = headerRow.FindElements(By.CssSelector("td"));
     return tableCols.Count();
 }
开发者ID:BrockFredin,项目名称:SeleniumLW,代码行数:7,代码来源:Table.cs

示例10: Find

        public ComponentScopeLocateResult Find(IWebElement scope, ComponentScopeLocateOptions options, SearchOptions searchOptions)
        {
            string labelXPath = new ComponentScopeXPathBuilder(options).
                WrapWithIndex(x => x.Descendant._("label")[y => y.TermsConditionOfContent]);

            IWebElement label = scope.Get(By.XPath(labelXPath).With(searchOptions).Label(options.GetTermsAsString()));

            if (label == null)
            {
                if (searchOptions.IsSafely)
                    return new MissingComponentScopeLocateResult();
                else
                    throw ExceptionFactory.CreateForNoSuchElement(options.GetTermsAsString(), searchContext: scope);
            }

            string elementId = label.GetAttribute("for");
            if (string.IsNullOrEmpty(elementId))
            {
                return new SequalComponentScopeLocateResult(label, new FindFirstDescendantStrategy());
            }
            else
            {
                ComponentScopeLocateOptions idOptions = options.Clone();
                idOptions.Terms = new[] { elementId };
                idOptions.Index = null;
                idOptions.Match = TermMatch.Equals;

                return new SequalComponentScopeLocateResult(scope, new FindByIdStrategy(), idOptions);
            }
        }
开发者ID:atata-framework,项目名称:atata,代码行数:30,代码来源:FindByLabelStrategy.cs

示例11: WaitForAutocomplete

 public void WaitForAutocomplete(IWebElement el)
 {
     new WebDriverWait(driver, TimeSpan.FromSeconds(explTimeout)).Until<Boolean>(drv =>
     {
         return (el.Displayed && el.FindElements(By.CssSelector("li")).Count > 0);
     });
 }
开发者ID:jar11,项目名称:automation,代码行数:7,代码来源:WebPage.cs

示例12: AssertElementsPresent

 public static void AssertElementsPresent(IWebElement[] elements, string elementDescription)
 {
     if (elements.Length == 0)
     {
         throw new AssertionException(String.Format("AssertElementsPresent Failed: Could not find '{0}'", elementDescription));
     }
 }
开发者ID:SiteOneSoftware,项目名称:RegistrationFormBddTest,代码行数:7,代码来源:CommonBase.cs

示例13: AssertElementPresent

 public static void AssertElementPresent(IWebElement element, string elementDescription)
 {
     if (!IsElementPresent(element))
     {
         throw new AssertionException(String.Format("AssertElementPresent Failed: Could not find '{0}'", elementDescription));
     }
 }
开发者ID:SiteOneSoftware,项目名称:RegistrationFormBddTest,代码行数:7,代码来源:CommonBase.cs

示例14: GetTableBody

        private static IEnumerable<Row> GetTableBody(IWebElement tableElement)
        {
            var bodyElement = tableElement.FindElement(By.TagName("tbody"));
            var bodyRows = bodyElement.FindElements(By.TagName("tr"));

            var rows = new List<Row>();

            for (int rowIndex = 0; rowIndex < bodyRows.Count; rowIndex++)
            {
                var bodyRow = bodyRows[rowIndex];
                var cells = bodyRow.FindElements(By.TagName("td"));

                var row = new Row { Index = rowIndex };

                for (int columnIndex = 0; columnIndex < cells.Count; columnIndex++)
                {
                    var cell = cells[columnIndex];
                    row.Cells.Add(new Cell { ColumnId = columnIndex, Value = cell.Text, WebElement = cell });
                }

                rows.Add(row);
            }

            return rows;
        }
开发者ID:endjin,项目名称:Endjin.SpecFlow.Selenium,代码行数:25,代码来源:WebElementExtensions.cs

示例15: Check

 public static void Check(IWebElement checkbox)
 {
     if (!IsChecked(checkbox))
     {
         checkbox.Click();
     }
 }
开发者ID:DarthFubuMVC,项目名称:Serenity,代码行数:7,代码来源:CheckboxHandler.cs


注:本文中的IWebElement类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。