如何通过 TabIndex 在 TTabSet 中选择选项卡时引发点击事件?
我有一个 TestComplete 测试,它使用 TabIndex
属性在 TTabSet
中选择一个选项卡:
Tab.TabIndex = 1
效果很好。但是,我注意到该选项卡上的某些对象需要发生单击事件才能启用。也就是说,如何通过涉及某种点击事件的 TabIndex
选择选项卡项?
I have a TestComplete test that selects a tab in a TTabSet
using the TabIndex
property:
Tab.TabIndex = 1
That works great. However, I am noticing that some of the objects on that tab require the click event to occur to be enabled. That said, how can I select the tab item via the TabIndex
with some sort of a click event involved?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以调用
TTabSet
的ItemRect
方法通过索引获取选项卡的坐标,然后将这些坐标传递给 TestComplete 的Click
方法。下面是一个示例:但是,此方法要求:
ItemRect
)可用于 TestComplete)。ItemRect
方法调用(否则该方法将被 Delphi 的智能链接器排除在 EXE 之外,因此无法用于 TestComplete)。另外,如果您的选项卡控件的选项卡数量多于显示的选项卡数量(即
Tabs.Count
>VisibleTabs
),则需要滚动它以显示所需的选项卡首先可见。例如,您可以使用FirstIndex
< /a> 属性:Instead of assigning a value to
TabIndex
, you can callTTabSet
'sItemRect
method to get the coordinates of a tab by its index, and then pass these coordinates to TestComplete'sClick
method. Here's an example:However, this approach requires that:
ItemRect
, available to TestComplete).ItemRect
method call (otherwise this method will be left out of the EXE by Delphi's smart linker, so it will be unavailable to TestComplete).Also, if your tab control has more tabs than are displayed (that is,
Tabs.Count
>VisibleTabs
), you'll need to scroll it to make the needed tab visible first. You can do this, for example, using theFirstIndex
property: