ui-automation


How to find Window by variable title using TestStack.White framework?


I am using TestStack.White framework to automate opening new document in MS Word 2013.
I am opening Microsoft Word application with:
Application application = Application.Launch("winword.exe");
After that, I am trying to get the window by partial title:
Window window = application.GetWindow("Word", InitializeOption.NoCache);
But it throws an exception saying that there is no such window.
Window title is: Document1 - Word
The question is: How to get a window by partial title taking into consideration that the title is changing every time: "Document2 - Word", "Document3 - Word", etc.
Also tried *Word but looks like this func does not support wildcards
If I invoke:
List windows = application.GetWindows();
after launching an application, windows list is empty.
Thanks in advance,
Ostap
You can use EnumWindows to find all the open windows.
Within that callback you'll get a window handle which you can then us with GetWindowTextLength and GetWindowText
This will let you decide what window handle is to the window you want. From there you can use GetWindowThreadProcessId to retrieve the process ID for the word document.
And finally with that you can create a TestStack White application using the Application.Start()
It looks like opening window takes some noticeable time. GUI testing frameworks often have functions like Wait() to make sure the window is already created/visible/enabled. I'm not an expert in Teststack.White. Probably this document may help: http://teststackwhite.readthedocs.io/en/latest/AdvancedTopics/Waiting/

Related Links

My automationelement FindFirst/FindAll seems to be very slow. How to improve the performance?
UI Automation CreatePropertyCondition 0xc0000005
NativeWindowHandle Returns 0, but Spy displays handle
Can we “click” on edit boxes using Microsoft UIAutomation libraries
Test flex mobile application built with 4.10 sdk with testcomplete
TreeWalker cant see AutomationElement, but UIA Verify can
Accessing elements of webview within a native iPhone app using UI Automation
Ranorex not able to recognise elements uniquely?
Getting / ussing full path to find controls in UIA and White
UIA: Get ControlType from control type name (string)
how to select which button to select in alert message for IOS UIAutomation
How to run multiple .trace files in one run i.e one after the other in UI automation tool?
Using TestComplete's UIAObject with Microsoft UI Automation Control Patterns
scrollToVisible error while testing on a device, UIAutomation
How to select font node in Sahi?
count the number of rows/columns using UI Automation

Categories

HOME
android-espresso
couchdb
redmine
message-queue
initialization
hystrix
match
clish
vimeo
buffer
twisted
closures
c#-7.0
vertica
susy-sass
office-ui-fabric
string-formatting
nullreferenceexception
error-logging
conda
stackexchange.redis
sybase-ase
dragula
unordered-multimap
strophe.js
webviewclient
xdebug
running-object-table
iwebbrowser2
locks
installanywhere
variable-variables
tidal-scheduler
stat
uipickerview
optionaldataexception
spooler
latexml
music21
cloudwatch
md5-file
sonicmq
nusoap
mobile-angular-ui
glimpse
rustdoc
gawk
gapi
mathjs
decoder
system.net.mail
between
cdo.message
declarative
qpixmap
unsigned
wicked-pdf
apache-pig-grunt
fdt
persistent-object-store
gridbaglayout
jsr363
dynamics-ax-2012-r2
wicked-gem
web-api
quercus
deque
r.java-file
nsmutabledata
debug-symbols
microsoft-expression-web
datagridcomboboxcolumn
xcode6.3.1
box2dweb
siena
forceclose
reference-counting
miglayout
eclim
chartfx
jbox2d
story
live-wallpaper
getproperty
nsfont
servercontrol
kext
azure-acs
kernel32
grails-validation
gaelyk
hungarian-notation
ixmldomdocument
asdoc
ning
iphone-sdk-3.1.3
rootkit

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App