Oracle code samples (JavaScript SDK)
Select an item from a ListOfValues
This example selects an item from a list of values attached to an edit field.
In the application, this list looks like a '...' button. To open the list from a test you need to use a sendKey(SoftKeys.ListOfValues) statement.
var LFT = require("leanft"); var SDK = LFT.SDK; var expect = require("leanft/expect"); var whenDone = LFT.whenDone; var Desktop = LFT.Desktop; var Oracle = LFT.Oracle; var assert = require('assert'); jasmine.DEFAULT_TIMEOUT_INTERVAL = 120000; describe("Oracle application",function(){ beforeAll(function(done){ In this section, you launch the application you want to test. // Use the Web Add-in to navigate to the Oracle server in a browser, // log in to the application and navigate to the desired window. // Make sure to set up any configuration needed to open the application. whenDone(done); }); beforeEach(function(done){ SDK.init(); whenDone(done); }); // Select a value inside ListOfValues control. it("Test ListOfValues",function(done){ // Create a description for a FormWindow control and set the properties to identify the FormWindow uniquely. let distributionListsFormWindow = Desktop.$(Oracle.FormWindow({ shortTitle: "Distribution Lists" })); // Create a description for a EditField control and set the properties to identify the EditField uniquely. let applicationEditField = distributionListsFormWindow .$(Oracle.EditField({ caption: "Application", objectName: "" })); // Use the sendKey method with parameter SoftKeys.LIST_OF_VALUES to open the ListOfValues control. applicationEditField.sendKey(Oracle.SoftKeys.listOfValues); // Create a description for a ListOfValues control and set the properties to identify the ListOfValues uniquely. let applicationsListOfValues = Desktop.$(Oracle.ListOfValues({ title: "Applications" })); // Use the find method to find values inside ListOfValues control. applicationsListOfValues.find("A%"); // Use the select method to select an item from the ListOfValues control. applicationsListOfValues.select(0); whenDone(done); }); afterEach(function(done){ SDK.cleanup(); whenDone(done); }); });
Set the value of a cell in a table
This example sets and then checks the value of a cell in an Oracle table.
var LFT = require("leanft"); var SDK = LFT.SDK; var expect = require("leanft/expect"); var whenDone = LFT.whenDone; var Desktop = LFT.Desktop; var Oracle = LFT.Oracle; var assert = require('assert'); jasmine.DEFAULT_TIMEOUT_INTERVAL = 120000; describe("Oracle application",function(){ beforeAll(function(done){ In this section, you launch the application you want to test. // Use the Web Add-in to navigate to the Oracle server in a browser, // log in to the application and navigate to the desired window. // Make sure to set up any configuration needed to open the application. whenDone(done); }); beforeEach(function(done){ SDK.init(); whenDone(done); }); //Verify cells from a table. it("Test Table",function(done){ // Create a description for a FormWindow control and set the properties to identify the FormWindow uniquely. let oracleAlertOptionsFormWindow = Desktop.$(Oracle.FormWindow({ shortTitle: "Oracle Alert Options" })); // Create a description for a List control. Set the properties to identify the List uniquely.let functionList = Desktop.$(Oracle.FormWindow({ shortTitle: "Navigator" })) .$(Oracle.Tab({ label: "Functions" })) .$(Oracle.List({ caption: "", classPath: "oracle.forms.ui.VTList;oracle.ewt.lwAWT.LWList;oracle.ewt.lwAWT.LWDataSourceList;oracle.ewt.lwAWT.LWContainer;oracle.ewt.lwAWT.LWComponent;java.awt.Container;java.awt.Component;java.lang.Object;", objectName: "" })); // Use the activate method with the item name to open a new FormWindow. functionList.activate("+ System"); // Use the activate method for child items. functionList.activate("Options"); // Create a description for a Table control and set the properties to identify the Table uniquely.let table = oracleAlertOptionsFormWindow .$(Oracle.Tab({ label: "Mail Systems" })) .$(Oracle.Table({ objectName: "Table" })); // Get the value of the control and check whether the cell in row 0 and column 0 has a specific value. table.cells(0,0).value().then(function(result){ expect(result === "Oracle InterOffice").toBeTruthy(); }); // Use the asTestObject method to get the inside test object from the cell in row 0 and column 1. // After we get the test object we can use the setText method to set the text of the EditField control. table.cells(0,1).asTestObject().then(function(testObj){ testObj.setText("text"); }); // Get the value of the control and check whether the previous step was performed correctly. table.cells(0,1).value().then(function(result){ expect(result === "text").toBeTruthy(); }); whenDone(done); }); afterEach(function(done){ SDK.cleanup(); whenDone(done); }); });
See also: