Creating a automatic download

Hi there all,

is there anyone who can make me an offer to automatically get the data from the booking table from the smoobu.com website.
I want to start the job automatically from a PC.
Thanks for helping me.
I am awaiting your offer

thanks in advance

Bert Lohmer
You can also reach me under bert.lohmer@gmx.de

hello,

hard to find out what data is really needed
which table etc

thanks for answering me

it ist smoobu.com and here is under the point bookings the possibility to make a download in Excel form.
That is what i need.
This should be automaticaley once a hour.

thanks a lot for answering me

thanks and best wishes

Bert

hi,

not able to see any excel download link.
but if you are seen it then download it, and read it to list or read line by line (maybe Katalon excel Plugin will help you)
hard to say exact anything, cause too few data what you are really doing

sorry, it is a little more difficult.
If you want to help me you can make a test registration by smoobu.com. Then you can make test bookings. This test bookings you can see under the topic bookings. Also here you can download this bookings in Excel.
That is what I need.
Sorry but i am a beginner by Katalon.

thanks a lot and have a good day

Bert

hi,

i got it
you have to use ChromeOptions options like this to set download path either using script or in Katalon Studio adding those settings under Project Settings --> Desired Capabilities --> WebUI --> Chrome
in script added options
public WebDriver setChromeOptions(File folder){
	
	ChromeOptions options = new ChromeOptions();
	String downloadPath = folder.getAbsolutePath()
	//String downloadsPath = System.getProperty("user.home") + "/Downloads";
	println ("downloadpath "+downloadPath)
	
	Map<String, Object> chromePrefs = new HashMap<String, Object>()
	chromePrefs.put("profile.default_content_settings.popups", 0);
	chromePrefs.put("download.default_directory", downloadPath)
	chromePrefs.put("download.prompt_for_download", false)
	chromePrefs.put("plugins.plugins_disabled", "Chrome PDF Viewer");
	options.addArguments("--test-type")
	options.addArguments("--disable-gpu")
	options.addArguments("--no-sandbox")
	options.addArguments("--disable-dev-shm-usage")
	options.addArguments("--disable-software-rasterizer")
	options.addArguments("--disable-popup-blocking")
	options.addArguments("--disable-extensions")
	options.setExperimentalOption("prefs", chromePrefs)
	DesiredCapabilities cap = DesiredCapabilities.chrome()
	cap.setCapability(ChromeOptions.CAPABILITY, options)
	cap.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
	
	System.setProperty("webdriver.chrome.driver", DriverFactory.getChromeDriverPath())
	WebDriver driver = new ChromeDriver(cap);
	return driver
}

after that use Excel Plugin to get data from downloaded excel etc

that it's a big stuff
needed lot of coding to get properly result

hello boy,

something like this way to process excel data

TESTCASE

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

String path = System.getProperty("user.dir")+"\\ExcelFiles\\SmoobuBookings - 2019-5-20.xls";
List<String> headerValues = new ArrayList<String>();
List<String> excelValues = new ArrayList<String>();
int processRows = 5;  //how many rows to get processed
int start = 0;
int end = 1;

headerValues = CustomKeywords.'excelHelper.ExcelUtil.ExcelHelper'(20, start, end, path)//get header values

//increase start & end to get data rows
start = 1;
end = 2;

for (int x = 0; x < processRows; x++) {
	excelValues = CustomKeywords.'excelHelper.ExcelUtil.ExcelHelper'(headerValues.size(), start, end, path)
	int i = 0;

	for (String s : headerValues) {
		if (excelValues.get(i).equals("**No Value**")) {
			System.out.println("Row " + start + " Header " + headerValues.get(i) + " has not value ");
		} else {
			System.out.println("Row " + start + " Header " + headerValues.get(i) + " has value " + excelValues.get(i));
		}
		i++;
	}
	start++;
	end++;
}

KEYWORD
package excelHelper

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.annotation.Keyword
import com.kms.katalon.core.checkpoint.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
import com.kms.katalon.core.testcase.TestCase
import com.kms.katalon.core.testdata.TestData
import com.kms.katalon.core.testobject.TestObject
import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords as WS
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI

import internal.GlobalVariable

import org.apache.poi.ss.usermodel.*;

import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.xssf.usermodel.*;

import java.util.ArrayList;
import java.util.List;

public class ExcelUtil {
	
	@Keyword
	public List<String> ExcelHelper(int colCount, int start, int end, String path) throws IOException, InvalidFormatException {
		
		List<String> excelValues = new ArrayList<String>();
		int MY_MINIMUM_COLUMN_COUNT = colCount;

		Workbook book = WorkbookFactory.create(new File(path));

		//Get first/desired sheet from the workbook
		Sheet sheet = book.getSheetAt(0);

		// Create a DataFormatter to format and get each cell's value as String
		DataFormatter dataFormatter = new DataFormatter();

		// Decide which rows to process
		int rowStart = start;
		//System.out.println("row start "+rowStart);
		int rowEnd = end;
		//System.out.println("row end "+rowEnd);

		for (int rowNum = rowStart; rowNum < rowEnd; rowNum++) {
			Row r = sheet.getRow(rowNum);
			if (r == null) {
				// This whole row is empty
				// Handle it as needed
				continue;
			}

			int lastColumn = Math.max(r.getLastCellNum(), MY_MINIMUM_COLUMN_COUNT);
			//System.out.println("last column "+lastColumn);

			for (int cn = 0; cn < lastColumn; cn++) {
				Cell c = r.getCell(cn, Row.RETURN_BLANK_AS_NULL);
				if (c == null) {
					excelValues.add("**No Value**");
					// The spreadsheet is empty in this cell
				} else {
					// Do something useful with the cell's contents
					excelValues.add(dataFormatter.formatCellValue(c));
				}
			}
		}

		return excelValues;
	}
}

and results
Row 1 Header Position has value 1156334
Row 1 Header Arrival has value 20.05.19
Row 1 Header Departure has value 21.06.19
Row 1 Header Property has value Property 1
Row 1 Header Guest has value csdcasa
Row 1 Header Portal has value Direct booking
Row 1 Header Created has value 2019-05-20 16:22
Row 1 Header Email has not value
Row 1 Header Phone has not value
Row 1 Header Address has not value
Row 1 Header Adults has not value
Row 1 Header Children has not value
Row 1 Header Check-in has not value
Row 1 Header Check-out has not value
Row 1 Header Notes has not value
Row 1 Header Price has not value
Row 1 Header Paid has value No
Row 1 Header Prepayment has not value
Row 1 Header Paid has value No
Row 1 Header Number of nights has value 32
Row 2 Header Position has not value
Row 2 Header Arrival has not value
Row 2 Header Departure has not value
Row 2 Header Property has not value
Row 2 Header Guest has not value
Row 2 Header Portal has not value
Row 2 Header Created has not value
Row 2 Header Email has not value
Row 2 Header Phone has not value
Row 2 Header Address has not value
Row 2 Header Adults has not value
Row 2 Header Children has not value
Row 2 Header Check-in has not value
Row 2 Header Check-out has not value
Row 2 Header Notes has not value
Row 2 Header Price has not value
Row 2 Header Paid has not value
Row 2 Header Prepayment has not value
Row 2 Header Paid has not value
Row 2 Header Number of nights has not value
Row 3 Header Position has not value
Row 3 Header Arrival has not value
Row 3 Header Departure has not value
Row 3 Header Property has not value
Row 3 Header Guest has not value
Row 3 Header Portal has not value
Row 3 Header Created has not value
Row 3 Header Email has not value
Row 3 Header Phone has not value
Row 3 Header Address has not value
Row 3 Header Adults has not value
Row 3 Header Children has not value
Row 3 Header Check-in has not value
Row 3 Header Check-out has not value
Row 3 Header Notes has not value
Row 3 Header Price has not value
Row 3 Header Paid has not value
Row 3 Header Prepayment has not value
Row 3 Header Paid has not value
Row 3 Header Number of nights has not value
Row 4 Header Position has not value
Row 4 Header Arrival has not value
Row 4 Header Departure has not value
Row 4 Header Property has not value
Row 4 Header Guest has not value
Row 4 Header Portal has not value
Row 4 Header Created has not value
Row 4 Header Email has not value
Row 4 Header Phone has not value
Row 4 Header Address has not value
Row 4 Header Adults has not value
Row 4 Header Children has not value
Row 4 Header Check-in has not value
Row 4 Header Check-out has not value
Row 4 Header Notes has not value
Row 4 Header Price has not value
Row 4 Header Paid has not value
Row 4 Header Prepayment has not value
Row 4 Header Paid has not value
Row 4 Header Number of nights has not value
Row 5 Header Position has not value
Row 5 Header Arrival has not value
Row 5 Header Departure has not value
Row 5 Header Property has not value
Row 5 Header Guest has not value
Row 5 Header Portal has not value
Row 5 Header Created has not value
Row 5 Header Email has not value
Row 5 Header Phone has not value
Row 5 Header Address has not value
Row 5 Header Adults has not value
Row 5 Header Children has not value
Row 5 Header Check-in has not value
Row 5 Header Check-out has not value
Row 5 Header Notes has not value
Row 5 Header Price has not value
Row 5 Header Paid has not value
Row 5 Header Prepayment has not value
Row 5 Header Paid has not value
Row 5 Header Number of nights has not value