Variable ‘Keys’ is not defined for test case

I have the following line of code:

WebUI.sendKeys(findTestObject(‘Individual Sign Up/Personal Information/street’), Keys.chord(Keys.TAB))

When I run the program it returns the following error:

Variable ‘Keys’ is not defined for test case

I have added the following import:

import com.kms.katalon.core.webui.keyword.builtin.SendKeysKeyword as Keys

Then I got the following error:

Test Cases/New Account Fails/Fails Test FAILED because (of) Variable ‘TAB’ is not defined for test case.

I also changed the chord to be the same as in the Send Keys example in the documentation for WebUI (https://docs.katalon.com/display/KD/[WebUI]+Send+Keys) and then I got the following error:

Test Cases/New Account Fails/Fails Test FAILED because (of) Variable ‘CONTROL’ is not defined for test case.

Which library do I need to import to be able to use the Keys?

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.checkpoint.CheckpointFactory as CheckpointFactory
import com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords as MobileBuiltInKeywords
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.testcase.TestCaseFactory as TestCaseFactory
import com.kms.katalon.core.testdata.TestData as TestData
import com.kms.katalon.core.testdata.TestDataFactory as TestDataFactory
import com.kms.katalon.core.testobject.ObjectRepository as ObjectRepository
import com.kms.katalon.core.testobject.TestObject as TestObject
import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords as WSBuiltInKeywords
import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords as WS
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUiBuiltInKeywords
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
import internal.GlobalVariable as GlobalVariable

import org.openqa.selenium.Keys as Keys

//WebUI.click(findTestObject(‘Object Repository/ESSnESS_login/Page_ESS ESS (2)/span_Land OwnerDeveloper’))
WebUI.setText(findTestObject(‘Object Repository/ESSnESS_login/Page_ESS ESS/input_email’), Username)

WebUI.setText(findTestObject(‘Object Repository/ESSnESS_login/Page_ESS ESS/input_password’), Password)

WebUI.click(findTestObject(‘Object Repository/ESSnESS_login/Page_ESS ESS/button_Submit’))

WebUI.acceptAlert()

WebUI.callTestCase(findTestCase(‘Main Test Cases/EssnEss_1_Create_land_owner’), [“Username”:‘admin@gmail.com’, “Password”:‘Sahaadmin123#’], FailureHandling.STOP_ON_FAILURE)

Error:-Test Cases/Common Test Cases/ESSnESS_Login FAILED because (of) Variable ‘Username’ is not defined for test case.

Same error i am also getting.

Test Cases/Common Test Cases/ESSnESS_Login FAILED because (of) Variable ‘Username’ is not defined for test case.

Hi there,

What error message do you observe after using that package?

Thanks

The above solution is also not working i tried to import package ,but still facing issue

I’m facing the same issue, only in one test out of 4.

‘WebUI.sendKeys(findTestObject(‘pages/text_meta_description’), Keys.chord(Keys.TAB))’

I have the following line of code WebUI.switchToFrame(findTestObject(‘Page_eFACiLiTY - Enterprise Facilit/iframe_main’),GlobalVariable.G_Timeout_Small, FailureHandling.STOP_ON_FAILURE)

while running this code ,am getting following error,
Test Cases/New Test Case-login FAILED because (of) Variable ‘G_Timeout_Small’ is not defined for test case.

I have the following line of code

WebUI.switchToFrame(findTestObject(‘Page_eFACiLiTY - Enterprise Facilit/iframe_main’),GlobalVariable.G_Timeout_Small, FailureHandling.STOP_ON_FAILURE)

I imported following packages:

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.checkpoint.CheckpointFactory as CheckpointFactory

import com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords as MobileBuiltInKeywords

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.testcase.TestCaseFactory as TestCaseFactory

import com.kms.katalon.core.testdata.TestData as TestData

import com.kms.katalon.core.testdata.TestDataFactory as TestDataFactory

import com.kms.katalon.core.testobject.ObjectRepository as ObjectRepository

import com.kms.katalon.core.testobject.TestObject as TestObject

import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords as WSBuiltInKeywords

import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords as WS

import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUiBuiltInKeywords

import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI

import internal.GlobalVariable as GlobalVariable

while running this code ,am getting following error,
Test Cases/New Test Case-login FAILED because (of) Variable ‘G_Timeout_Small’ is not defined for test case.

How can i solve this error?

As i can able to record for the same iframe and can able to run the script using katalon Automation Tool for chrome inbuilt ,

Please check the code below ,

import com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords as Mobile

import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords as WS

import com.thoughtworks.selenium.Selenium

import org.openqa.selenium.firefox.FirefoxDriver

import org.openqa.selenium.WebDriver

import com.thoughtworks.selenium.webdriven.WebDriverBackedSelenium

import static org.junit.Assert.*

import java.util.regex.Pattern

import static org.apache.commons.lang3.StringUtils.join

WebUI.openBrowser(‘https://www.katalon.com/’)

def driver = DriverFactory.getWebDriver()

String baseUrl = “https://www.katalon.com/

selenium = new WebDriverBackedSelenium(driver, baseUrl)

selenium.open(" URL")

selenium.click(“id=Usr_name”)

selenium.type(“id=Usr_name”, “sa”)

selenium.type(“id=Usr_pwd”, “SA”)

selenium.click(“id=btn_login”)

selenium.click("//div[@id=‘DIV1’]/div")

selenium.click(“link=Masters”)

selenium.click("//div[@id=‘sidebar’]/div[2]/ul/li/ul/li/a/span")

selenium.selectFrame(“index=1”)

selenium.click("//a[@id=‘Action1_But_Add’]/i")

Please respond and help me out

Hdivya said:

I have the following line of code

WebUI.switchToFrame(findTestObject(‘Page_eFACiLiTY - Enterprise Facilit/iframe_main’),GlobalVariable.G_Timeout_Small, FailureHandling.STOP_ON_FAILURE)

I imported following packages:

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.checkpoint.CheckpointFactory as CheckpointFactory

import com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords as MobileBuiltInKeywords

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.testcase.TestCaseFactory as TestCaseFactory

import com.kms.katalon.core.testdata.TestData as TestData

import com.kms.katalon.core.testdata.TestDataFactory as TestDataFactory

import com.kms.katalon.core.testobject.ObjectRepository as ObjectRepository

import com.kms.katalon.core.testobject.TestObject as TestObject

import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords as WSBuiltInKeywords

import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords as WS

import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUiBuiltInKeywords

import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI

import internal.GlobalVariable as GlobalVariable

while running this code ,am getting following error,
Test Cases/New Test Case-login FAILED because (of) Variable ‘G_Timeout_Small’ is not defined for test case.

How can i solve this error?

As i can able to record for the same iframe and can able to run the script using katalon Automation Tool for chrome inbuilt ,

Please check the code below ,

import com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords as Mobile

import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords as WS

import com.thoughtworks.selenium.Selenium

import org.openqa.selenium.firefox.FirefoxDriver

import org.openqa.selenium.WebDriver

import com.thoughtworks.selenium.webdriven.WebDriverBackedSelenium

import static org.junit.Assert.*

import java.util.regex.Pattern

import static org.apache.commons.lang3.StringUtils.join

WebUI.openBrowser(‘https://www.katalon.com/’)

def driver = DriverFactory.getWebDriver()

String baseUrl = “https://www.katalon.com/

selenium = new WebDriverBackedSelenium(driver, baseUrl)

selenium.open(" URL")

selenium.click(“id=Usr_name”)

selenium.type(“id=Usr_name”, “sa”)

selenium.type(“id=Usr_pwd”, “SA”)

selenium.click(“id=btn_login”)

selenium.click("//div[@id=‘DIV1’]/div")

selenium.click(“link=Masters”)

selenium.click("//div[@id=‘sidebar’]/div[2]/ul/li/ul/li/a/span")

selenium.selectFrame(“index=1”)

selenium.click("//a[@id=‘Action1_But_Add’]/i")

Please respond and help me out

This is the root cause:
“Test Cases/New Test Case-login FAILED because (of) Variable ‘G_Timeout_Small’ is not defined for test case.”

So please double check if ‘G_Timeout_Small’ variable is used within your current test case but it is not created in other places

Anna Kruglyanskaya said:

I’m facing the same issue, only in one test out of 4.

‘WebUI.sendKeys(findTestObject(‘pages/text_meta_description’), Keys.chord(Keys.TAB))’

Adding import org.openqa.selenium.Keys as Keys to the import section worked for me.

Hi

I am still facing this issue.

import internal.GlobalVariable as GlobalVariable

import org.openqa.selenium.Keys as Keys

WebUI.openBrowser(’’)

WebUI.navigateToUrl(‘https://app.bronto.com/login/index/login/’)

WebUI.setText(findTestObject(‘input_username’), bronto_un)

I have defined this variable in the Execution Profile = “Bronto”.
So i do select this profile before i run my test case or test suite.

But get this error:
Test Cases/Bronto Login FAILED because (of) Variable ‘bronto_un’ is not defined for test case.

I followed this:
https://docs.katalon.com/pages/viewpage.action?pageId=13697476

Thanks
Andrew

Andrew said:

Hi

I am still facing this issue.

import internal.GlobalVariable as GlobalVariable

import org.openqa.selenium.Keys as Keys

WebUI.openBrowser(’’)

WebUI.navigateToUrl(‘https://app.bronto.com/login/index/login/’)

WebUI.setText(findTestObject(‘input_username’), bronto_un)

I have defined this variable in the Execution Profile = “Bronto”.
So i do select this profile before i run my test case or test suite.

But get this error:
Test Cases/Bronto Login FAILED because (of) Variable ‘bronto_un’ is not defined for test case.

I followed this:
https://docs.katalon.com/pages/viewpage.action?pageId=13697476

Thanks
Andrew

Variables in Profile is GLOBAL VARIABLES, so if you want to use these variables, you need to add GlobalVariables prefix, e.g:
WebUI.setText(findTestObject(‘input_username’), GlobalVariable.bronto_un)

Vinh Nguyen said:

Andrew said:

Hi

I am still facing this issue.

import internal.GlobalVariable as GlobalVariable

import org.openqa.selenium.Keys as Keys

WebUI.openBrowser(’’)

WebUI.navigateToUrl(‘https://app.bronto.com/login/index/login/’)

WebUI.setText(findTestObject(‘input_username’), bronto_un)

I have defined this variable in the Execution Profile = “Bronto”.
So i do select this profile before i run my test case or test suite.

But get this error:
Test Cases/Bronto Login FAILED because (of) Variable ‘bronto_un’ is not defined for test case.

I followed this:
https://docs.katalon.com/pages/viewpage.action?pageId=13697476

Thanks
Andrew

Variables in Profile is GLOBAL VARIABLES, so if you want to use these variables, you need to add GlobalVariables prefix, e.g:
WebUI.setText(findTestObject(‘input_username’), GlobalVariable.bronto_un)

Thank you Vinh!

I made it work. However for this I had to define this variabke inb Profile but also on the individual Test Case level. I believe it is incorrect. I should not define the global variable in Profile and each test case.

Andrew