Double-click SmartClient / Firefox troubles

128 views
Skip to first unread message

Eric C

unread,
Jun 2, 2009, 7:44:53 AM6/2/09
to webdriver
I can't seem to get a double-click event to a ListGrid (table) cell in
a SmartClient app (js library like ext). The only workaround I've
found is to single-click another object, tab until I get focus on the
cell I want, then send Keys.Enter.

Along the same lines, and at the root of the problem imo, I cannot
effectively click using WebElement.click() in this app. The elements
are getting the mouseDown event but not the mouseUp. The only way I
can single-click elements on this page is to cast the driver, then use
the drag function and just drag it onto itself.

Any ideas? There is a public site I can add info here to see what I'm
talking about if anyone is interested.

Eric C

unread,
Jun 2, 2009, 10:59:58 AM6/2/09
to webdriver
Apparently SmartClient responds to mouseDown and mouseUp events
individually, and considers the DOM to be "internals" and strongly
discourages writing tests using Selenium and such.

http://forums.smartclient.com/showthread.php?t=2312&highlight=selenium

Well, really, I want to do it anyway, for the small amount of testing
we need to do I can work the DOM just fine even with the SmartClient
widgets we have built.

So... is there a way I can send individual mouseDown and mouseUp
events to Firefox?

Simon Stewart

unread,
Jun 3, 2009, 5:54:32 AM6/3/09
to webd...@googlegroups.com
Hi,

You'll be pleased to hear that webdriver works very well with AJAX
apps --- indeed, we're working closely with the GWT team to ensure
that GWT apps are easy to test with webdriver. There's a few things
that you can do that make testing these apps easier.

Firstly, put IDs or names on key elements in your interface for easy
location. Secondly, it's wise to build abstractions around common
components in the UI. For example, if you're dealing with a
SmartClient "button" class often, it would make sense to model that in
your code; this way, if the DOM structure changes, it should be a
quick fix to get things up and running again. Thirdly, if SmartClient
offers a Javascript mechanism for locating and interacting with
elements, you may be able to use that. The JavascriptExecutor can
return WebElements, and calls to "executeScript" can accept
WebElements as arguments.

That last point may need a little explanation. I'm not familiar with
SmartClient, but let's imagine that they offer a "Find" function in JS
to locate elements somehow. Your button code could therefore look
something like this:

public class Button {
WebDriver driver;
WebElement element;

public Button(WebDriver driver, String locator) {
this.driver = driver;
element = ((JavascriptExecutor) driver)
.executeScript("return Find(arguments[0]);",
locator));
}

public void click() {
((JavascriptExecutor) driver).executeScript(
"arguments[0].click;", element);
}
}

Finally, if you've got any information about the "detailed
architecture that would allow any Ajax framework that treats the DOM
as internal information to work with Selenium" mentioned in that
thread, I'd be keen to have a look a look at it --- I'm not aware of
it, but it sounds interesting.

Regards,

Simon

Eric C

unread,
Jun 3, 2009, 9:19:40 AM6/3/09
to webdriver
Thanks Simon!

The JavascriptExecutor works awesomely!

As it turns out, SmartClient has a great library of existing
javascript functions to manipulate the SmartClient objects on the
page.

So instead of "double-clicking" on a row in a table to edit it, all I
did was find the row number I wanted to edit and then:
((JavascriptExecutor) driver) .executeScript
("mySmartClientTable.startEditing(" + matchingRowNum + ")");

Very clean and satisfying.

SmartClient is PLANNING to somehow adopt Selenium compatibility,
probably like you said, by adding the ability to assign IDs or
something to elements.

Also, the two example scripts for manipulating elements via javascript
might be better ways than I'm using currently. Very exciting!!

-Eric
Reply all
Reply to author
Forward
0 new messages