The link I would like to click is input by the user. For example the user inputs for variable track, "Tampa Bay Downs"
My python selenium test program will search the code below:
<a ng-click="updateFavorite()(raceInfo.trackAbbr); $event.stopPropagation();">EV
i class="my-icon-favorite-fill my-icon-favorite-fill_active" ng-class="{
'my-icon-favorite-fill' : !showActionFeedback, ...onFeedback, 'rotating spinner' :
showActionFeedback}" update-favorite-action-feedback="" qa-label="race-favorite-icon">
::before
</i>
</a>
<span class="ng-binding" ng-bind="::raceInfo.trackName" qa-label="race-track-name">
Tampa Bay Downs</span>
</td>
The successful code will find the input words "Tampa Bay Downs" and then click it to activate an angularjs action that would cause a separate page to open, which is the desired action.
I have tried to find the link using the correct xpath with no success.
I have also tried this with no success:
try:
element = driver.find_element_by_css_selector("a[qa-label="+track+"]")
except:
print "error finding css selector for track"
"//span[contains(.,'{}')]/preceding-sibling::a".format(track)or use the class name to be more specific"//span[@qa-label='race-track-name' and contains(.,'{}')]/preceding-sibling::a".format(track)