Share this page

# SAPUI5 code samples (JavaScript SDK)

In this topic:

## 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:

- UFT Developer JavaScript SDK Reference
- UFT Developer JavaScript SDK code samples

Tips to improve your search results... UFT Developer JavaScript SDK Reference Version 15.0-15.0.2 UFT Developer SDK Reference All View Local Help Center View Online Help Center back Go back in browser history forward Go forward in browser history Remove search highlights next topic Go to next topic previous topic Go to previous topic Print the current topic Version: