Null dereference(s) in AppTreeParser - Doing it wrong?

20 views
Skip to first unread message

skuenzli

unread,
Oct 9, 2010, 2:21:12 PM10/9/10
to Selenium-Flex API - Development
Good morning,

Thank you for building selenium-flex. My team has started using
selenium-flex to automate testing of a relatively large, multi-module,
flex 4 (mostly spark + some halo) application.

We are seeing null nodes being de-referenced in AppTreeParser's
assignID, setTooltipsToID, and hasFirstChild functions; this appears
to prevent sfapi from completing initialization. Adding some simple
null-checking at the top of these functions prevents the errors and at
least simple flexClick operations now succeed.

I see on the support forum that modules are supported by sfapi (see
postscript).

We're proceeding with a custom build of sfapi with the aforementioned
null-checking so we can get unblocked, but I am wondering if we're
doing something basic incorrectly to cause these assignment issues.
Can you please advise?

I've included the svn diff to AppTreeParser in the postscript.

Regards,
Stephen

* Reference to module support info:
http://groups.google.com.au/group/sfapi-support/browse_thread/thread/6ccea15cd52fc00a/1552eb3c07922d0f?lnk=gst&q=module#1552eb3c07922d0f

* svn diff src/sfapi/core/AppTreeParser.as
Index: src/sfapi/core/AppTreeParser.as
===================================================================
--- src/sfapi/core/AppTreeParser.as (revision 23)
+++ src/sfapi/core/AppTreeParser.as (working copy)
@@ -207,6 +207,11 @@
*/
private function hasFirstChild(node:AppTreeNode):Boolean
{
+ if(node == null || node.child == null){
+ return false;
+ }
+
+
if(node.child.hasOwnProperty("numChildren") &&
node.child.numChildren > 0)
{
firstNode = new AppTreeNode(node.child.getChildAt(0), 0, false);
@@ -318,7 +323,14 @@
var parents:Array = new Array();
var currentNode:AppTreeNode = new AppTreeNode(thisApp.parent);
var sibTravers:Boolean = false;
+

+ trace("setting tooltips for " + thisApp + "; currentNode is " +
currentNode);
+
+ if(currentNode == null){ //inside setTooltipsToID
+ return;
+ }
+
do
{
if(hasFirstChild(currentNode) && ! sibTravers)
@@ -427,6 +439,11 @@
*/
private function assignID(node:Object):void
{
+ trace("assigning id to " + node);
+ if(node == null){
+ return;
+ }
+
if(node.hasOwnProperty("id") && node.hasOwnProperty("toolTip"))
{
if(node.id == null)

* original stacktrace:
Main Thread (Suspended: TypeError: Error #1009: Cannot access a
property or method of a null object reference.)
sfapi.core::AppTreeParser/assignID
sfapi.core::AppTreeParser/setTooltipsToID
SeleniumFlexAPI/applicationCompleteHandler
flash.events::EventDispatcher/dispatchEventFunction [no source]
flash.events::EventDispatcher/dispatchEvent [no source]
mx.managers::SystemManager/preloader_preloaderDoneHandler
flash.events::EventDispatcher/dispatchEventFunction [no source]
flash.events::EventDispatcher/dispatchEvent [no source]
mx.preloaders::Preloader/displayClassCompleteHandler
flash.events::EventDispatcher/dispatchEventFunction [no source]
flash.events::EventDispatcher/dispatchEvent [no source]
com.somebody.common.view.components::AnimationPreloader/
handleInitComplete
flash.events::EventDispatcher/dispatchEventFunction [no source]
flash.events::EventDispatcher/dispatchEvent [no source]
mx.preloaders::Preloader/dispatchAppEndEvent
mx.preloaders::Preloader/appCreationCompleteHandler
flash.events::EventDispatcher/dispatchEventFunction [no source]
flash.events::EventDispatcher/dispatchEvent [no source]
mx.core::UIComponent/dispatchEvent
mx.core::UIComponent/set initialized
mx.managers::LayoutManager/doPhasedInstantiation
mx.managers::LayoutManager/doPhasedInstantiationCallback
Reply all
Reply to author
Forward
0 new messages