8000 sendKeys not working for key strokes (special keys) · Issue #125 · xebia/Xebium · GitHub
[go: up one dir, main page]

Skip to content
This repository was archived by the owner on Jun 27, 2019. It is now read-only.
This repository was archived by the owner on Jun 27, 2019. It is now read-only.

sendKeys not working for key strokes (special keys) #125

Open

Description

Hi,

I have been trying to send KEY_BACKSPACE using xebium and am running into some issues with that:

The code given by selenium IDE is :

sendKeys //input[Ivan Dyachkov (@id)=blahblah'] ${KEY_BACKSPACE}

which works.

The code given by the xebium formatter is:

| do | sendKeys | on | !-//input[Ivan Dyachkov (@id)='blahblah']-! | with | $KEY_BACKSPACE |

which doesn't seem to be working. I also tried entering $KEY_BACKSPACE between !- -! to avoid formatting by fitnesse and that didn't help either.

p.s. Using firefox driver

Thanks!

Activity

  1. sglebs commented on Aug 6, 2014

    @sglebs

    I am having the exact same problem, with TAB. I have tried:

    \t
    \t
    !- ${KEY_BACKSPACE} -!
    !- $KEY_BACKSPACE -!

    None of these worked

  2. sglebs commented on Aug 6, 2014

    @sglebs

    One of the problems I see is in class com.xebia.incubator.xebium.fastseleniumemulation.Type. It is missing a bunch (like tab, backspace etc):

    @Override
    protected Void handleSeleneseCommand(WebDriver driver, String locator, String value) {
        alertOverride.replaceAlertMethod(driver);
    
        if (value == null) {
            value = "";
        }
        value = value.replace("\\10", Keys.ENTER);
        value = value.replace("\\13", Keys.RETURN);
        value = value.replace("\\27", Keys.ESCAPE);
        value = value.replace("\\38", Keys.ARROW_UP);
        value = value.replace("\\40", Keys.ARROW_DOWN);
        value = value.replace("\\37", Keys.ARROW_LEFT);
        value = value.replace("\\39", Keys.ARROW_RIGHT);
    
  3. jguglielmi commented on Aug 6, 2014

    @jguglielmi

    Consider maybe adding a pull request for an enum?

  4. sglebs commented on Aug 7, 2014

    @sglebs

    I patched the code above to support TAB and it works:

    @Override
    protected Void handleSeleneseCommand(WebDriver driver, String locator, String value) {
        alertOverride.replaceAlertMethod(driver);
    
        if (value == null) {
            value = "";
        }
        value = value.replace("\\08", Keys.TAB);   // mqm
        value = value.replace("\\10", Keys.ENTER);
        value = value.replace("\\13", Keys.RETURN);
        value = value.replace("\\27", Keys.ESCAPE);
        value = value.replace("\\38", Keys.ARROW_UP);
        value = value.replace("\\40", Keys.ARROW_DOWN);
        value = value.replace("\\37", Keys.ARROW_LEFT);
        value = value.replace("\\39", Keys.ARROW_RIGHT);
    
        WebElement element = finder.findElement(driver, locator);
    
        clear(element);
        element.sendKeys(value);
        triggerEvents(element, driver);
    
        return null;
    }
    

    In your cell, use \08 and it will send a TAB. You must do the same for Backspace and all the other missing special characters.

  5. sglebs commented on Aug 7, 2014

    @sglebs

    The 08 above is preceded by 2 backslashes in the table cell. Somehow one slash was eaten by the formatting here. Just one backslash will not work.

  6. sglebs commented on Oct 2, 2014

    @sglebs

    In the fork I made, I solved this in a slightly different way now. I populate the special keys in the alias map. So now I have to precede its symbolic name with % in any table cell. In other words: %$KEY_TAB instead of $KEY_TAB when you use sendKeys.

    The fix was simple: add a method, initSpecialKeysMapping, and make the constructor call it. Here:

    public SeleniumDriverFixture() {
        super();
                initSpecialKeysMapping();
    }
    
    private void initSpecialKeysMapping() {
        aliases.put("$KEY_BACKSPACE", Keys.chord(Keys.BACK_SPACE));
        aliases.put("$KEY_TAB", Keys.chord(Keys.TAB));
        aliases.put("$KEY_ENTER", Keys.chord(Keys.ENTER));
        aliases.put("$KEY_RETURN", Keys.chord(Keys.RETURN));
    }
    

    Anyway, this is available in my fork.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      0