History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: SEL-563
Type: Bug Bug
Status: Open Open
Priority: Major Major
Assignee: Unassigned
Reporter: Hugh Gibson
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Selenium

Border-width causes element position errors

Created: 17/Jul/08 09:06 AM   Updated: 18/Jul/08 02:26 AM
Component/s: BrowserBot-Mozilla
Affects Version/s: None
Fix Version/s: None

Original Estimate: Unknown Remaining Estimate: Unknown Time Spent: Unknown
File Attachments: 1. HTML File selenium_border_bug.html (2 kb)
2. HTML File selenium_border_bug_simple.html (0.3 kb)

Environment: Firefox 2.0.0.16, Selenium IDE 1.0b2. Windows XP.


 Description  « Hide
A div with border-width specified is not correctly located by Selenium.prototype.getElementPositionTop. and Selenium.prototype.getElementPositionLeft in Firefox.

Something similar to this was reported at http://clearspace.openqa.org/message/32718#32718

Details: I've got some sample HTML with a top-level div with

<div style="border-width: 10px 20px 30px 40px; width: 55px; height: 66px; min-width: 150px; min-height: 26px; left: 100px; top: 100px;" ... snip ...>

There are other divs within this div eventually getting some divs with text content, the first being "Expired". The other divs have 0 border width. Executing Selenium commands in Selenium IDE show that the position calculated is wrong:

# [info] Executing: |assertElementPositionLeft | //div[text()="Expired"] | 140 |
# [error] Actual value '60' did not match '140'
# [info] Executing: |assertElementPositionTop | //div[text()="Expired"] | 110 |
# [error] Actual value '91' did not match '110'

This is an issue because the code is an extract from an AJAX package which has created a popup list under a combo box. We're trying to get the Selenium code to automatically select entries in the popup list, so use something like clickAt (actually a variant supplied by the AJAX provider, qooxdoo, which doesn't have x,y offset). However, the x.y posiiton sent to the Javascript is out by 1 pixel so gets rejected by the mouse handling code as being off the menu.

In the example I have attached here I have exagerated the border so the effect can be seen more clearly.

Hugh


 All   Comments   Work Log   Change History      Sort Order:
Hugh Gibson - 17/Jul/08 09:09 AM
Open this file in Firefox and execute these commands against it in Selenium IDE:

<tr>
<td>assertElementPositionLeft</td>
<td>//div[text()=&quot;Expired&quot;]</td>
<td>140</td>
</tr>

<tr>
<td>assertElementPositionTop</td>
<td>//div[text()=&quot;Expired&quot;]</td>
<td>110</td>
</tr>

Result:

# [info] Executing: |assertElementPositionLeft | //div[text()="Expired"] | 140 |
# [error] Actual value '60' did not match '140'
# [info] Executing: |assertElementPositionTop | //div[text()="Expired"] | 110 |
# [error] Actual value '91' did not match '110'

The left and top position of the div with content "Expired" are way out.

Hugh

Hugh Gibson - 18/Jul/08 02:01 AM
A much simplified version of the test file is attached as selenium_border_bug_simple.html.

There appear to be two bugs: one in Firefox and one in Selenium.

Firstly, remove the "overflow: hidden" from the outer div. The offsetLeft and offsetTop of the inner div is 0, 0 (viewed in Firebug). The position of the inner div should be left = 140, top = 110. However, Selenium calculates it as 100, 100. In other words, the border width of the outer div is not taken into account.

# [info] Executing: |assertElementPositionLeft | //div[text()="Expired"] | 140 |
# [error] Actual value '100' did not match '140'
# [info] Executing: |assertElementPositionTop | //div[text()="Expired"] | 110 |
# [error] Actual value '100' did not match '110'

Secondly, test with the file as uploaded (i.e. reinstate "overflow: hidden"). The inner html element now has offsetLeft of -40 and offsetTop of -10 (viewed in Firebug) . This appears to be a Firefox bug. It means the calculation of inner div position is way out on Selenium now as it isn't taking into account the border OR the buggy offsetLeft/offsetTop.

# [info] Executing: |assertElementPositionLeft | //div[text()="Expired"] | 140 |
# [error] Actual value '60' did not match '140'
# [info] Executing: |assertElementPositionTop | //div[text()="Expired"] | 110 |
# [error] Actual value '90' did not match '110'

Hugh

Hugh Gibson - 18/Jul/08 02:26 AM
Note that Firefox 3.0.1 fixes the negative offsetLeft issue. The problem with border width not being taken into account in Selenium remains.

Hugh