Testing special characters with Selenium

asked 2011-10-26 10:54:26 +0800

digulla gravatar image digulla
502 4

I've just wasted one day trying to create Selenium tests for a simple search box and I got nowhere. My current impression is that Selenium is useful for simple mouse-driven apps.

The search box uses keyboard navigation (up/down/esc/enter).

What I tried:

WebDriver (Selenium 2) doesn't support special keys on the keyboard or ZK doesn't respond to key events generated by WebDriver. I also don't like the keyhole surgery which I have to do using Selenium 2 which exposes almost nothing from the DOM. Writing tests with Selenium 2 feels like a huge waste of time.

Selenium IDE can't record special keys. I tried all kinds of combinations use keyDown/KeyUp, typeKeys without any success. I either get an error ("invalid keySequence") or nothing happens.

Then I tried to get at jQuery to post an artifical event but I got this error: Threw an exception: this.page().getCurrentWindow().wrappedJSObject is undefined

It it possible at all to test keyboard driven ZK apps using Selenium? If so, how do I do it?

If Selenium doesn't work, what else can I try?

delete flag offensive retag edit

2 Replies

Sort by ยป oldest newest

answered 2011-10-26 10:56:29 +0800

digulla gravatar image digulla
502 4

To convince me that Selenium is useful, show me a test case which drives the "Keystroke Events" demo in the sandbox (http://www.zkoss.org/zksandbox/#e7).

link publish delete flag offensive edit

answered 2011-11-17 02:51:17 +0800

matthewgo gravatar image matthewgo

updated 2011-11-17 03:30:34 +0800

Hi digulla,
The following is a simple sample

                WebDriver driver = new FirefoxDriver();
    		WebElement element = driver.findElement(By.id("zk_comp_5"));   // the input id
    		Actions builder = new Actions(driver);

                //Use Keys.LEFT_CONTROL here
                //zul alert is not a js alert, it calls Messagebox.show(); 
    		//Alert alert = driver.switchTo().alert();
    		//wait for the msgbox generated, or the selenium will execute faster than the browser;
    		//we need to find Element ourselves
    		WebElement alertOK = driver.findElement(By.id("zk_comp_14")); //the OK button's ID in the msgbox  
      		new Actions(driver).click(alertOK).build().perform();
    		builder.sendKeys(element, Keys.ENTER).perform();

For more information please refer to smalltalk

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools




Asked: 2011-10-26 10:54:26 +0800

Seen: 712 times

Last updated: Nov 17 '11

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More