嘗試每個列出的選項,但都無法在使用白色的窗格控件中找到功能區。 儘管VisualUIAVerify在樹中顯示它。WinForms UI自動化:在VisualUIAVerify中找不到Ribon
"window" "Test 0.0.1" "MainForm"
|--"pane" "Dock Top" "_MainForm_Toolbars_Dock_Area_Top"
|--"" "Ribbon" ""
|--"tab" "Ribbon Tabs" ""
|--"tab item" "Tools" ""
我想自動點擊標籤項「工具」。 但只能找到一個「窗格」
import clr
import sys
sys.path.append(r"C:\TEMP\white")
clr.AddReference("White.Core")
clr.AddReference("White.NUnit")
from White.NUnit import *
from White import *
from White.Core import *
from White.Core.Configuration import *
from White.Core.UIItems import *
from White.Core.UIItems.WindowItems import *
from White.Core.UIItems.ListBoxItems import *
from White.Core.UIItems.Container import *
from White.Core.UIItems.Finders import *
from White.Core.Factory import *
from White.Core.Finder import *
from White.Core.AutomationElementSearch import *
from White.Core.WindowsAPI import *
from System.Diagnostics import Process
wp= Process();
wp.StartInfo.FileName = r"c:\TEMP\gui\TestShell.exe";
wp.StartInfo.Arguments = r"TestShell.taco -e DBA -s qa";
wp.Start();
wapp = Application.Attach(wp);
wnds=Application.GetWindows(wapp)
wnd=wnds[0]
#test
>wnd.Name
"Test 0.0.1"
我甚至可以單擊選項卡工具提供的座標(IronPython的)。
def click(cp,mouse,x,y):
cp = wnd.Bounds.TopLeft;
cp.Offset(x, y);
mouse = Desktop.Instance.Mouse;
mouse.Location = cp;
mouse.Click(cp);
cp = wnd.Bounds.TopLeft;
mouse = Desktop.Instance.Mouse;
mouse.Location = cp;
mouse.Click(cp);
click(cp,mouse,120,50) #tools
前往窗格:
pn=wnd.GetElement(SearchCriteria.ByAutomationId("_MainForm_Toolbars_Dock_Area_Top"));
綁找到色帶
rbn=pn.GetElement(SearchCriteria.ByAutomationId("Ribbon"));
或發現所有的孩子
pn.FindAll(TreeScope.Children, Condition.TrueCondition)
似乎沒有任何工作。