SlideShare une entreprise Scribd logo
1  sur  18
The Software Testing Using PowerShell team presents

New object model
in
UIAutomation PowerShell
Extensions
part 1
Problem
What actions does a control support?

Select? Toggle? Click?
Problem
●

first, we need to examine the control

$radioButton.GetSupportedPatterns()
●

and search for a cmdlet that invokes an action
we need

Get-Command *radio*
●

and after all we need to test whether it works

Get-UiaRadioButton hex | InvokeUiaRadioButtonSelectItem
Solution
Each control supports some patterns why do not use them fluently?
$radioButton = Get-UiaRadioButton hex
$radioButton.Select()

Intellisense should help to write code,
methods should be available only if they are
supported
Solution

The new elements' object model is the
answer!
Example task
Turn calculator into the Standard mode:
Example code
$menuView = Start-Process calc -PassThru | `
Get-UiaWindow | Get-UiaMenuItem view
($menuView.Expand() | Get-UiaMenuItem
standard).Click()
# menu item View exposes method Expand()
# menu item Standard accepts Click()
Chaining methods
The majority of methods return the object the
method was called on:
$btn1 = Start-Process calc -PassThru | GetUiaWindow | Get-UiaButton 1
$btn1.Click().NavigateToNextSibling().Click().Cl
ick().Highlight()
# this code writes 100 and highlights button 0
ISupportsSelectionItemPattern
Let's change dec to hex:

$rbtn = Get-UiaRadioButton hex
$rbtn.Select()
ISupportsTransformPattern
Move, Resize, Rotate
$wnd.Move(500, 500)

check whether a control supports a method of
pattern:
if ($wnd.CanResize) {
$wnd.Resize(300, 300)
}
# not resizable
ISupportsWindowPattern
$visualState =
[System.Windows.Automation.WindowVisualState]
$wnd.SetWindowVisualState(
$visualState::Maximized)
$wnd.WaitForInputIdle(60000)
$wnd.Close()
ISupportsScrollItemPattern
services.msc
# the following may require run as Administrator
$gridItem = Get-UiaWindow -n services | GetUiaDataGrid | Get-UiaDataItem Workstation
$gridItem.ScrollIntoView()
ISupportsScrollPattern
services.msc
# the following may require run as Administrator
$grid = Get-UiaWindow -n services | Get-UiaDataGrid
$scrollAmount = [System.Windows.Automation.ScrollAmount]
$grid.Scroll(
$scrollAmount::LargeIncrement, $scrollAmount::SmallIncrement)
$grid.ScrollHorizontal($scrollAmount::LargeDecrement)
$grid.ScrollVertical($scrollAmount::NoAmount)
ISupportsValuePattern
$editPrice = Get-UiaWindow -n *calc* | GetUiaEdit -Value 123

$editPrice.Value = 1234
ISupportsSelectionPattern
services.msc
# the following may require run as Administrator
$grid = Get-UiaWindow -n services | GetUiaDataGrid
$grid.GetItem(1,1).Click()
$grid.GetSelection()
ISupportsTogglePattern
$chkBox = Start-Process charmap -PassThru | `
Get-UiaWindow | Get-UiaCheckBox
$chkBox.ToggleState
$chkBox.Toggle()
# the Toggle method turns on and off
IntelliSense
As usual, PowerShell (partially) supports
IntelliSense after you ran a piece of code:
The end

Happy testing!

Contenu connexe

En vedette

Advanced Tools & Scripting with PowerShell 3.0 Jump Start - Certificate
Advanced Tools & Scripting with PowerShell 3.0 Jump Start - CertificateAdvanced Tools & Scripting with PowerShell 3.0 Jump Start - Certificate
Advanced Tools & Scripting with PowerShell 3.0 Jump Start - Certificate
Don Reese
 
Free tools for win server administration
Free tools for win server administrationFree tools for win server administration
Free tools for win server administration
Concentrated Technology
 

En vedette (20)

自動テスト入れてみたけど、誰からも反応が無かった話。
自動テスト入れてみたけど、誰からも反応が無かった話。自動テスト入れてみたけど、誰からも反応が無かった話。
自動テスト入れてみたけど、誰からも反応が無かった話。
 
IT Pro のための PowerShell スクリプティング
IT Pro のための PowerShell スクリプティングIT Pro のための PowerShell スクリプティング
IT Pro のための PowerShell スクリプティング
 
Combining output from multiple sources
Combining output from multiple sourcesCombining output from multiple sources
Combining output from multiple sources
 
Best free tools for win database admin
Best free tools for win database adminBest free tools for win database admin
Best free tools for win database admin
 
PowerShell Functions
PowerShell FunctionsPowerShell Functions
PowerShell Functions
 
PowerShell 8tips
PowerShell 8tipsPowerShell 8tips
PowerShell 8tips
 
Advanced Tools & Scripting with PowerShell 3.0 Jump Start - Certificate
Advanced Tools & Scripting with PowerShell 3.0 Jump Start - CertificateAdvanced Tools & Scripting with PowerShell 3.0 Jump Start - Certificate
Advanced Tools & Scripting with PowerShell 3.0 Jump Start - Certificate
 
Best free tools for w d a
Best free tools for w d aBest free tools for w d a
Best free tools for w d a
 
Free tools for win server administration
Free tools for win server administrationFree tools for win server administration
Free tools for win server administration
 
Server Core2
Server Core2Server Core2
Server Core2
 
