ElPandaRojo1 Posted November 13, 2020 Share Posted November 13, 2020 Hello, I would like to know how I can send a keyboard command in webdriver, for example I need to send the SHITF + ENTER key combination, either to an element or to the browser, I appreciate if you can help me Link to comment Share on other sites More sharing options...
Danp2 Posted November 13, 2020 Share Posted November 13, 2020 The _WD_Action function can be used to send keystrokes to the browser. You can find examples on the forum using the search feature. Here's a link to one example -- Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
ElPandaRojo1 Posted November 13, 2020 Author Share Posted November 13, 2020 Yes but, I don't understand how I can send two keys at the same time $sAction = '{"actions":[{"type": "key", "id": "keyboard_1", "actions": [{"type": "keyDown", "value": "\uE00F"}, {"type": "keyUp", "value": "\uE00F"}]}]}' _WD_Action($sSession, "actions", $sAction) Or so would it work? saying that the Key_Down the SHIFT and in the Key_Up the ENTER $sAction = '{"actions":[{"type": "key", "id": "keyboard_1", "actions": [{"type": "keyDown", "value": "\uE008"}, {"type": "keyUp", "value": "\uE007"}]}]}' _WD_Action($sSession, "actions", $sAction) Link to comment Share on other sites More sharing options...
Danp2 Posted November 13, 2020 Share Posted November 13, 2020 If you think about it, you never send twice simultaneous keys. When you press Shift+Enter, you are actually sending two keyDown events (one for Shift, the other for Enter) followed by two keyUp events. Suggest that you try to do the same using Actions. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
ElPandaRojo1 Posted November 13, 2020 Author Share Posted November 13, 2020 I have another question I have a text, Line texto 1 Line texto 2 Line texto 3 Line texto 4 I would like to send this text with these line breaks but when I use _WD_ElementAction ($ sSession, $ sElement, "value", "Text") it sends me the line breaks as an ENTER, I would like to know how I can make it just send me the jump of line and to be able to send this text in a single paragraph, and not separated. Link to comment Share on other sites More sharing options...
Danp2 Posted November 13, 2020 Share Posted November 13, 2020 This isn't something I've tried, but have you considered replacing the CR/LF combination with only a LF before using it with _WD_ElementAction? If that doesn't work, then I would recommend that you post a short script that we can run to observe the issue. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
ElPandaRojo1 Posted November 13, 2020 Author Share Posted November 13, 2020 The sending of keys does not work for me, try like this $sAction = '{"actions":[{"type": "key", "id": "keyboard_1", "actions": [{"type": "keyDown", "value": "\uE008"}, {"type": "keyDown", "value": "\uE007"},{"type": "keyUp", "value": "\uE008"},{"type": "keyUp", "value": "\uE007"}]}]}' $_WD_Action = _WD_Action($sSession, "actions", $sAction) and also like this $sAction = '{"actions": [{"type": "key","id": "keyboard","actions": [{"type": "keyDown", "value": "\uE008"},{"type": "keyDown", "value": "\uE007"},{"type": "keyUp", "value": "\uE008"},{"type": "keyUp", "value": "\uE007"}]}]}' $_WD_Action = _WD_Action($sSession, "actions", $sAction) but none worked for me Link to comment Share on other sites More sharing options...
Danp2 Posted November 13, 2020 Share Posted November 13, 2020 "Does not work" isn't an adequate description for us to diagnose the issue. Does the code execute without any errors? 3 hours ago, Danp2 said: If that doesn't work, then I would recommend that you post a short script that we can run to observe the issue. Do this please is you want me to look further into this for you. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
ElPandaRojo1 Posted November 16, 2020 Author Share Posted November 16, 2020 I already found the way to send the key combination, thank you very much for your help, I could not send an example code, since I did not find a page similar to the one I am testing, since the page is from work. I send the form that I found that is part of how you explained to me. _ChromeXPathComandByXPath($sSession, "SearchXpath", "value", "\uE008\uE007") Func _ChromeXPathComandByXPath($sSession, $XPath, $Value, $Option = "") $sButton = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, $XPath) $cResult = _WD_ElementAction($sSession,$sButton, $Value , $Option) Return $cResult EndFunc So I send a SHIFT + ENTER that gives me a line break where it does not accept the jump with just the enter. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now