SAPUI5 code samples

Opening for SAPUI5 test script

This example shows how to open a test script for SAPUI5

var LFT = require("leanft");
var expect = require("leanft/expect");
var Web = LFT.Web;
var SAPUI5 = LFT.SAPUI5;
var browser;


jasmine.DEFAULT_TIMEOUT_INTERVAL = 120000;

describe("SAP UI5 examples",function(){
	beforeAll(function(done){
		LFT.init();
		LFT.whenDone(done);
	});

	beforeEach(function(done){
		LFT.beforeTest();

		Web.Browser.launch(Web.BrowserType.IE).then(function(launched_browser){
			browser = launched_browser;
		});

		LFT.whenDone(done);
	});

Back to top

Select and verify item from list

This example shows how to select an item from the list and verify that the selection is correct.

it("List select item by index", function (done) {
	// Navigate to the web site.
	browser.navigate("https://sapui5.netweaver.ondemand.com/sdk/#test-resources/sap/ui/commons/ListBox.html");

	// Identify the list box object.
	var listBox = browser.$(SAPUI5.ListBox({
		tagName:"DIV",
		id:"lb3"
	}));

	// Select the first item in the list by index.
	listBox.select(1);

	// Verify that selected item is as selected.
	listBox.selectedItems().then(function (selectedItems) {
		expect(selectedItems.length).toEqual(1);
	});

	LFT.whenDone(done);
});

Back to top

Delete item from list box object

This example shows how to delete an item from a list box object.

it("Delete an item from list", function (done) {
	// Navigate to the web site.
	browser.navigate("https://sapui5.hana.ondemand.com/sdk/test-resources/sap/m/List.html");

	// Navigate to the List box object.
	browser.$(SAPUI5.ListBox({
		tagName:"DIV",
		name:"List Overview"
	})).select("Standard List Thumb");

	// Make the list box items capable of being deleted.
	browser.$(SAPUI5.Button({
		tagName:"BUTTON",
		buttonType:"submit",
		name:"Delete"
	})).click();

	// Identify the list box object.
	var listBox = browser.$(SAPUI5.ListBox({
		tagName:"DIV",
		name:"Travel [List-Mode: Delete]"
	}));

	// Delete an item from the list box.
	listBox.delete("Travel Settings");

	LFT.whenDone(done);
});

Back to top

See also: