Pass WebUI object name in data driven approach to mouse over and click menu dynamically

I am working on a test case to hover over menu and click sub menu dynamically using data driven approach by passing object name using variable and validating control is directed to target using Verify Match keyword by passing the URL of the destination page.

Failed approach:

  1. created internal data with three columns that houses main menu, sub menu object name and the destination url
  2. created variables at test case level and passed it as object name using a test suite


Can someone let me know if there is a way to pass object name as variable and execute test case using a test suite

I am not sure why it is a failed approach? and is there any error message you got with the approach?

it also help if you go the script tab and copy/paste the script here for more information

Hello Brian,

Thanks for your response. This is the code generated in the script tab

import static com.kms.katalon.core.checkpoint.CheckpointFactory.findCheckpoint
import static com.kms.katalon.core.testcase.TestCaseFactory.findTestCase
import static com.kms.katalon.core.testdata.TestDataFactory.findTestData
import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject
import com.kms.katalon.core.checkpoint.Checkpoint as Checkpoint
import com.kms.katalon.core.cucumber.keyword.CucumberBuiltinKeywords as CucumberKW
import com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords as Mobile
import com.kms.katalon.core.model.FailureHandling as FailureHandling
import com.kms.katalon.core.testcase.TestCase as TestCase
import com.kms.katalon.core.testdata.TestData as TestData
import com.kms.katalon.core.testobject.TestObject as TestObject
import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords as WS
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
import internal.GlobalVariable as GlobalVariable
import com.kms.katalon.core.logging.KeywordLogger as KeywordLogger

WebUI.openBrowser(’’)

WebUI.maximizeWindow()

WebUI.navigateToUrl(‘https://msdn.microsoft.com/en-us/’)

‘KeywordLogger log = new KeywordLogger()’

‘log.logInfo varMMenu’

WebUI.mouseOver(findTestObject(varMMenu))

WebUI.delay(2)

WebUI.click(findTestObject(varSMenu))

‘Validate click action results in opening target page’

‘Validate URL’
CurrentURL = WebUI.getUrl()

WebUI.verifyMatch(CurrentURL, varDestURL, false)

WebUI.delay(3)

WebUI.closeBrowser()

Brian, I identified the issue and fixed it. The test case was failing as I wasn’t providing full name of the object/menu the includes the location of the object. For instance, hovering menu Community in the msdn site. The object is under folder Main menu in the Object repository. The input file should contain value “Main menu/community”. Instead the file contained value Community and the tool wasn’t able to find the object/menu Community.

1 Like