![]() | Using brittle object identification |
|
16 Aug 2012, 19:44
Chuck van der Linden (3 posts) |
In the Parsing HTML tables recipe you are identifying the table by ordinal position on the page. That tends to create a brittle test that will break if anyone adds or removes another table on the page anywhere above the one used in the test. Would it be better to show creating more testable HTML and assigning a Name or ID attribute to the table element which would then allow:
|
|
21 Aug 2012, 04:53
Ian Dees (192 posts) |
Hi, Chuck. You’re right: the best approach is to identify HTML elements by name, ID, or (in a pinch) CSS attribute. Nearly anything is better than a raw ordinal. We were using it here only as an example of dirty HTML that we (hypothetically) didn’t have direct control over. I should have explained in the text why we tested it this way, and will correct that in the next beta. Good catch, and thank you. Sincerely, Ian |
| You must be logged in to comment |

