Take the 2-minute tour ×
Software Quality Assurance & Testing Stack Exchange is a question and answer site for software quality control experts, automation engineers, and software testers. It's 100% free, no registration required.

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>
share|improve this question
    
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 Feb 23 '12 at 12:28
    
there is no other tab with name 'account'...I have tried xpath=(//td[@onclick="document.forms[0].debbuttonpressed.value='CONTO';EmptyHidd‌​enButtonValues('CONTO');;document.forms[0].submit();"])[2] this one..but sometimes it runs sometimes fails –  rohit ware Feb 23 '12 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 Feb 23 '12 at 17:35
add comment

2 Answers

up vote 1 down vote accepted

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

//td[text()='Account']
share|improve this answer
    
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 Feb 23 '12 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 Feb 23 '12 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 Feb 23 '12 at 19:09
    
I have tried this solution for all tab and all are working fine. –  rohit ware Feb 24 '12 at 5:20
add comment

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.

share|improve this answer
    
Thanks pmafi, this works for me...:) –  rohit ware Feb 24 '12 at 5:21
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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