Hello experts,
I am new to Katalon and was just using the firefox add-in Katalon recorder for some repetitive data download on a website. I introduced a loop within these Katalon recorder steps and exported the codes as below. Unfortunately, I am facing several problems with my code.
First of all, they are executing very fast on the web browser (causing it to issue an error message) and I would like to introduce a wait time to slow each of the 50 iterations of the loop but I am not clear how to do this (which Katalon recorder command should I use for this and where in the codes below would the wait code enter?)
Second, I need to tell the database to extract a certain number of observations (e.g. for one type of download, I am limited to 47619 observations at any one time - hence the need for a loop to do this as I have to extract about 6 millions observations and I need to repeat this about 200 times). Thus, there are two fields on that form (a from: and a to: field) as follows:
from: 1 to: 47619
from: 47620 to: 95238
from: 95239 to: 142857
and so on…
On Katalon recorder, I entered the following for the from: and to: fields:
((${i}-1)*47619)+1
and
${i}*47619
I am not clear though if my codes are really capturing the gist of how I want the counter to increment and get the correct from: and to: fields filled.
Grateful for any suggestions on this. Codes follow below.
Thank you and regards,
Dev
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.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.webui.driver.DriverFactory as DriverFactory
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUiBuiltInKeywords
import internal.GlobalVariable as GlobalVariable
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
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.google.com/’)
def driver = DriverFactory.getWebDriver()
String baseUrl = “https://www.google.com/”
selenium = new WebDriverBackedSelenium(driver, baseUrl)
selenium.open(“mywebsitehere.com”)
selenium.click(“link=Excel”)
selenium.click(“id=component_FileName”)
String i = “1”
selenium.while(“i<30”)
selenium.type(“id=component_FileName”, “$fr_bs_ltl17_” + i)
selenium.click(“id=component_RangeOptionSelectedId”)
selenium.select(“id=component_RangeOptionSelectedId”, “label=A range of companies”)
selenium.click("//option[@value=‘Range’]")
selenium.click(“name=component.From”)
selenium.type(“name=component.From”, “((” + i + “-1)*47619)+1”)
selenium.click(“name=component.To”)
selenium.type(“name=component.To”, i + “*47619”)
selenium.click(“link=Export”)
selenium.click("//img[@alt=‘X’]")
selenium.click("//img[@alt=‘Export’]")
String = selenium.getEval(i + “+1”)
selenium.endWhile()