write_textfield fails on OSX - improper clear action

Bug #1051683 reported by Bartosz Szerszon
16
This bug affects 2 people
Affects Status Importance Assigned to Milestone
selenium-simple-test
Confirmed
Medium
Unassigned

Bug Description

Bug is really easy to reproduce, just use the function write_textfield(id_or_elem, new_text, check, clear) in OSX context.

Issue araised due to the fact that OSX uses combination of CMD&A to select all text while in SST code there is only one call to CTRL&A and as a result text is not written properly in the textfield, which causes assertion error on a textfield.

======================================================================
FIX: Function that I've created to work-around this issue
-------------------------------------------------------------------------------------------------------------------------------------
def __osx_clear_textfield(id_or_elem):
    textfield = assert_textfield(id_or_elem)
    textfield.send_keys(keys.Keys().COMMAND, 'a')
    textfield.send_keys(keys.Keys().DELETE)
-------------------------------------------------------------------------------------------------------------------------------------

======================================================================
BUG DETAILS
-------------------------------------------------------------------------------------------------------------------------------------
Traceback (most recent call last):
  File "/.../sst/runtests.py", line 276, in test
    exec self.code in context
...
    write_textfield(id_or_elem, new_text)
  File "/.../sst/actions.py", line 509, in write_textfield
    _raise(msg)
  File "/.../sst/actions.py", line 109, in _raise
    raise AssertionError(msg)
AssertionError: Textfield: 'xxx' - did not write. Text was: u'yyy'
-------------------------------------------------------------------------------------------------------------------------------------

Revision history for this message
Martin Haye (martin-haye) wrote :

Here is a patch that switches based on the platform and I have found to be reliable:

--- src/sst/actions.py 2012-11-04 11:58:17.000000000 -0800
+++ src/sst/actions.py 2013-01-04 16:12:36.000000000 -0800
@@ -507,7 +507,10 @@

     # clear field like this, don't use clear()
     if clear:
- textfield.send_keys(keys.Keys().CONTROL, 'a')
+ if 'Darwin' in browser.capabilities.get("platform", ""):
+ textfield.send_keys(keys.Keys().COMMAND, 'a') # Mac-only
+ else:
+ textfield.send_keys(keys.Keys().CONTROL, 'a')
         textfield.send_keys(keys.Keys().DELETE)

     if isinstance(new_text, unicode):

Revision history for this message
Martin Haye (martin-haye) wrote :

Sorry the indentation got changed when I submitted the patch as part of my comment. Is there a better way I should have submitted the patch?

Revision history for this message
Jason Dunckley (coloradojay) wrote :

I entered a second duplicate for this (doh!) Bug #1100550, however I proposed an alternate solution to the conditional, which was to implement double_click (which could also be exposed as an action), which should work in a platform independent way.

Revision history for this message
Martin Haye (martin-haye) wrote :

Jason, wouldn't it actually need to be a triple-click? Double-click (at least on my Mac in Firefox and Chrome) selects a whole word rather than the entire contents of the field.

Also, you'll have to be certain to click in the right spot, but that seems doable.

Vincent Ladeuil (vila)
Changed in selenium-simple-test:
status: New → Confirmed
importance: Undecided → Medium
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.