1

Below is code for tab - account.This is third tab. I have to go on tab but I am not able to identify

 <td class="buttons" nowrap="nowrap" title="Shows data of bank account"
 onclick="document.forms[0].debbuttonpressed.value='CONTO';EmptyHiddenButtonValues('CONTO');;
document.forms[0].submit();" style="background-image:url(/images/reiter_unchecked_middle.gif);
background-repeat:repeat-x;cursor:pointer;" heigth="21">Account</td>
3
  • Welcome to SQA, rohit ware. What have you tried so far? Also, can you tell us about the elements that precede/follow that tab? Fir example, do any of the other tabs read "Account"?
    – user246
    Commented Feb 23, 2012 at 12:28
  • there is no other tab with name 'account'...I have tried xpath=(//td[@onclick="document.forms[0].debbuttonpressed.value='CONTO';EmptyHiddenButtonValues('CONTO');;document.forms[0].submit();"])[2] this one..but sometimes it runs sometimes fails
    – rohit ware
    Commented Feb 23, 2012 at 14:34
  • This is virtually the same question you asked last time and again, you are not providing enough details. Please include more of the html, otherwise it is nearly impossible to help.
    – Sam Woods
    Commented Feb 23, 2012 at 17:35

2 Answers 2

1

Since there are no other tabs with the name 'Account', the first xpath I would try would be:

//td[text()='Account']
4
  • It is generally not a best practice to identify elements based on the text visible to a user instead of the markup. The main reason would be the ability to run in localized builds, but it is also more likely to change. Even a change to add non breaking spaces for formatting could break this.
    – Sam Woods
    Commented Feb 23, 2012 at 17:33
  • 2
    @Sam Woods I agree that if an application is intended to be localized, identifying by text is risky. I appreciate that someone with a long history at Microsoft might be sensitive to internationalization! However, identifying by text it is probably less risky than identifying by the Javascript in its onclick callback. Perhaps rohit ware will divulge more about the contents of the page.
    – user246
    Commented Feb 23, 2012 at 17:47
  • I completely agree that it is better than using the javascript onclick, but would still rather find a different way to identify it, which would require more info from rohit about the surrounding html.
    – Sam Woods
    Commented Feb 23, 2012 at 19:09
  • I have tried this solution for all tab and all are working fine.
    – rohit ware
    Commented Feb 24, 2012 at 5:20
1

Is it too obvious to use the "title" attribute?

//td[@title='Shows data of bank account']

On a different note, you could also look at the parent element and identify it, then draw reference to the particular tab your after.

E.g. if the cell td is within a table row:

//tr[@foo=bar]/td[x]

where x is the child xth td element of the tab your after.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.