• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# IWebElement类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: Execute

        protected override void Execute(IWebDriver driver, dynamic context, IWebElement element)
        {
            var resolvedText = Test.ResolveMacros(Text);
            var resolvedValue = Test.ResolveMacros(Value);

            var isValue = String.IsNullOrWhiteSpace(resolvedText);

            var stringComparison = IsCaseSensitive
                ? StringComparison.InvariantCulture
                : StringComparison.InvariantCultureIgnoreCase;

            var option = isValue
                ? element.GetOptionByValue(resolvedValue, stringComparison)
                : element.GetOptionByText(resolvedText, stringComparison);

            if (option == null)
            {
                var key = isValue ? "Value" : "Text";
                var value = isValue ? resolvedValue : resolvedText;
                var message = String.Format("Unable to locate option by {0}: {1}", key, value);
                throw new Exception(message);
            }

            var isSelected = option.IsSelected();

            if (IsFalseExpected)
                Assert.False(isSelected);
            else
                Assert.True(isSelected);
        }
开发者ID:MGetmanov,项目名称:Selenite,代码行数:30,代码来源:IsDropdownSelectedCommand.cs


示例17: OpenInNewTab

 public static void OpenInNewTab(IWebElement item)
 {
     var url = item.FindElement(By.TagName("a"));
     url.SendKeys(Keys.Control + Keys.Return);
     url.SendKeys(Keys.Control + Keys.Tab);
     Cons.driver.SwitchTo().Window(Cons.driver.WindowHandles[Cons.driver.WindowHandles.Count - 1]);
 }
开发者ID:Polivando,项目名称:Rozetka,代码行数:7,代码来源:Cons.cs


示例18: GetElementPositionWithinUsableViewport

 public static Point GetElementPositionWithinUsableViewport(this IWebDriver driver, IWebElement element)
 {
     var elementRect = new Rectangle(element.Location.X, element.Location.Y, element.Size.Width, element.Size.Height);
     var scrollY = elementRect.Top;
     var scrollX = elementRect.Left;
     return new Point(scrollX, scrollY);
 }
开发者ID:jw56578,项目名称:SpecFlowTest,代码行数:7,代码来源:WebDriverExtensions.cs


示例19: HandleElement

        private void HandleElement(IWebElement el, IWebDriver browser, string[] parameters)
        {
            el.Clear();
            var keystroke = KeywordUtility.ReadParameterValue(_variables, parameters[2]);

            el.SendKeys(keystroke);
        }
开发者ID:rainymaple,项目名称:WebTester,代码行数:7,代码来源:SendKeys.cs


示例20: LikeButton

		public LikeButton(IWebElement like)
		{
			if (like == null)
				throw new NotFoundException("like button not found");
			this.like = like;
			isLiked = UlearnDriver.HasCss(like, "btn-primary");
		}
开发者ID:andgein,项目名称:uLearn,代码行数:7,代码来源:LikeButton.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# IWebHelper类代码示例发布时间:2022-05-24
下一篇:
C# IWebDriver类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap