How To Identify ATags with StrongTags/EmTags

Technology specific object identification, supported applications, web technologies, and 3rd party controls.
Posts: 1
Joined: Thu Sep 04, 2014 4:21 am

How To Identify ATags with StrongTags/EmTags

Post by feeblemind099 » Thu Sep 04, 2014 4:41 am


I am looping through search results, say for example Google. And I am searching for Technical Testing.. From the results page, I want to click on the link for "Technical Web Testing 101 - Udemy"..

Thing is, since the ATags have StrongTags/EmTags in them.. the innerText value is somewhat parsed or cut to get rid of the bold texts. say from the above example,

innertext becomes /dom[@domain=link]//ol[#'rso']/div[2]/li[5]//a[@innertext=' Web 101 - Udemy']

how do I make the code data driven that on whenever I tried to search, I will still look on the link as a whole, but just wanted to click the correct innerText value?

Code is something like:

var ds = new DataSet();
var table = ds.Tables.Add("SearchTechnicalTestingInGoogle");
table.Columns.Add("Id", typeof (Int32));
table.Columns.Add("SearchCriteria", typeof (String));
table.Columns.Add("Results", typeof (String));

var idCol = table.Columns["Id"];
idCol.AutoIncrement = true;

var row = table.NewRow();
row.SetField("SearchCriteria", "Technical Testing");
row.SetField("Results", "Technical Web Testing 101 - Udemy");

foreach (DataRow dr in table.Rows)
var searchTxtBox = doc.FindSingle<InputTag>("...");
searchTxtbox.TagValue = dr.Field<string>("SearchCriteria");

var searchResults = dr.Field<string>("Results");

if (!TryFindResult(searchResults))
throw new Exception("Test Failed. Search Criteria not found.");

public bool TryFindResult(string searchResults)
bool wasLinkFound = false;
string[] words = searchResults.Split(' ');

foreach (string word in words)
if notboldwords
i want to concat them, say concatText
string concatLink = "...path.. a[@innertext~'" + concatText + "']
var linkToClick = doc.FindSingle<ATag>(concatLink)
wasLinkFound = true;
return wasLinkFound;

And since it is data driven, if I cannot find the string up to the last page, it will return something like, I cannot find the link etc.


User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA

Re: How To Identify ATags with StrongTags/EmTags

Post by Support Team » Mon Sep 08, 2014 3:03 pm

Hello feeblemind099,

I’m afraid that it’s not possible to identify an “a-tag” based on its inner text without knowing its actual “inner text”. Since the Google search generates the “inner text” based on keywords etc. it won’t be possible to search for the link as a whole.

In order to iterate over the links you will need to use the correct “inner text” for object identification. For example: ‘ Web 101 - Udemy’ instead of “Technical Web Testing 101 – Udemy”.