14. • Created by Microsoft
• Based on a subset of COM
• Still included in “OLE”
• Intended for use by scripting languages
What is OLE Automation?
14
C C++ C#
Visual
Basic
Java
VBScript Perl PHP Python Ruby
23. • Object::methods
• Not helpful
Ruby
Methods
• WIN32OLE::ole_methods
• WIN32OLE::ole_put_methods
• Very informative
OLE
Methods
Ruby Methods vs OLE Methods
23
48. Resources
• Joshua Russell on GitHub:
– https://github.com/RussellJoshuaA
• This presentation on GitHub:
– https://github.com/RussellJoshuaA/ruby_win32ole_presentation/
48
49. Consider using OLE
• Task Automation
• Acceptance Testing
Applications on Windows
• Microsoft Office
• Mainframe Terminal Emulators
Ruby and WIN32OLE
Conclusion
49
52. • COM is used to create software components that can interact
• COM is a standard which specifies an object model and
programming requirements that enable COM objects to
interact with other objects
• COM is the foundation for OLE, ActiveX, and other
technologies
Component Object Model
52
53. • A COM object is one which provides access to its data
exclusively through one or more sets of interfaces
• COM objects can be created with a variety of programming
languages
COM Object
53
54. • COM makes a fundamental distinction between interface
definitions and their implementations
• An interface is a group of related function prototypes whose
usage is defined but whose implementation is not
• An interface implementation is the code that carries out the
actions specified in an interface definition
COM Interfaces
54
55. • “OLE” was originally an acronym for Object Linking and
Embedding. Now it’s just “OLE”.
• OLE is a mechanism for manipulating documents created by
multiple applications
What is OLE?
55
56. • OLE incorporates many concepts:
– Linking and Embedding
– In-Place Activation (Visual Editing)
– Automation
– Compound Files
– Uniform Data Transfer
– Drag and Drop
– Component Object Model
OLE is made of stuff
56
57. • Power-Up Your Test Suite with OLE Automation
– For test automation, every platform is a challenge that requires a
unique solution. For many native applications in a Windows
environment, the appropriate automation solution is OLE
Automation. From testing desktop applications & stored
procedures to data management & metrics, the combination of
Ruby and WIN32OLE can automate tests on native Windows
apps. The audience will learn the capabilities and limitations of
automation using Microsoft’s Automation interface, with
examples in Excel, Internet Explorer, and PASSPORT terminal
emulator. For those staying through the End Credits, we’ll have a
special bonus scene!
Abstract
57
Microsoft applications, implementation robust. Internet Explorer, IBM Notes, HP ALM/QC
Excel is an especially good target for OLE Automation. Ruby gems that manipulate Excel file formats have limitations
Mainframe applications for both task automation (test data) and acceptance testing. Rocket Passport, DN-Computing Quick3270, Micro Focus Attachmate Extra! X-treme
Automate repetitive tasks and test setup. OLE Automation does not exercise the user interface.
OLE Automation = means of manipulating applications directly by accessing objects that they expose || Popular options >> Selenium-webdriver, RAutomation || Several names: COM automation, subset of COM; Previously “OLE Automation”, now “Automation” …Too vague to be helpful. “The Application Interface Formerly Known As OLE Automation”.
Created by Microsoft >> Based on a subset of COM, standard for creating software which can communicate >> OLE, grab bag of semi-related functionalities, scripting languages, bunch of languages >> list (Java 3rd party)
Client and server model: Automation clients, automation servers
An application (a type of COM server) which exposes its functionality through COM interfaces to other applications is an automation server
An application which accesses the objects exposed by an automation server is called an automation client
Application implements object model. Objects exposed have properties and methods that can be accessed and manipulated. Dictates how automation can interact.
ATA!!! How many Ruby devs? The Ruby implementation of OLE Automation is called WIN32OLE. WIN32OLE is not a Ruby gem, it is a part of the Ruby standard library since 1.8
WIN32OLE does not need to be installed, just required. Access an OLE object by creating an instance of the WIN32OLE class and providing the program ID of the automation server
The program ID is located in the Windows registry
Ruby Object methods. Not helpful. OLE methods. Everything you need to know. Use OLE methods to get access to other OLE objects
Mainframe automation for data concerns. Cattle, not pets. Selfish data. Repeatable scenarios.
As mentioned before, several mainframe terminal emulators support OLE Automation. Quick3270 from DN-Computing, Extra! From Micro Focus, and Passport from Rocket all have published interfaces.
TE3270 is a Ruby gem for mainframe automation. Supports a handful of terminal emulators, some using OLE Automation. Except Passport. It doesn’t support Passport, unless you make some creative changes. I’ll link it.
TE3270Create classes to represent mainframe screens. Identify fields by row, column, and length. Define custom methods for screen classes
Example using Ruby, Cucumber, and the TE3270 gem for data management
TE3270 factory methods and simple interactions with screen classes make clean, readable step definitions for Cucumber scenarios that interact with mainframe screens.
First scenario wrapper for Ruby code, ease-of-use, second scenario more readable, actual example
Launch mainframe, log in, find user, unenroll, reenroll with temp credentials
ATA!!! Who manages daily/weekly/monthly reports with Excel? Collections of data? How much time?
Follow Ruby basics. What happened? One more step… manipulate the application object
There we go! Application -> Workbooks. Methods are like the File menu. Add new, open existing. In this case, open.
Workbook immediately visible. Workbooks collection. Access Customers worksheet by index, name. Same for Orders. Add new worksheet.
Rows collection, access rows by index.
Columns collection, just like Rows. Access by index.
Cells collection, again… the same. Access by row, column or by single index
Close one workbook or close them all.
Quit the application.
Charts. Formulas. Formatting. Version control. You can find more information about the capabilities of Excel OLE Automation by referencing the Microsoft documentation of the Excel Object Model…
DCOM: OLE Automation over network, Event handling with “sink interfaces”, A subset of the COM interface is implemented on Apple’s Core Foundation