Press key for tab doesnt accept ascii code for tab key

4,794 views
Skip to first unread message

Sujata Dwivedi

unread,
Apr 17, 2013, 3:15:29 PM4/17/13
to robotframe...@googlegroups.com
Hi,
ASCII code 09 for tab key is not working
I used in this way

Press Key id \09

please suggest which is to be used in place of 9 and also what is to be used for shift+Tab key.

Markus Bernhardt

unread,
Apr 17, 2013, 3:23:20 PM4/17/13
to suja...@gmail.com, robotframe...@googlegroups.com
Please use \\09

--
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-u...@googlegroups.com.
To post to this group, send email to robotframe...@googlegroups.com.
Visit this group at http://groups.google.com/group/robotframework-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Sujata Dwivedi

unread,
Apr 17, 2013, 3:52:11 PM4/17/13
to robotframe...@googlegroups.com, suja...@gmail.com

Thanks Markus it is working.
But i also want to use shift+tab keyword is there any ASCII code for this?

Sujata Dwivedi

unread,
Apr 18, 2013, 1:18:39 PM4/18/13
to robotframe...@googlegroups.com, suja...@gmail.com
I used \\18 for shift+tab but its not working.
 Please suggest

 

Kevin O.

unread,
Apr 18, 2013, 2:51:09 PM4/18/13
to robotframe...@googlegroups.com, suja...@gmail.com
I have never had to verify tab order using Selenium.
Using modifier key like the SHIFT key requires Selenium to be using native events. I was not able to get this test to pass on FF using 2.21, but newer versions of Selenium should work. It does work in IE8.
Send Shift Tab To Current Element is begging to be implemented in Python, but I wanted to give you something easy to try out.

Good Luck,
Kevin

*** Settings ***
Library           Selenium2Library

*** Test Cases ***
Shift Tab
    Open Browser    http://gmail.com    ie
    Wait Until Page Contains Element    id=Passwd
    Click Element    id=Passwd
    Focused Element Id Should Be    Passwd
    Send Shift Tab To Current Element
    Focused Element Id Should Be    Email

*** Keywords ***
Focused Element Id Should Be
    [Arguments]    ${expected id}
    ${focused id}=    Execute Javascript    return window.document.activeElement.id;
    Should Be Equal    ${focused id}    ${expected id}

Send Shift Tab To Current Element
    ${keys}=    Evaluate    selenium.webdriver.common.keys.Keys    selenium
    ${s2l}=    Get Library Instance    Selenium2Library
    ${actionchain module}=    Evaluate    selenium.webdriver.common.action_chains    selenium
    ${action chain}=    Call Method    ${actionchain module}    ActionChains    ${s2l._current_browser()}
    Call Method    ${action chain}    key_down    ${keys.SHIFT}
    Call Method    ${action chain}    send_keys    ${keys.TAB}
    Call Method    ${action chain}    key_up    ${keys.SHIFT}
    Call Method    ${action chain}    perform

Sujata Dwivedi

unread,
Apr 21, 2013, 2:15:08 PM4/21/13
to robotframe...@googlegroups.com, suja...@gmail.com

Hi Kevin,
THANKS FOR YOUR REPLY.
I run your code.But your code move towards the sign in button not on the username field, i mean to say that it work as tab key not the shift+tab key.

PLEASE SUGGEST ME.

Kevin O.

unread,
Apr 22, 2013, 10:29:58 AM4/22/13
to robotframe...@googlegroups.com, suja...@gmail.com
That happened for me too because Firefox was not using native events. To get FF to use native events, you have to use a version of Se & FF that supports it. By default it is always disabled on Linux.
If you want to try and force native events, I think you can set desired_capabilities=enable.native.events:true in Open Browser.
Since I think it was not running with native events, the request to press the shift button was just ignored.
I do not know much about Firefox as I test in IE mostly.

Good Luck

Pushpendra Singh

unread,
Jun 16, 2013, 2:08:00 PM6/16/13
to robotframe...@googlegroups.com
Hello,


 i am using this code

