c# - LINQ performance issue while trying to find element collection by tag name and then find a specfic one by id or text using selenium webdriver -


I am not an expert in LINQ here what I am trying to do.

A. I am getting a collection of elements of a page using the Selenium WebDriver API

  Private Readonly & lt; IWebElement & gt; Return Page Elements () {Return Driver. Fund Elements (Page Element Selector); }  where PageElementSelector are all HTML tags (because it is a long list, I did not paste it here). I then institute this method inside my baseclass constructor.  

B. I'm using the following to find the target element

  Public IWebElement FindButtonById (String ID) {Return Return Page Elements () FirstOrDefault (webElement = & gt; webElement.TagName == "Button" & amp; Web Element. GetAttribute ("id") == ID); }  

And it has been used here under my test

  click the public plan pageDialplayButtonButton () {FindButtonById ( "BtnDelete") .click (); Return new planpage (driver); }  

My problem is that there are several elements in some pages and LINQ greatly reduces test execution. This is a good concept that I want to implement which can save me a lot of time and code duplication is. Is there a way to increase the performance of this query? I do not need to use LINQ, any solution is appreciated


Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -