尝试在高级数据网格单元格中获取文本

发布于 2024-10-10 21:34:20 字数 4754 浏览 3 评论 0原文

我有一个 AdvancedDataGrid,可以从 Web 服务加载数据。它只加载顶级内容,然后当您单击箭头时它会获取该数据。

我想做的就是找出某个单元格中是否有某些文本。我最初是这样做的:

public static function assertTextInAdg(params:Object):Boolean{
    // Gets the ADG
    trace('youre in the assertTextInAdg function');
    var grid:* = FPLocator.lookupDisplayObject(params);
    trace('var grid:* = FPLocator.lookupDisplayObject(params): ' + grid);
    // Convert ADG to automation delegate to get an array of column names
    var newGrid:* = new AdvancedDataGridAutomationImpl(grid);
    trace('var newGrid:* = new AdvancedDataGridAutomationImpl(grid): ' + newGrid);
    var datas:AdvancedDataGridTabularData = newGrid.automationTabularData as AdvancedDataGridTabularData;
    trace('var datas:AdvancedDataGridTabularData = newGrid.automationTabularData as AdvancedDataGridTabularData: ' + datas);
    var columnId:Array = datas.columnNames as Array;
    trace('var columnId:Array = datas.columnNames as Array: ' + columnId);
    // Convert ADG data to an array of rows
    var gridView:HierarchicalCollectionView = grid.dataProvider as HierarchicalCollectionView;
    trace('var gridView:HierarchicalCollectionView = grid.dataProvider as HierarchicalCollectionView: ' + gridView);
    var gridData:HierarchicalData = gridView.source as HierarchicalData;
    trace('var gridData:HierarchicalData = gridView.source as HierarchicalData: ' + gridData);
    var gridArrayColl:ArrayCollection = gridData.source as ArrayCollection;
    trace('var gridArrayColl:ArrayCollection = gridData.source as ArrayCollection: ' + gridArrayColl);
    var gridArray:Array = gridArrayColl.source as Array;
    trace('var gridArray:Array = gridArrayColl.source as Array: ' + gridArray);
    var validator:String = params.validator;
    trace('var gridArray:Array = gridArrayColl.source as Array: ' + validator);

    for (var i:int = 0; i < gridArray.length; i++) {
        for (var j:int = 0; j < columnId.length; j++) {
            if (gridArray[i][columnId[j]] == validator) { return true; }
        }
    }

    throw new Error("Validator not found in ADG.");

}

如果数据是从代码中提供的,那么这是可行的,但现在我正在尝试使用从服务器提供的数据进行同样的操作,并且跟踪结果如下:

youre in the assertTextInAdg function
var grid:* = FPLocator.lookupDisplayObject(params):           companyDashboard.dashboardCanvas.dashboardGrid
var newGrid:* = new AdvancedDataGridAutomationImpl(grid): [object AdvancedDataGridAutomationImpl]
var datas:AdvancedDataGridTabularData = newGrid.automationTabularData as AdvancedDataGridTabularData: [object AdvancedDataGridTabularData]
var columnId:Array = datas.columnNames as Array: @objectName,@customObjectType,@owner,@value0,@value1,@icon1,@value2,@icon2,@value3,@icon3,@value4,@icon4,@value5,@value6,@icon6,empty
var gridView:HierarchicalCollectionView = grid.dataProvider as HierarchicalCollectionView: [object HierarchicalCollectionView]
var gridData:HierarchicalData = gridView.source as HierarchicalData: [object HierarchicalData]
var gridArrayColl:ArrayCollection = gridData.source as ArrayCollection: null

然后它失败了,因为它不能获取来源,我想。我对其他策略完全持开放态度,并且我已经在这个问题上困扰了 10 天。这看起来似乎是相对容易的。预先感谢您的任何意见。

**更新**