VDI-in-a-Box: Microsoft Desktop Virtualization for Smaller Businesses and Uses
VDI-in-a-Box:  Microsoft Desktop Virtualization for Smaller Businesses and UsesVDI-in-a-Box:  Microsoft Desktop Virtualization for Smaller Businesses and Uses
VDI-in-a-Box: Microsoft Desktop Virtualization for Smaller Businesses and Uses
 
PowerShell v4 Desired State Configuration
PowerShell v4 Desired State ConfigurationPowerShell v4 Desired State Configuration
PowerShell v4 Desired State Configuration
 
Three cool cmdlets I wish PowerShell Had!
Three cool cmdlets I wish PowerShell Had!Three cool cmdlets I wish PowerShell Had!
Three cool cmdlets I wish PowerShell Had!
 
Introduction to powershell
Introduction to powershellIntroduction to powershell
Introduction to powershell
 
PowerShell custom properties
PowerShell custom propertiesPowerShell custom properties
PowerShell custom properties
 
Basic PowerShell Toolmaking - Spiceworld 2016 session
Basic PowerShell Toolmaking - Spiceworld 2016 sessionBasic PowerShell Toolmaking - Spiceworld 2016 session
Basic PowerShell Toolmaking - Spiceworld 2016 session
 
Managing SQLserver
Managing SQLserverManaging SQLserver
Managing SQLserver
 
PS error handling and debugging
PS error handling and debuggingPS error handling and debugging
PS error handling and debugging
 
Automating ad with powershell
Automating ad with powershellAutomating ad with powershell
Automating ad with powershell
 
PowerShell crashcourse for sharepoint
PowerShell crashcourse for sharepointPowerShell crashcourse for sharepoint
PowerShell crashcourse for sharepoint
 

Similaire à The elements' object model in UIAutomation PowerShell Extensions, part 1

Tutorial ranorex
Tutorial ranorexTutorial ranorex
Tutorial ranorex
radikalzen
 
qtp 9.2 features
qtp 9.2 featuresqtp 9.2 features
qtp 9.2 features
krishna3032
 
Qtp 92 Tutorial Anil
Qtp 92 Tutorial AnilQtp 92 Tutorial Anil
Qtp 92 Tutorial Anil
guest3373d3
 
Qtp 9.2 Tutorial
Qtp 9.2 TutorialQtp 9.2 Tutorial
Qtp 9.2 Tutorial
guest37ae7f
 
QTP with Descriptive programming
QTP with Descriptive programmingQTP with Descriptive programming
QTP with Descriptive programming
Kuldeep Sharma
 
Qtp with descriptive programming
Qtp with descriptive programmingQtp with descriptive programming
Qtp with descriptive programming
medsherb
 
Qtp With Descriptive Programming
Qtp With Descriptive ProgrammingQtp With Descriptive Programming
Qtp With Descriptive Programming
Kuldeep Sharma
 

Similaire à The elements' object model in UIAutomation PowerShell Extensions, part 1 (20)

Quality of life through Unit Testing
Quality of life through Unit TestingQuality of life through Unit Testing
Quality of life through Unit Testing
 
Tutorial ranorex
Tutorial ranorexTutorial ranorex
Tutorial ranorex
 
The real beginner's guide to android testing
The real beginner's guide to android testingThe real beginner's guide to android testing
The real beginner's guide to android testing
 
ITGM8. Всеволод Брекелов (Grid Dinamics) Component tests. let's do that!
ITGM8. Всеволод Брекелов (Grid Dinamics) Component tests. let's do that!ITGM8. Всеволод Брекелов (Grid Dinamics) Component tests. let's do that!
ITGM8. Всеволод Брекелов (Grid Dinamics) Component tests. let's do that!
 
Qtp 92 Tutorial769
Qtp 92 Tutorial769Qtp 92 Tutorial769
Qtp 92 Tutorial769
 
Qtp 92 Tutorial769
Qtp 92 Tutorial769Qtp 92 Tutorial769
Qtp 92 Tutorial769
 
qtp 9.2 features
qtp 9.2 featuresqtp 9.2 features
qtp 9.2 features
 
Qtp 92 Tutorial
Qtp 92 TutorialQtp 92 Tutorial
Qtp 92 Tutorial
 
Ppt Qtp
Ppt QtpPpt Qtp
Ppt Qtp
 
Qtp 92 Tutorial769
Qtp 92 Tutorial769Qtp 92 Tutorial769
Qtp 92 Tutorial769
 
Qtp 92 Tutorial Anil
Qtp 92 Tutorial AnilQtp 92 Tutorial Anil
Qtp 92 Tutorial Anil
 
Qtp 9.2 Tutorial
Qtp 9.2 TutorialQtp 9.2 Tutorial
Qtp 9.2 Tutorial
 
Asp netmvc e03
Asp netmvc e03Asp netmvc e03
Asp netmvc e03
 
Unit Testing with Python
Unit Testing with PythonUnit Testing with Python
Unit Testing with Python
 
TDD And Refactoring
TDD And RefactoringTDD And Refactoring
TDD And Refactoring
 
Gui
GuiGui
Gui
 
QTP with Descriptive programming
QTP with Descriptive programmingQTP with Descriptive programming
QTP with Descriptive programming
 
Qtp with descriptive programming
Qtp with descriptive programmingQtp with descriptive programming
Qtp with descriptive programming
 
Qtp With Descriptive Programming
Qtp With Descriptive ProgrammingQtp With Descriptive Programming
Qtp With Descriptive Programming
 
intro_gui
intro_guiintro_gui
intro_gui
 

Dernier

Dernier (20)

HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 

The elements' object model in UIAutomation PowerShell Extensions, part 1