venkatesan_G02 has asked for the wisdom of the Perl Monks concerning the following question:

Hi,

I am using WWW::Selenium module to interact with a web page automatically. I am able to login and check for necessary details successfully. But when i try to enter some commands, i have to type ENTER key at the end of my command because there is no submit key in the form.

I tried the following ways to simulate the enter key in www::selenium but failed.

$sel->type_keys("q","\13"); $sel->key_down("q","\13");

Type keys is just typing \13 plainly but with key down, i do not see anything happening at all.

Please advice!!

Replies are listed 'Best First'.
Re: How To Simulate "Enter" Key Stroke using WWW::Selenium
by runrig (Abbot) on Nov 13, 2009 at 19:28 UTC
    Try key_press(), or perhaps fire_event (if you can figure out what event gets fired when you press enter).
      I tried $sel->key_press("q","\13"); but still nothing is happening.
        How about this (from the docs):
        $sel->submit($form_locator) Submit the specified form. This is particularly useful for forms w +ithoutsubmit buttons, e.g. single-input "Search" forms. $form_locator is an element locator for the form you want to s +ubmit
Re: How To Simulate "Enter" Key Stroke using WWW::Selenium
by ikegami (Patriarch) on Nov 13, 2009 at 20:03 UTC

    String literal "\13" produces a one character string consisting of a vertical tab (character 13oct = 11dec). This is obviously not what you were trying to send.

    I'm not sure what you were trying to send, but if you were trying to send a newline, it's chr(10) aka "\n" aka "\0x0A" aka "\12".

      I am trying to send an ENTER key press and i used
      $sel->key_press("q","\r");

      But i am receiving the following error:

      Error requesting http://localhost:5555/selenium-server/driver/:
      ERROR: invalid keySequence

        Enter produces a newline, not a carriage return. I'm not saying selenium will accept a newline — I don't know the first thing about selenium — I'm saying that sending a carriage return is surely incorrect.