我一直在走一条略有不同的路线。我现在尝试使用光标迭代 HierarchicalCollectionView。这似乎有效。但是,当我获得节点时,我无法用它做任何有用的事情...我一直在寻找示例,但到目前为止它们都停在获得节点的地方。这意味着我知道这是一个愚蠢的问题。

 public static function assertTextInAdg(params:Object):Boolean{
    // Gets the ADG
    trace('youre in the assertTextInAdg function');
    var grid:* = FPLocator.lookupDisplayObject(params);
    trace('var grid:* = FPLocator.lookupDisplayObject(params): ' + grid);
    var adgData:* = grid.hierarchicalCollectionView;
    trace('var adgData:* = grid.hierarchicalCollectionView: ' + adgData);
    trace('AdgData.length() = ' + adgData.length);
    var cursor:* = adgData.createCursor();
    while(!cursor.afterLast) {
        var node:Object = cursor.current;
        cursor.moveNext();
 }

这是trace() 的输出:

youre in the assertTextInAdg function
var grid:* = FPLocator.lookupDisplayObject(params):     testApp.ApplicationSkin2._ApplicationSkin_Group1.contentGroup.Panel5.myADG
var adgData:* = grid.hierarchicalCollectionView: [object HierarchicalCollectionView]
AdgData.length() = 8
node.getData: undefined
constructor: [class Object]
hasRoot: undefined
length: undefined
openNodes: undefined
prototype: undefined
showRoot: undefined
source: undefined
node.getData: undefined
constructor: [class Object]
hasRoot: undefined
length: undefined
openNodes: undefined
prototype: undefined
showRoot: undefined
source: undefined
node.getData: undefined
constructor: [class Object]
hasRoot: undefined
length: undefined
openNodes: undefined
prototype: undefined
showRoot: undefined
source: undefined

I have an AdvancedDataGrid that loads data from a web service. It only loads the top level stuff and then as you click the arrows it gets that data.

All I want to do is to find out if some text is in one of the cells. I originally did this:

public static function assertTextInAdg(params:Object):Boolean{
    // Gets the ADG
    trace('youre in the assertTextInAdg function');
    var grid:* = FPLocator.lookupDisplayObject(params);
    trace('var grid:* = FPLocator.lookupDisplayObject(params): ' + grid);
    // Convert ADG to automation delegate to get an array of column names
    var newGrid:* = new AdvancedDataGridAutomationImpl(grid);
    trace('var newGrid:* = new AdvancedDataGridAutomationImpl(grid): ' + newGrid);
    var datas:AdvancedDataGridTabularData = newGrid.automationTabularData as AdvancedDataGridTabularData;
    trace('var datas:AdvancedDataGridTabularData = newGrid.automationTabularData as AdvancedDataGridTabularData: ' + datas);
    var columnId:Array = datas.columnNames as Array;
    trace('var columnId:Array = datas.columnNames as Array: ' + columnId);
    // Convert ADG data to an array of rows
    var gridView:HierarchicalCollectionView = grid.dataProvider as HierarchicalCollectionView;
    trace('var gridView:HierarchicalCollectionView = grid.dataProvider as HierarchicalCollectionView: ' + gridView);
    var gridData:HierarchicalData = gridView.source as HierarchicalData;
    trace('var gridData:HierarchicalData = gridView.source as HierarchicalData: ' + gridData);
    var gridArrayColl:ArrayCollection = gridData.source as ArrayCollection;
    trace('var gridArrayColl:ArrayCollection = gridData.source as ArrayCollection: ' + gridArrayColl);
    var gridArray:Array = gridArrayColl.source as Array;
    trace('var gridArray:Array = gridArrayColl.source as Array: ' + gridArray);
    var validator:String = params.validator;
    trace('var gridArray:Array = gridArrayColl.source as Array: ' + validator);

    for (var i:int = 0; i < gridArray.length; i++) {
        for (var j:int = 0; j < columnId.length; j++) {
            if (gridArray[i][columnId[j]] == validator) { return true; }
        }
    }

    throw new Error("Validator not found in ADG.");

}

This works if the data is provided from the code, but now I am trying the same thing with the data being provided from a server and the traces come out like this:

youre in the assertTextInAdg function
var grid:* = FPLocator.lookupDisplayObject(params):           companyDashboard.dashboardCanvas.dashboardGrid
var newGrid:* = new AdvancedDataGridAutomationImpl(grid): [object AdvancedDataGridAutomationImpl]
var datas:AdvancedDataGridTabularData = newGrid.automationTabularData as AdvancedDataGridTabularData: [object AdvancedDataGridTabularData]
var columnId:Array = datas.columnNames as Array: @objectName,@customObjectType,@owner,@value0,@value1,@icon1,@value2,@icon2,@value3,@icon3,@value4,@icon4,@value5,@value6,@icon6,empty
var gridView:HierarchicalCollectionView = grid.dataProvider as HierarchicalCollectionView: [object HierarchicalCollectionView]
var gridData:HierarchicalData = gridView.source as HierarchicalData: [object HierarchicalData]
var gridArrayColl:ArrayCollection = gridData.source as ArrayCollection: null

And then it fails, because it can't get the source, I think. I am completely open to other strategies and I have been stuck on this problem for 10 days now. This seems like it would be relatively easy. Thanks in advance for any input.

** UPDATE **

I have been going down a slightly different route. I am now trying to iterate through the HierarchicalCollectionView with a cursor. This seems to work. But, when I get the node I can't do anything useful with it... I have been looking for examples but so far they all stop at the point of getting the node. Which means this is a stupid question I know.

 public static function assertTextInAdg(params:Object):Boolean{
    // Gets the ADG
    trace('youre in the assertTextInAdg function');
    var grid:* = FPLocator.lookupDisplayObject(params);
    trace('var grid:* = FPLocator.lookupDisplayObject(params): ' + grid);
    var adgData:* = grid.hierarchicalCollectionView;
    trace('var adgData:* = grid.hierarchicalCollectionView: ' + adgData);
    trace('AdgData.length() = ' + adgData.length);
    var cursor:* = adgData.createCursor();
    while(!cursor.afterLast) {
        var node:Object = cursor.current;
        cursor.moveNext();
 }

This is the trace() output:

youre in the assertTextInAdg function
var grid:* = FPLocator.lookupDisplayObject(params):     testApp.ApplicationSkin2._ApplicationSkin_Group1.contentGroup.Panel5.myADG
var adgData:* = grid.hierarchicalCollectionView: [object HierarchicalCollectionView]
AdgData.length() = 8
node.getData: undefined
constructor: [class Object]
hasRoot: undefined
length: undefined
openNodes: undefined
prototype: undefined
showRoot: undefined
source: undefined
node.getData: undefined
constructor: [class Object]
hasRoot: undefined
length: undefined
openNodes: undefined
prototype: undefined
showRoot: undefined
source: undefined
node.getData: undefined
constructor: [class Object]
hasRoot: undefined
length: undefined
openNodes: undefined
prototype: undefined
showRoot: undefined
source: undefined

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

迷雾森÷林ヴ 2024-10-17 21:34:20

使用 selenium 和 FlexPilot 这就是我检查网格中文本的方式

selenium.flexAssertProperty("id=MyAppInFlex", "chain=id:userGrid/name:AdvancedListBaseContentHolder*/name:AdvancedListBaseContentHolder*, validator=text|Maria Marcano");

我有一些博客文章,其中包含有关 Selenium 和 FlexPilot 的信息
- http://mariangemarcano.blogspot.com/2010/ 08/selenium-testing-with-flex-pilot.html
- http://mariangemarcano.blogspot.com/2010/10/automating- myappinflexswf-useful.html

Using selenium and FlexPilot this is how I am checking for a text in a grid

selenium.flexAssertProperty("id=MyAppInFlex", "chain=id:userGrid/name:AdvancedListBaseContentHolder*/name:AdvancedListBaseContentHolder*, validator=text|Maria Marcano");

I have some blog post with information about Selenium and FlexPilot
- http://mariangemarcano.blogspot.com/2010/08/selenium-testing-with-flex-pilot.html
- http://mariangemarcano.blogspot.com/2010/10/automating-myappinflexswf-useful.html

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文