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

C# ISearchContext类代码示例

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

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



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

示例1: FindElements

        /// <summary>
        /// Finds many elements
        /// </summary>
        /// <param name="context">Context used to find the element.</param>
        /// <returns>A readonly collection of elements that match.</returns>
        public override ReadOnlyCollection<IWebElement> FindElements(ISearchContext context)
        {
            if (this.bys.Length == 0)
            {
                return new List<IWebElement>().AsReadOnly();
            }

            List<IWebElement> elems = null;
            foreach (By by in this.bys)
            {
                List<IWebElement> newElems = new List<IWebElement>();

                if (elems == null)
                {
                    newElems.AddRange(by.FindElements(context));
                }
                else
                {
                    foreach (IWebElement elem in elems)
                    {
                        newElems.AddRange(elem.FindElements(by));
                    }
                }

                elems = newElems;
            }

            return elems.AsReadOnly();
        }
开发者ID:Zekom,项目名称:selenium,代码行数:34,代码来源:ByChained.cs


示例2: FindElements

        public override ReadOnlyCollection<IWebElement> FindElements(ISearchContext context)
        {
            // Create script arguments
            object[] scriptArgs = new object[this.args.Length + 1];
            scriptArgs[0] = this.RootElement;
            Array.Copy(this.args, 0, scriptArgs, 1, this.args.Length);

            // Get JS executor
            IJavaScriptExecutor jsExecutor = context as IJavaScriptExecutor;
            if (jsExecutor == null)
            {
                IWrapsDriver wrapsDriver = context as IWrapsDriver;
                if (wrapsDriver != null)
                {
                    jsExecutor = wrapsDriver.WrappedDriver as IJavaScriptExecutor;
                }
            }
            if (jsExecutor == null)
            {
                throw new NotSupportedException("Could not get an IJavaScriptExecutor instance from the context.");
            }

            ReadOnlyCollection<IWebElement> elements = jsExecutor.ExecuteScript(this.script, scriptArgs) as ReadOnlyCollection<IWebElement>;
            if (elements == null)
            {
                elements = new ReadOnlyCollection<IWebElement>(new List<IWebElement>(0));
            }
            return elements;
        }
开发者ID:JP-3,项目名称:protractor-net,代码行数:29,代码来源:JavaScriptBy.cs


示例3: CreateBys

        public static IEnumerable<By> CreateBys(ISearchContext context, MemberInfo member)
        {
            string platform = GetPlatform(context);
            string automation = GetAutomation(context);

            IEnumerable<By> defaultBys = CreateDefaultLocatorList(member);
            ReadOnlyCollection<By> defaultByList = new List<By>(defaultBys).AsReadOnly();

            IEnumerable<By> nativeBys = CreateNativeContextLocatorList(member, platform, automation);
            IList<By> nativeByList = null;

            if (nativeBys == null)
                nativeByList = defaultByList;
            else
                nativeByList = new List<By>(nativeBys).AsReadOnly();

            Dictionary<ContentTypes, IEnumerable<By>> map = new Dictionary<ContentTypes, IEnumerable<By>>();
            map.Add(ContentTypes.HTML, defaultByList);
            map.Add(ContentTypes.NATIVE, nativeByList);
            ContentMappedBy by = new ContentMappedBy(map);
            List<By> bys = new List<By>();
            bys.Add(by);

            return bys.AsReadOnly();
        }
开发者ID:suryarend,项目名称:appium-dotnet-driver,代码行数:25,代码来源:ByFactory.cs


示例4: LocateElement

        /// <summary>
        /// Locates an element using the given <see cref="ISearchContext"/> and list of <see cref="By"/> criteria.
        /// </summary>
        /// <param name="searchContext">The <see cref="ISearchContext"/> object within which to search for an element.</param>
        /// <param name="bys">The list of methods by which to search for the element.</param>
        /// <returns>An <see cref="IWebElement"/> which is the first match under the desired criteria.</returns>
        public IWebElement LocateElement(ISearchContext searchContext, IEnumerable<By> bys)
        {
            if (searchContext == null)
            {
                throw new ArgumentNullException("searchContext", "searchContext may not be null");
            }

            if (bys == null)
            {
                throw new ArgumentNullException("bys", "List of criteria may not be null");
            }

            string errorString = null;
            foreach (var by in bys)
            {
                try
                {
                    return searchContext.FindElement(by);
                }
                catch (NoSuchElementException)
                {
                    errorString = (errorString == null ? "Could not find element by: " : errorString + ", or: ") + by;
                }
            }

            throw new NoSuchElementException(errorString);
        }
开发者ID:BogdanLivadariu,项目名称:selenium,代码行数:33,代码来源:DefaultElementLocatorFactory.cs


示例5: 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


示例6: WebElement

		/// <summary>
		/// Initializes a new instance of the <see cref="WebElement" /> class.
		/// </summary>
		/// <param name="searchContext">The driver used to search for elements.</param>
		protected internal WebElement(ISearchContext searchContext)
		{
			this.searchContext = searchContext;
			
			this.bys = new List<By>();
			this.Cache = true;
		}
开发者ID:lopezn,项目名称:specbind,代码行数:11,代码来源:WebElement.cs


示例7: RelatedOppsSections

 public RelatedOppsSections(ISearchContext context)
     : base(context)
 {
     Element("Title", By.CssSelector(".contact-opportunity__name"));
     Element("Stage", By.CssSelector(".contact-opportunity .contact-opportunity__status:nth-of-type(1)"));
     Element("Value", By.CssSelector(".contact-opportunity .contact-opportunity__status:nth-of-type(2)"));
 }
开发者ID:justintaylor,项目名称:actEssentials,代码行数:7,代码来源:RelatedSection.cs


示例8: TestSearchContext

 public TestSearchContext(TestSettings settings, By selfSelector, ISearchContext context,Func<IWebElement> selfLookup)
 {
     _settings = settings;
     _selfSelector = selfSelector;
     _context = context;
     _selfLookup = selfLookup;
 }
开发者ID:Jayman1305,项目名称:Selenium.Extensions,代码行数:7,代码来源:TestSearchContext.cs


示例9: AssertElementPresent

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


示例10: SetUp

 public void SetUp()
 {
     mocks = new Mockery();
     mockDriver = mocks.NewMock<ISearchContext>();
     mockElement = mocks.NewMock<IWebElement>();
     mockExplicitDriver = mocks.NewMock<IWebDriver>();
 }
开发者ID:RanchoLi,项目名称:selenium,代码行数:7,代码来源:PageFactoryTest.cs


示例11: FindElements

        public override ReadOnlyCollection<IWebElement> FindElements(ISearchContext context)
        {
            var scriptExecutor = DriverWrapperUnwrapper.GetDriverImplementationOf<IJavaScriptExecutor>(context);

            EnsureScriptIsLoaded(scriptExecutor);

            IEnumerable<object> scriptResult = null;

            object executeScript;

            if (context is IWebElement)
            {
                executeScript = scriptExecutor.ExecuteScript("return " + resultPrefix + javascriptGlobal + "(" + selector + ", arguments[0])" + resultPosftix, context);
            }
            else
            {
                executeScript = scriptExecutor.ExecuteScript("return " + resultPrefix + javascriptGlobal + "(" + selector + ")" + resultPosftix);
            }

            scriptResult = (IEnumerable<object>)executeScript;

            var result = new ReadOnlyCollection<IWebElement>(scriptResult.Cast<IWebElement>().ToList());

            return result;
        }
开发者ID:fschwiet,项目名称:SizSelCsZzz,代码行数:25,代码来源:ByExternalScript.cs


示例12: WebElementProxy

 /// <summary>
 /// Initializes a new instance of the <see cref="WebElementProxy"/> class.
 /// </summary>
 /// <param name="searchContext">The driver used to search for elements.</param>
 /// <param name="bys">The list of methods by which to search for the element.</param>
 /// <param name="cache"><see langword="true"/> to cache the lookup to the element; otherwise, <see langword="false"/>.</param>
 /// <param name="locatorFactory">The <see cref="IElementLocatorFactory"/> implementation that
 /// determines how elements are located.</param>
 internal WebElementProxy(ISearchContext searchContext, IEnumerable<By> bys, bool cache, IElementLocatorFactory locatorFactory)
 {
     this.locatorFactory = locatorFactory;
     this.searchContext = searchContext;
     this.bys = bys;
     this.cache = cache;
 }
开发者ID:JacquesBonet,项目名称:selenium-1,代码行数:15,代码来源:WebElementProxy.cs


示例13: FindTextbox

        public static IWebElement FindTextbox(ISearchContext context, IWebElement element)
        {
            var id = element.GetAttribute("id");
            var labelId = id + "Value";

            return context.FindElement(By.Id(labelId));
        }
