Test Driven Developer
You got a TEST for that?
Home
|
Syndication
|
Sign In
Monday, July 21, 2008
Drag and Drop in Selenium
I learned a valuable lesson today using Selenium. It seems that the DragAndDropToObject() function doesn't scale well when the HTML is being updated in a loop by the mainline code... This method uses two locator strings, one to find the object to drag, and the other to find the object to drop.
It apparently has to examine the entire XML DOM for each locator, each time through. So, when I created a loop that did a drag and drop 250 times on a page, the first few were not too bad only a couple hundred milliseconds. However, as more and more DHTML was added to the page, it took longer and longer to drop the next objects. I measured this time, and when I charted the data, it was a moderately increasing exponential slope. Definitely not even linear...
It seems that the more HTML was added to the DOM, the longer it took both of the locators to locate their objects, even though those objects were static on the page. It walked the DOM each time, for each locator. Thus the increasing non-linear time slope, because the DOM grows with every loop iteration.
By the time it got to the 50th iteration through the loop, the time taken was almost 2 orders of magnitude higher than the initial one. It made testing this particular feature not doable through this framework. And in measuring how long it took the actual javascript to render the new DHTML, it was just around 100ms, when the Selenium locates for the command took upwards of 7000ms for the 50th loop, but was only 200ms at the initial loop.
The Solution
I didn't find a complete solution to the excruciating amount of time the locator code needs to walk the DOM, but I did end up switching from the DragAndDropToObject() method to the DragAndDrop() method. The latter uses one locator string and a relative X,Y coordinate string (NOT a locator). It's just about zero time for it to process the relative coordinate string rather than the locator. So, in my specific case with this test, I was able to cut the time down to 2.5 seconds for the 250th drag and drop. Still a very LONG running test, but it worked (oh yeah and it found a nice juicy bug too...).
OpenQA people - it might behoove you to take a look at optimizing how you interact with a DOM that is growing or being updated by the code under test... A bit of performance gain in this area would really come in handy.
Automation
|
Selenium
|
Testing
Monday, July 21, 2008 10:33:26 PM (Pacific Standard Time, UTC-08:00)
Comments [0]
|
Comments are closed.
© Copyright 2008, John E. Boal
Calendar
<
December 2008
>
Sun
Mon
Tue
Wed
Thu
Fri
Sat
30
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
1
2
3
4
5
6
7
8
9
10
Total Posts: 30
This Year: 30
This Month: 0
This Week: 0
Comments: 17
Archives
November, 2008 (2)
October, 2008 (2)
September, 2008 (4)
August, 2008 (3)
July, 2008 (5)
June, 2008 (4)
May, 2008 (1)
April, 2008 (2)
March, 2008 (4)
February, 2008 (2)
January, 2008 (1)
On this page
categories
ABN
Acceptance Criteria
ATDD
Automation
C#
Mocks
MSTest
Python
Refactoring
Selenium
SQL
TDD
Testing
Tools
Unit Tests
WatiN
Links
Home
Test Driven Development, Defined (Wikipedia)
Test Driven Design
Test-Driven.com - Agile development tools
NUnit
Book: Test-Driven Development in Microsoft .NET
CodeProject - Advanced Unit Testing: Unit Test Patterns
John Boal's Personal Blog
John Boal's Agile Development Blog
Blogroll
OPML
Lazy Coder
Scott Koon's Blog
#2782
Ade Miller's Tech Blog
Agile Development
Mitch Lacey's Agile Development Blog
Espresso Fueled Agile Development
Mike Puleio's Blog
Geek Noise
Noise de Peter Provost
Sneal's Blog
Shawn Neal's Blog
Search
About
© Copyright 2008, John E. Boal
Sign In