function RestrictSpace(e, t) {

             try {

                 if (window.event) {

                     var charCode = window.event.keyCode;

                 }

                 else if (e) {

                     var charCode = e.which;

                 }

                 else { return true; }

                 if ((charCode > 64 && charCode < 91) || (charCode > 96 && charCode < 123) || (charCode == 08) )

                     return true;

                 else

                     return false;

             }

             catch (err) {

                 alert(err.Description);

             }

         }


now i want to allow TAB key, ASCII 09 is not working here.


plz chk that....

Jason Tran

unread,
Dec 9, 2013, 5:20:40 PM12/9/13
to robotframe...@googlegroups.com
All,

When I tried:

Press Key \\09

I got error: Keyword 'Selenium2Library.Press Key' expected 2 arguments, got 1.

What do I need to put in the second column (first argument)?

Press Key 'first argument?' \\09

Thanks,

Tatu Aalto

unread,
Dec 10, 2013, 2:03:02 AM12/10/13
to jason...@gmail.com, robotframe...@googlegroups.com
Ugh

Because you need to specify a locator, as it is stated in the documentation [1].

-Tatu
[1] http://rtomac.github.io/robotframework-selenium2library/doc/Selenium2Library.html#Press%20Key
--
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-u...@googlegroups.com.
To post to this group, send email to robotframe...@googlegroups.com.

Jason Tran

unread,
Dec 11, 2013, 1:28:09 PM12/11/13
to robotframe...@googlegroups.com, jason...@gmail.com
Thanks Tatu!

I am trying to select an item from the dropdown menu that is not visible, so I am trying to use tab key to get to the item. Is that possible? Or I have to use the item that is currently visible on the menu until the item I want visible, then use that item's value?

By the way, using Firefox inspect element and Firebug, below are the values that I got. Do I assign a variable to one of the value then use it as "locator" in the press key command?

Firefox inspector: copy unique selector
.jspPane > li:nth-child(6) > a:nth-child(1)

xpath
/html/body/div/div[2]/div[2]/table[2]/tbody/tr/td[2]/div/div[21]/table/tbody/tr/td[2]/div/ul/li/ul/div/div/div/li[6]/a

css path
html body div#pages div.b1 div#main_content table tbody tr td div#mainbody.r_content div.field_top table tbody tr td div#id_timeout_top_main.select_menu ul li.option_list ul#id_timeout_li.ul_obj div.scrollbar_idle div.jspContainer div.jspPane li a.hovered_item


Many thanks!
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-users+unsub...@googlegroups.com.

Tatu Aalto

unread,
Dec 15, 2013, 2:10:22 PM12/15/13
to jason...@gmail.com, robotframe...@googlegroups.com
Ugh

Sorry for long delay. I do not know, it all depends. My guess would be that if you are able to do it from keyboard, then you should be also to do it with Selenium2Library too.

In theory yes, although those are quite long selectors (but still valid ones). I would first read some general documentation about xpath and css. I personally have found w3schools docs [1] [2]quite useful. Example is also useful to study, the see attachment, it is same test that press tab key on www.google.fi on input field. But test uses different selectors.

[1] http://www.w3schools.com/cssref/css_selectors.asp
[2] http://www.w3schools.com/xpath/xpath_syntax.asp

-Tatu
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-u...@googlegroups.com.
press_tab.txt

Suji Alwar

unread,
Feb 4, 2016, 3:03:51 AM2/4/16
to robotframework-users

Hi,

Can you please tell me how you are finding the id for Enter key?


dm08

unread,
Feb 4, 2016, 1:47:59 PM2/4/16
to suji...@gmail.com, robotframework-users
On Feb 3, 2016, at 11:34 PM, Suji Alwar <suji...@gmail.com> wrote:


Hi,

Can you please tell me how you are finding the id for Enter key?



--
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-u...@googlegroups.com.
To post to this group, send email to robotframe...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages