Skip to content
This repository was archived by the owner on Apr 20, 2021. It is now read-only.

add press key feature#178

Open
gimler wants to merge 1 commit into
Behatch:masterfrom
gimler:keypress
Open

add press key feature#178
gimler wants to merge 1 commit into
Behatch:masterfrom
gimler:keypress

Conversation

@gimler

@gimler gimler commented Jul 6, 2016

Copy link
Copy Markdown
Contributor

It make it possible to press a specific keyboard key.

(I )press key :char
(I )press key :char on :element

example:

Then I press key "r"
Then I press key "["
Then I press key "ctrl+r"

@gimler gimler force-pushed the keypress branch 7 times, most recently from ec80534 to 90ac460 Compare July 7, 2016 06:41
@gimler

gimler commented Jul 7, 2016

Copy link
Copy Markdown
Contributor Author

ready to merge

@stevenkroiher

Copy link
Copy Markdown

👍

@sanpii

sanpii commented Jul 7, 2016

Copy link
Copy Markdown
Member

Good work, I have just one point: the key and modifier arguments need more abstration.

Something like that:

Then I press key "a"
Then I press key "<enter>"
Then I press key "Ctrl+A"

@gimler gimler force-pushed the keypress branch 3 times, most recently from 3dba717 to 75bbff1 Compare July 11, 2016 06:51
@gimler

gimler commented Jul 11, 2016

Copy link
Copy Markdown
Contributor Author

<enter> is a liddle bit tricky we can have a function convertSpecialKeyToChar($key) and a convert array for all keys but i think this is not sexy. Do you have another idea?

@sanpii

sanpii commented Jul 11, 2016

Copy link
Copy Markdown
Member

Do you have another idea?

No, this is what I think, but simpler than a regex:

function convertKey($char)
{
    static $specialKeys = [
        '<enter>' => 13,
    ];

    list($modifier, $key) = explode('+', $char, 2);

    if (isset($specialKeys[$key])) {
        $key = $specialKeys[$key];
    }

    return [$modifier, $key];
}

Not tested and I don’t know if multiple modifiers are supported by mink.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants