I am new to selenium and trying to write linktext code for the html code
<a href="repopulateUser.jsp?authAuthSessionId=7DD74346650647B7BA9ED08C1ABAE66D&roleId=bc95f1f2-9ccd-11e8-9a37-0050568817ef&ROLE=Programmer&ROLECODE=PROGRAMMER&roleGrpId=f4c11ca7-9c1b-11e8-9a37-0050568817ef&moduleId=cb475927-7eb1-11e8-97d0-0050568817ef&studyId=null" class="labels">Programmer</a>
Code trial:
driver.findElement(By.linkText("Programmer")).click();
the code above is not working, is something wrong?
linkText should work if the element with the text Programmer is uniquely identified within the HTML. Still as the element is a JavaScript enabled element so to
click()
on the element you need to useelementToBeClickable()
and you can use the following Locator Strategy:linkText
:Alternative
As an alternative you can also use either of the following Locator Strategies:
cssSelector
:xpath
: