I am currently working on automating tests using Java WebDriver with Eclipse and TestNG.
One of the challenges I am facing is locating an element named 'Tests 142' on a web page. The issue is that the number '142' in the element name keeps changing as it represents a count of records. I initially tried using partialLinkText technique to locate the element, but it failed because there is another element with the name 'Tests' on the page which interferes with the locator. Can anyone assist me in creating a dynamic element locator for 'Tests 142' that can accurately solve this problem?
HTML Code:
html>
<head>
<body>
<div id="errorMsgContainer" class="ui-widget-header"> </div>
<script type="text/javascript">
<style>
<div id="help" class="help">
<div class="wrapper">
<div id="header">
<div id="mainMenu">
<br clear="all">
<div class="siteWrapper">
<div id="content">
<div id="main" class="main">
<h2>
<ul id="" class="tabPane" style="padding-left:5px;">
<div class="tabPage">
<ul id="" class="tabPaneVertical" style="padding-left:5px;">
<li id="items_" class="">
<li id="items_" class="">
<li id="items_" class="active">
<div>
<a href="/test2/1/p/a/projects/project/tests/project_id/1">
Tests
<span>142</span>
</a>
<div class="children">
</div>
</li>
<li id="items_" class="">
<li id="items_" class="">
<li id="items_" class="">
<li id="items_" class="">
<li id="items_" class="">
</ul>
<div class="tabPageVertical">
<script type="text/javascript">
</div>
</div>
<div id="footer"></div>
<div class="clear"></div>
</div>
<div class="footer">Powered by 2 © 2006-2013 v1.4.9.3</div>
<script>
</div>
<div id="ui-datepicker-div" class="ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all"></div>
</body>
</html>
Thank you for your assistance.