a problem with my set text

I am working on a report as a new employee in my company, this report is for me to learn about Katalon and automation itself. This report is a web-based report and how the program works is as such:
image
image

The Script:
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 static com.kms.katalon.core.testobject.ObjectRepository.findWindowsObject
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.testng.keyword.TestNGBuiltinKeywords as TestNGKW
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 com.kms.katalon.core.windows.keyword.WindowsBuiltinKeywords as Windows
import internal.GlobalVariable as GlobalVariable
import org.openqa.selenium.Keys as Keys

WebUI.openBrowser(‘’)

login stuffs

WebUI.click(findTestObject(‘Object Repository/52/52.002/Page_Operasional Perum Jamkrindo/input_Password_Submit’))

WebUI.delay(3)

WebUI.click(findTestObject(‘Object Repository/52/52.002/Page_PERUM JAMKRINDO/a_SIE’))

WebUI.click(findTestObject(‘Object Repository/52/52.002/Page_PERUM JAMKRINDO/a_PUSAT’))

WebUI.click(findTestObject(‘Object Repository/52/52.002/Page_PERUM JAMKRINDO/a_PENERBITAN SERTIFIKAT’))

WebUI.selectOptionByValue(findTestObject(‘Object Repository/52/52.002/Page_PERUM JAMKRINDO/select_12345678910111213141516171819202122232425262728293031’),
‘1’, true)

WebUI.selectOptionByValue(findTestObject(‘Object Repository/52/52.002/Page_PERUM JAMKRINDO/select_JanFebMarAprMeiJunJulAguSepOktNovDes’),
‘5’, true)

WebUI.setText(findTestObject(‘Object Repository/52/52.002/Page_PERUM JAMKRINDO/input_Periode Sertifikat_tglAwalProdukUnitB_f68dd7’),
‘2021’)

WebUI.selectOptionByValue(findTestObject(‘Object Repository/52/52.002/Page_PERUM JAMKRINDO/select_123456789101112131415161718192021222_566da4’),
‘30’, true)

WebUI.selectOptionByValue(findTestObject(‘Object Repository/52/52.002/Page_PERUM JAMKRINDO/select_JanFebMarAprMeiJunJulAguSepOktNovDes_1’),
‘5’, true)

WebUI.setText(findTestObject(‘Object Repository/52/52.002/Page_PERUM JAMKRINDO/input_S_tglAkhirProdukUnitBank_Year_ID’), ‘2021’)

WebUI.selectOptionByValue(findTestObject(‘Object Repository/52/52.002/Page_PERUM JAMKRINDO/select_BULANJANUARIFEBRUARIMARETAPRILMEIJUN_14387c’),
‘04’, true)

WebUI.selectOptionByValue(findTestObject(‘Object Repository/52/52.002/Page_PERUM JAMKRINDO/select_TAHUN2022202120202019201820172016201_ccbfbf’),
‘2022’, true)

WebUI.selectOptionByValue(findTestObject(‘Object Repository/52/52.002/Page_PERUM JAMKRINDO/select_-- Semua Bank Non bank --BANK AGRONI_5ceedb’),
‘15’, true)

WebUI.selectOptionByValue(findTestObject(‘Object Repository/52/52.002/Page_PERUM JAMKRINDO/select_-- Semua Kanwil --Kanwil 1 (Medan)Ka_7d99a3’),
‘3’, true)

WebUI.selectOptionByValue(findTestObject(‘Object Repository/52/52.002/Page_PERUM JAMKRINDO/select_-- Semua Wilayah Kerja --DKI Jakarta_f691fe’),
‘2’, true)

WebUI.selectOptionByValue(findTestObject(‘Object Repository/52/52.002/Page_PERUM JAMKRINDO/select_-- Semua LOB–KBG dan SuretyshipKons_a3a03b’),
‘3’, true)

WebUI.selectOptionByValue(findTestObject(‘Object Repository/52/52.002/Page_PERUM JAMKRINDO/select_-- Semua Produk --BRIGUNA BRICustoms_f4eb36’),
‘52’, true)

WebUI.switchToWindowTitle(‘:: :: PERUM JAMKRINDO :: ::’)

WebUI.click(findTestObject(‘Object Repository/52/52.002/Page_PERUM JAMKRINDO/input_Peruntukan_submit01’))

WebUI.closeBrowser()

What I find puzzling is when the test case is being run, item number 12 and 15, which is the set text does not input the correct numbers, even though I have recorded the number according to the test scenario provided by my company. More puzzlingly, my test case does not show any errors whatsoever, because in the Log Viewer it runs the supposed number, but in the “simulated browser” (I don’t know what it’s called), the browser running the test case, it does not input the supposed number.

image

What should I do? Thanks in advance.

Couple of things, start with manually inputting the text into those fields in a fresh browser window. I don’t know the nature of the web page, but if there’s default behavior that replaces the string if it’s outside a certain bound (namely anything less than the current year) this could cause this to happen. It likely isn’t the case, but I have to write automations for a strange website myself so I have a habit of checking.

Also, is there any default text in that field before you set the text?

PS: You also gave us the domain, user name, and password in the script :frowning:

I think you need to “know” a bit about the application, so here goes:

  1. In all of your “selectOptionByValue”, you have the boolean set to true.
WebUI.selectOptionByValue(findTestObject(...), '04', true)

This may be the default setting, but you need to be in control–the true means that you want to use Regular Expression. Regex allows the use of wildcards for substitution and comparison, which you do not want from your test case that I can see. Change them all to false, like I show below.

WebUI.selectOptionByValue(findTestObject(...), '04', false)
  1. You are using “selectOptionByValue”. I think you want to use “selectOptionByLabel” instead. The value is within the HTML of the page, which you probably have not looked at. The label is what you can see in the drop-down. Change the statement as below:
WebUI.selectOptionByLabel(findTestObject(...), '04', false)

Edit: even though you are entering “values”, like 04, the actual values that you would have to use in the statement are in the HTML, and you would have to match those HTML values to have the proper reference display. For 04, they might be the same, but for 2021, it may not be. You want the labels that are the references you see.

See if these help.

i noticed my mistake on the image but failed to notice the mistake in my script, thank you for correcting me🙏🏾

regarding your answer i will gladly learn more about this because i’ve only learnt about Katalon and automation for approximately 11 days as of replying.

thank you🙏🏾

Edit:
regarding the default text in that field, it’s “2022”, as seen in the provided image.

So I thought I would carry on with some more info.

You have your script entering the text and selecting the drop-downs, but you do not have any confirmation that the text was entered correctly or the appropriate drop-down value was chosen. After selecting the label, you can verify the label was chosen.

WebUI.selectOptionByLabel(findTestObject('Object Repository/52/52.002/Page_PERUM JAMKRINDO/select_12345678910111213141516171819202122232425262728293031'),
'1', false)

WebUI.verifyOptionSelectedByLabel(findTestObject('Object Repository/52/52.002/Page_PERUM JAMKRINDO/select_12345678910111213141516171819202122232425262728293031'),
'1', false, 10)

After setting the text, verify the text was set.

WebUI.setText(findTestObject('Object Repository/52/52.002/Page_PERUM JAMKRINDO/input_Periode Sertifikat_tglAwalProdukUnitB_f68dd7'), '2021')

WebUI.verifyElementAttributeValue(findTestObject('Object Repository/52/52.002/Page_PERUM JAMKRINDO/input_Periode Sertifikat_tglAwalProdukUnitB_f68dd7'), "value", '2021', 10)

Hello.

I am sorry for my late reply as I only replied once I’m at office and tried your solution. And try I did.

For the selectOptionByLabel it worked in one object and it did not work for the other object, so I went back with selectOptionByValue on the object that did not work.

The bane for my project, the Set Text catastrophe, gives out the following result:

image

which leaves me at a loss for words. Even though my supervisor has gave me a different scenario to cater for this problem, I am still determined to solve this problem with the intended scenario. I am hoping for more guidance on this problem.

Edit:
It turns out that the dates for my problem is automated to change every single passing day each time I opened the web. A little something I found after asking the programmer.

Like @joel.scott mentions, if there is something already in the textbox, then you may have to remove it first before you set your text.

WebUI.clearText(findTestObject('Object Repository/52/52.002/Page_PERUM JAMKRINDO/input_Periode Sertifikat_tglAwalProdukUnitB_f68dd7'))
WebUI.setText(findTestObject('Object Repository/52/52.002/Page_PERUM JAMKRINDO/input_Periode Sertifikat_tglAwalProdukUnitB_f68dd7'), '2021')

As for “moving” dates, you can isolate the date parts, (day, month, year), from the current date and then use the date parts in your test script.

Get Date and Time parts separately in Java (tutorialspoint.com)