开发者ID:DarthFubuMVC,项目名称:FubuMVC.AutoComplete,代码行数:7,代码来源:AutoCompleteHandler.cs


示例14: FindElements

        /// <summary>
        /// Finds many elements
        /// </summary>
        /// <param name="context">Context used to find the element.</param>
        /// <returns>A readonly collection of elements that match.</returns>
        public override ReadOnlyCollection<IWebElement> FindElements(ISearchContext context)
        {
            if (this.bys.Length == 0)
            {
                return new List<IWebElement>().AsReadOnly();
            }

            IEnumerable<IWebElement> elements = null;
            foreach (By by in this.bys)
            {
                ReadOnlyCollection<IWebElement> foundElements = by.FindElements(context);
                if (foundElements.Count == 0)
                {
                    // Optimization: If at any time a find returns no elements, the
                    // only possible result for find-all is an empty collection.
                    return new List<IWebElement>().AsReadOnly();
                }

                if (elements == null)
                {
                    elements = foundElements;
                }
                else
                {
                    elements = elements.Intersect(by.FindElements(context));
                }
            }

            return elements.ToList().AsReadOnly();
        }
开发者ID:RanchoLi,项目名称:selenium,代码行数:35,代码来源:ByAll.cs


示例15: Execute

 /// <summary>
 /// Executes the specified context.
 /// </summary>
 /// <param name="context">The context.</param>
 /// <returns></returns>
 public IEnumerable<SearchResult> Execute(ISearchContext context)
 {
     using (var session = this._dbFunction.CreateSession())
     {
         return session.GetTyped<SearchResult>(r => r.executesearch(context));
     }
 }
开发者ID:bugjohnyang,项目名称:YAFNET,代码行数:12,代码来源:MsSqlSearch.cs


示例16: FindElements

        /// <summary>
        /// Finds many elements
        /// </summary>
        /// <param name="context">Context used to find the element.</param>
        /// <returns>A readonly collection of elements that match.</returns>
        public override ReadOnlyCollection<IWebElement> FindElements(ISearchContext context)
        {
            List<IWebElement> elements = new List<IWebElement>();
            elements.AddRange(this.idFinder.FindElements(context));
            elements.AddRange(this.nameFinder.FindElements(context));

            return elements.AsReadOnly();
        }
开发者ID:JacquesBonet,项目名称:selenium-1,代码行数:13,代码来源:ByIdOrName.cs


示例17: GetData

        public string GetData(ISearchContext context, IWebElement element)
        {
            // TODO:   discuss how to fix in a more elegant manner.  ISearchContext reference is null here 
            // so we use the one we hijacked from EnterData
            IWebElement textbox = FindTextbox(_searchContext, element);

            return new TextboxElementHandler().GetData(_searchContext, textbox);
        }
开发者ID:DarthFubuMVC,项目名称:FubuMVC.AutoComplete,代码行数:8,代码来源:AutoCompleteHandler.cs


示例18: EraseData

 public virtual void EraseData(ISearchContext context, IWebElement element)
 {
     if (element.GetAttribute("value").IsNotEmpty())
     {
         element.Click();
         element.SendKeys(Keys.Home + Keys.Shift + Keys.End + Keys.Backspace);
     }
 }
开发者ID:DarthFubuMVC,项目名称:Serenity,代码行数:8,代码来源:TextboxElementHandler.cs


示例19: EnterData

        public void EnterData(ISearchContext context, IWebElement element, object data)
        {
            while (element.GetAttribute("value").IsNotEmpty())
            {
                element.SendKeys(Keys.Backspace);
            }

            element.SendKeys(data as string ?? string.Empty);
        }
开发者ID:jemacom,项目名称:fubumvc,代码行数:9,代码来源:TextboxElementHandler.cs


示例20: GetData

        public string GetData(ISearchContext context, IWebElement element)
        {
            var selected = findSelected(element);

            if (selected == null) return "Nothing";

            var value = selected.GetAttribute("value");
            return value.IsEmpty() ? selected.Text : "{0}={1}".ToFormat(selected.Text, value);
        }
开发者ID:jemacom,项目名称:fubumvc,代码行数:9,代码来源:SelectElementHandler.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# ISearchCriteria类代码示例发布时间:2022-05-24
下一篇:
C# ISdmxObjects类代码示例发布时间: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