Find Elements with different ways

Two different ways for find a element of a list in a page with WebDriver:

To find a element that inside in a span css and contains some text, you can use the lambda and catch the array for this elements: 

> Lambda expression
bsaNavigator.FindElements(By.TagName(“span“)).Where(o => o.Text == “@Text“).ToList()
                                       

Or you can select the element, like SQl expression, remember of change the variables and the type of the source (span, div, table, tr and others). @Text is the variable that you will search in this span elements .

> Linq
                                       
var spans = from p in bsaNavigator.FindElements(By.TagName(“span“)) where p.Text == “@Text” select p;

 

Do you have some doubt ? You can ask me in the comments !

Bye bye 🙂

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.