i have recorded updating steps in a website and want to replicate the same steps in multiple sites with the identical parameter with one variable parameter.
Here the target value in 1st row is website (test1.com) and value in 2nd last row is variable (test1 Comment).
I need to update in multiple websites with different comments…how can i create the csv file for this and upload using katalon add on.
| Command |
Target |
Value |
| Click |
test1.com |
|
| Click |
xpath=(.//*[normalize-space(text())] |
|
| Click |
xpath=(.//*[normalize-space(text()) and normalize-space(.) |
|
| Click |
name=subject |
|
| type |
name=subject |
test1 Comment |
| Click |
id=submit-button |
|
Regards,
hello,
download opencsv .jar
add it to the project Drivers folder
restart Katalon Studio
and use it
simple example methods
import com.opencsv.CSVReader
import com.opencsv.CSVReaderBuilder
import com.opencsv.CSVWriter
public void WriteCsvFile(){
File file = new File("data1.csv");
if(file.exists()){
return
}
else{ CSVWriter writer = new CSVWriter(new FileWriter(file));
//Create record
String [] record = "4,David,Miller,Australia,30".split(",");
//Write the record to file
writer.writeNext(record);
//close the writer
writer.close();
}
System.out.println("End.");
}
public void appendToCsvFile() throws Exception
{
String csv = "data1.csv";
CSVWriter writer = new CSVWriter(new FileWriter(csv, true));
String [] record = "3,David,Feezor,USA,40".split(",");
writer.writeNext(record);
writer.close();
}
public void readLines() throws Exception
{
//Build reader instance
//Start reading from line number 2 (line numbers start from zero)
CSVReader csvReader = new CSVReaderBuilder(new FileReader("data1.csv")).withSkipLines(1).build()
//Read CSV line by line and use the string array as you want
String[] nextLine;
while ((nextLine = csvReader.readNext()) != null) {
if (nextLine != null) {
//Verifying the read data here
System.out.println(Arrays.toString(nextLine));
}
}
}
Hi Timo,
Thanks…i am very new to katalon and want to use the data driven testing from katalon recorder using add csv file option. Below is the code of the recording that i have made.
Variables are highlighted in bold in below line numbers. I need to create csv file for these variables and perform data driven testing in katalon recorder add on
- selenium.type(“id=search-suggestions-timeout-field”, “5655085702”)
- selenium.click(“link=5655085702”)
- selenium.type(“name=subject”, “Test Comment”)
Katalon script exported after recorded in katalon recorder.
1 WebUI.openBrowser(‘https://www.katalon.com/’)
2. def driver = DriverFactory.getWebDriver()
3. String baseUrl = “https://www.katalon.com/”
4. selenium = new WebDriverBackedSelenium(driver, baseUrl)
5. selenium.open("https://Testsite.com")
6. selenium.click(“id=search-suggestions-timeout-field”)
7. selenium.type(“id=search-suggestions-timeout-field”, “5655085702”)
8. selenium.click(“id=search-form-custom-submit-button-native”)
9. selenium.click(“link=5655085702”)
10. selenium.selectWindow(“win_ser_1”)
11. selenium.click(“xpath=//[@id=“case-actions”]/span/span/span")
12. selenium.click("xpath=//[@id=“case-actions-select_4”]/div”)
13. selenium.click(“name=subject”)
14. selenium.type(“name=subject”, “Test Comment”)
15. selenium.click(“id=update-case-details-form-custom-submit-button-native”)
16. selenium.close()
17. selenium.selectWindow(“win_ser_local”)