-
FEATURED COMPONENTS
First time here? Check out the FAQ!
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?
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).
Hi digulla,
The following is a simple sample
WebDriver driver = new FirefoxDriver(); driver.get("URL"); WebElement element = driver.findElement(By.id("zk_comp_5")); // the input id Actions builder = new Actions(driver); //Use Keys.LEFT_CONTROL here builder.click(element).sendKeys(Keys.LEFT_CONTROL,"a").build().perform(); //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; Thread.sleep(1000); //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(); Thread.sleep(1000); builder.sendKeys(element, Keys.ENTER).perform();
For more information please refer to smalltalk
Asked: 2011-10-26 10:54:26 +0800
Seen: 712 times
Last updated: Nov 17 '11