I have following source-code
:
main.container-fluid:nth-child(5)<main class="container-fluid ng-scope" ng-view=""><div class="row ng-scope">
<section class="col-md-8 col-md-offset-2 col-sm-10 col-sm-offset-1">
<h3 ng-show="searchQuery" class="page-header page-header-sm ng-hide"><span translate="TITLE_SEARCH_RESULTS" class="ng-scope">Search Results</span> <span class="label label-default ng-binding" ng-bind-html="searchQuery"></span></h3>
<h3 ng-show="!searchQuery" class="page-header page-header-sm ng-scope" translate="TITLE_ALL_PRODUCTS">All Products</h3>
<div class="alert-info ng-hide" ng-show="confirmation">
<p class="ng-binding"></p>
</div>
</section>
(this is just a part of the source code
here is the full Source code)
Now I want to verify if the source code
contains All Products
.
Notice: I got, that text content on multi places same page so its important I select this one (for XPath
).
This is my code I wrote so far:
IList<IWebElement> links = Driver.Instance.FindElements(By.XPath("//h3[@class='page-header page-header-sm ng-scope']"));
IList<IWebElement> listOflinks = new List<IWebElement>();
for (int i = 0; i < links.Count; i++)
{
links = Driver.Instance.FindElements(By.XPath("//h3[@class='page-header page-header-sm ng-scope']"));
if (!string.IsNullOrEmpty(links[i].Text))
//links[i].Click();
Console.WriteLine(links[i].ToString());
}
Then I return in the console:
Element (id = c25b9ecd-b828-4353-a9d8-9f8a53b9cee9)
but the goal is instead to write in the console All Products
+ verify its there.
maybe could be done with Assert
?
Could someone help me to correct the code?