I originally didn't like the getTable function in Selenium very much. Mostly, I didn't like the cell adressing approach it uses. I, therefore, used to use getText and iterate the table. I am usually stuck using an iterative approach as much of our content is dynamically generated and no predictable properties are created at generation time. I figured since getText/getAttribute would get at the same information ultimately, getTable had no use in my toolbox.
What I didn't realize is how unbelievably slow getText/getAttribute can be when attempting to crawl a table on a page. The cells are addressed using xpath in this case, often very long xpath. If there is one hit on Selenium it is that resolving long xpath is very, very slow. Reading the contents of a table using this approach took 40 or 50 minutes! Whilst I don't normally worry about performance a great deal on test code, this timeframe was ridiculous.
So, being the curious type, I tried getTable. ZOMG! WAY faster. getTable does only read the text from the cell, however, so if you need more than that you'll be stuck using getText/getAttribute. However, getting the text of the cell faster may allow you to avoid having to iterate the whole table to find what you need using getText/getAttribute.
Print | posted on Monday, March 16, 2009 9:28 AM