robotframework-selenium2library-java icon indicating copy to clipboard operation
robotframework-selenium2library-java copied to clipboard

New keyword Press Key Native

Open UlrichBode opened this issue 11 years ago • 1 comments

Add to Element.java a new keyword Press Key Native. Prototype see below.

Goal: Elements like scrollbar are not coded in html. Therefore a locator can only hit the whole element and not single control elements. Keys like page up/down can be used instead. The keyword Press Key only accepts ASCII characters. To use other keys (see http://docs.oracle.com/javase/6/docs/api/constant-values.html#java.awt.event.KeyEvent.CHAR_UNDEFINED) a native version is necessary.

Additional the same keyword without locator could be useful. Compare http://robotframework-seleniumlibrary.googlecode.com/hg/doc/SeleniumLibrary.html?r=2.5#Press%20Key%20Native

/**

  • Simulates pressing a key. Helpful for non-ASCII keys like page up/down.
  • @param locator
  • @param key code for keys see http://docs.oracle.com/javase/6/docs/api/constant-values.html#java.awt.event.KeyEvent.CHAR_UNDEFINED */ public void pressKeyNative(final String locator, final String key) { if (locator == null || key == null) { info("Keyword needs locator and key => FAILED"); throw new Selenium2LibraryNonFatalException( "Keyword needs locator and key => FAILED"); } final List<WebElement> element = elementFind(locator, true, true); element.get(0).sendKeys(key); }

UlrichBode avatar Sep 25 '13 16:09 UlrichBode

You want to scroll or something else ?

Can use action Builder to do the job and can be easily created as Keyword.

asitishere avatar Jun 21 '15 22:06 asitishere