Here is my macro
{
"Name": "Virkespriser",
"CreationDate": "2022-8-30",
"Commands": [
{
"Command": "store",
"Target": "medium",
"Value": "!replayspeed",
"Description": ""
},
{
"Command": "store",
"Target": "true",
"Value": "!errorIgnore",
"Description": ""
},
{
"Command": "bringBrowserToForeground",
"Target": "",
"Value": "",
"Description": ""
},
{
"Command": "open",
"Target": "https://www.byggmax.se/45x95-kortregel-p08145096",
"Value": "",
"Description": ""
},
{
"Command": "store",
"Target": "30",
"Value": "!TIMEOUT_WAIT",
"Description": ""
},
{
"Command": "click",
"Target": "xpath=/html/body/div[4]/div/div/div/button",
"Value": "",
"Targets": [
"xpath=/html/body/div[4]/div/div/div/button",
"xpath=//div[4]/div/div/div/button",
"css=body > div.amgdprcookie-bar-template > div > div > div > button.amgdprcookie-button.-allow"
],
"Description": ""
},
{
"Command": "if_v2",
"Target": "${!STATUSOK}==true",
"Value": "",
"Description": ""
},
{
"Command": "echo",
"Target": "Byggmax - Butik ej vald, fortsätter.",
"Value": "green",
"Description": ""
},
{
"Command": "click",
"Target": "linkText=Välj din butik@POS=2",
"Value": "",
"Targets": [
"linkText=Välj din butik@POS=2",
"xpath=//*[@id=\"maincontent\"]/div/div/div[3]/div[2]/div/div[2]/div/a",
"xpath=//div[2]/div/div[2]/div/a",
"css=#maincontent > div > div > div.content-wrapper > div.product-info-actions-wrapper > div > div.add-to-button-message > div > a"
],
"Description": ""
},
{
"Command": "type",
"Target": "name=postal_code",
"Value": "85751",
"Targets": [
"name=postal_code",
"xpath=//*[@id=\"shop_selector\"]/input",
"xpath=//input[@name='postal_code']",
"xpath=//div[2]/form/input",
"css=#shop_selector > input:nth-child(1)"
],
"Description": ""
},
{
"Command": "click",
"Target": "xpath=//*[@id=\"shop_selector\"]/div/button",
"Value": "",
"Targets": [
"xpath=//*[@id=\"shop_selector\"]/div/button",
"xpath=//div[2]/div/div/div[2]/form/div/button",
"css=#shop_selector > div > button"
],
"Description": ""
},
{
"Command": "else",
"Target": "",
"Value": "",
"Description": ""
},
{
"Command": "echo",
"Target": "Byggmax - Butik redan vald, fortsätter.",
"Value": "green",
"Description": ""
},
{
"Command": "end",
"Target": "",
"Value": "",
"Description": ""
},
{
"Command": "storeText",
"Target": "xpath=//*[@id=\"product-price-74244\"]/span/span",
"Value": "Virkespriser95x45",
"Description": ""
},
{
"Command": "store",
"Target": "10",
"Value": "!TIMEOUT_WAIT",
"Description": ""
},
{
"Command": "open",
"Target": "https://www.byggmax.se/45x95-regel-c14-p08145095",
"Value": "",
"Description": ""
},
{
"Command": "storeText",
"Target": "xpath=//*[@id=\"product-price-74246\"]/span/span",
"Value": "Virkespriser_lang_95x45",
"Description": ""
},
{
"Command": "open",
"Target": "https://www.byggmax.se/friggebod-original-15m%C2%B2-sorselestugan-p7101345",
"Value": "",
"Description": ""
},
{
"Command": "storeText",
"Target": "xpath=//*[@id=\"product-price-190051\"]/span/span",
"Value": "Stuga_Sorselestugan_Orginal_15kvm",
"Description": ""
},
{
"Command": "open",
"Target": "https://www.byggmax.se/attefallshus-iris-199kvm-palmako-p7103740",
"Value": "",
"Description": ""
},
{
"Command": "storeText",
"Target": "xpath=//*[@id=\"product-price-193900\"]/span/span",
"Value": "Stuga_Palmako_Iris_19kvm",
"Description": ""
},
{
"Command": "open",
"Target": "https://www.byggmax.se/attefallshus-njuta-20-2-vibostugan-p7103526",
"Value": "",
"Description": ""
},
{
"Command": "storeText",
"Target": "xpath=//*[@id=\"product-price-149226\"]/span/span",
"Value": "Stuga_ViboStugan_Njuta_20kvm",
"Description": ""
},
{
"Command": "open",
"Target": "https://www.byggmax.se/attefallshus-njuta-25-2-vibostugan-p7103534",
"Value": "",
"Description": ""
},
{
"Command": "storeText",
"Target": "xpath=//*[@id=\"product-price-149242\"]/span/span",
"Value": "Stuga_ViboStugan_Njuta_25kvm",
"Description": ""
},
{
"Command": "open",
"Target": "https://www.beijerbygg.se/privat/sv/produkter/utemilj%C3%B6/stugor/attefallshus-friggebodar/stuga-kalix-25",
"Value": "",
"Description": ""
},
{
"Command": "store",
"Target": "5",
"Value": "!TIMEOUT_WAIT",
"Description": ""
},
{
"Command": "type",
"Target": "xpath=//*[@id=\"store-select-prompt\"]/div/div/form/div/input",
"Value": "85751",
"Targets": [
"xpath=//*[@id=\"store-select-prompt\"]/div/div/form/div/input",
"xpath=//form/div/input",
"css=#store-select-prompt > div > div > form > div > input"
],
"Description": ""
},
{
"Command": "if_v2",
"Target": "${!STATUSOK}==true",
"Value": "",
"Description": ""
},
{
"Command": "echo",
"Target": "Beijer - Butik ej vald, fortsätter.",
"Value": "green",
"Description": ""
},
{
"Command": "click",
"Target": "linkText=Privatkund",
"Value": "",
"Targets": [
"linkText=Privatkund",
"xpath=//*[@id=\"store-select-prompt\"]/div/div/div[2]/a",
"xpath=//div[2]/div/div/div/div[2]/a",
"css=#store-select-prompt > div > div > div.expanded.button-group.store-select-prompt__button-group > a.button.primary.no-margin.js-consumerCustomerTypeButton"
],
"Description": ""
},
{
"Command": "else",
"Target": "",
"Value": "",
"Description": ""
},
{
"Command": "echo",
"Target": "Beijer - Butik redan vald.",
"Value": "green",
"Description": ""
},
{
"Command": "end",
"Target": "",
"Value": "",
"Description": ""
},
{
"Command": "storeText",
"Target": "xpath=//*[@id=\"pageContent\"]/div/div[3]/section[2]/div/div/div[4]/div[2]/div/div/div/div",
"Value": "Stuga_ViboStugan_Kalix_25kvm",
"Description": ""
},
{
"Command": "store",
"Target": "10",
"Value": "!TIMEOUT_WAIT",
"Description": ""
},
{
"Command": "open",
"Target": "https://www.beijerbygg.se/privat/sv/produkter/tr%C3%A4produkter/plank-reglar/byggreglar-c24/byggregel-45x95mm-c24",
"Value": "",
"Description": ""
},
{
"Command": "storeText",
"Target": "xpath=//*[@id=\"pageContent\"]/div/div[3]/section[2]/div/div/div[5]/div[2]/div/div/div/div",
"Value": "Virkespriser95x45Beijer",
"Description": ""
},
{
"Command": "open",
"Target": "https://www.lundqvisttravaru.se/produkter/fritidshus/kusthuset/",
"Value": "",
"Description": ""
},
{
"Command": "storeText",
"Target": "xpath=//*[@id=\"main\"]/div/section/div/div[2]/div/div/div/h2/span",
"Value": "Lundqvist_kusthuset_vadersakrat",
"Description": ""
},
{
"Command": "storeText",
"Target": "xpath=//*[@id=\"main\"]/div/section/div/div[2]/div/div/div/div/div/div[2]/p/strong",
"Value": "Lundqvist_kusthuset_byggsats",
"Description": ""
},
{
"Command": "storeText",
"Target": "xpath=//*[@id=\"main\"]/div/section/div/div[2]/div/div/div/h2/span[3]",
"Value": "Lundqvist_kusthuset_farditOchIsolerat",
"Description": ""
},
{
"Command": "store",
"Target": "fast",
"Value": "!replayspeed",
"Description": ""
},
{
"Command": "open",
"Target": "http://192.168.1.4:1880/RPA/Virke?pris=${Lundqvist_kusthuset_vadersakrat}&topic=Price-Lundqvist-kusthuset-vädersäkrat",
"Value": "",
"Description": ""
},
{
"Command": "open",
"Target": "http://192.168.1.4:1880/RPA/Virke?pris=${Lundqvist_kusthuset_farditOchIsolerat}&topic=Price-Lundqvist-kusthuset-Färdigt-och-isolerat",
"Value": "",
"Description": ""
},
{
"Command": "open",
"Target": "http://192.168.1.4:1880/RPA/Virke?pris=${Lundqvist_kusthuset_byggsats}&topic=Price-Lundqvist-kusthuset-byggsats-skal",
"Value": "",
"Description": ""
},
{
"Command": "open",
"Target": "http://192.168.1.4:1880/RPA/Virke?pris=${Virkespriser95x45}&topic=Price-Virke-45x95",
"Value": "",
"Description": ""
},
{
"Command": "open",
"Target": "http://192.168.1.4:1880/RPA/Virke?pris=${Virkespriser95x45Beijer}&topic=Price-Virke-45x95-Beijer",
"Value": "",
"Description": ""
},
{
"Command": "open",
"Target": "http://192.168.1.4:1880/RPA/Virke?pris=${Virkespriser_lang_95x45}&topic=Price-Virke-Lang-45x95",
"Value": "",
"Description": ""
},
{
"Command": "open",
"Target": "http://192.168.1.4:1880/RPA/Virke?pris=${Stuga_Sorselestugan_Orginal_15kvm}&topic=Price-Stuga-Sorselestugan-Orginal-15kvm",
"Value": "",
"Description": ""
},
{
"Command": "open",
"Target": "http://192.168.1.4:1880/RPA/Virke?pris=${Stuga_Palmako_Iris_19kvm}&topic=Price-Stuga-Palmako-Iris-19kvm",
"Value": "",
"Description": ""
},
{
"Command": "open",
"Target": "http://192.168.1.4:1880/RPA/Virke?pris=${Stuga_ViboStugan_Njuta_20kvm}&topic=Price-Stuga-ViboStugan-Njuta-20kvm",
"Value": "",
"Description": ""
},
{
"Command": "open",
"Target": "http://192.168.1.4:1880/RPA/Virke?pris=${Stuga_ViboStugan_Njuta_25kvm}&topic=Price-Stuga-ViboStugan-Njuta-25kvm",
"Value": "",
"Description": ""
},
{
"Command": "open",
"Target": "http://192.168.1.4:1880/RPA/Virke?pris=${Stuga_ViboStugan_Kalix_25kvm}&topic=Price-Stuga-ViboStugan-Kalix-25kvm-Beijer",
"Value": "",
"Description": ""
},
{
"Command": "store",
"Target": "false",
"Value": "!errorIgnore",
"Description": ""
}
]
}
It will contain errors so it takes longer then the time out. Here are my powershell script that i use:
function WriteEventRPALog ($EventMessage, $Fas, $Macro, $Description){
#write-host "Fas: $Fas"
if ($Fas -eq 1){$Fas = 3001}
if ($Fas -eq 2){$Fas = 3002}
if ($Fas -eq 3){$Fas = 3003}
if ($Fas -eq 4){$Fas = 3004}
if ($Fas -eq 5){$Fas = 3005}
if ($Fas -eq 6){$Fas = 3006}
if ($Fas -eq 7){$Fas = 3007}
if ($Fas -eq 8){$Fas = 3008}
if ($Fas -eq 9){$Fas = 3009}
if ($global:RPAMacro -eq "Remedy") {$Kategori = 1}
if ($global:RPAMacro -eq "Smart-IT") {$Kategori = 2}
Write-EventLog -LogName "RPA-Logs" -Source "Robot" -EventID $Fas -EntryType Information -Message "$EventMessage # $global:RPAMacro # $Description" -Category $Kategori
}
function Test-Administrator
{
[OutputType([bool])]
param()
process {
[Security.Principal.WindowsPrincipal]$user = [Security.Principal.WindowsIdentity]::GetCurrent()
return $user.IsInRole([Security.Principal.WindowsBuiltinRole]::Administrator)
}
}
Function ReadLogFile ($LogFile){
$global:Fas1 = $null
$global:Fas2 = $null
$global:Fas3 = $null
$global:Fas4 = $null
$global:Fas5 = $null
$global:Fas6 = $null
$global:Fas7 = $null
$global:Fas8 = $null
$global:Fas9 = $null
$global:Fas1Desc = $null
$global:Fas2Desc = $null
$global:Fas3Desc = $null
$global:Fas4Desc = $null
$global:Fas5Desc = $null
$global:Fas6Desc = $null
$global:Fas7Desc = $null
$global:Fas8Desc = $null
$global:Fas9Desc = $null
$global:FasDone = $null
$INI = Get-Content $LogFile
#$INI
$IniTemp = @()
ForEach($Line in $INI)
{
If ($Line -ne "" -and $Line.StartsWith("[") -eq $True)
{
if ($Line.StartsWith("[echo]")) {
#write-host "Data: $Line"
$IniTemp += $Line
}
#if ($Line.StartsWith("[echo] INFO:")) {
# #write-host "Data: $Line"
# $IniTemp += $Line
#}
}
}
Write-Host
Write-Host('=============================================')
Write-Host
ForEach($Line in $IniTemp)
{
#Write-host $Line
if ($Line.StartsWith("[echo] INFO:")) {
$LineInfo = $Line.Replace("[echo] INFO: ", "")
Write-host "Info: $LineInfo"
if ($LineInfo.StartsWith("FAS1")) {$global:Fas1Desc = $LineInfo}
if ($LineInfo.StartsWith("FAS2")) {$global:Fas2Desc = $LineInfo}
if ($LineInfo.StartsWith("FAS3")) {$global:Fas3Desc = $LineInfo}
if ($LineInfo.StartsWith("FAS4")) {$global:Fas4Desc = $LineInfo}
if ($LineInfo.StartsWith("FAS5")) {$global:Fas5Desc = $LineInfo}
if ($LineInfo.StartsWith("FAS6")) {$global:Fas6Desc = $LineInfo}
if ($LineInfo.StartsWith("FAS7")) {$global:Fas7Desc = $LineInfo}
if ($LineInfo.StartsWith("FAS8")) {$global:Fas8Desc = $LineInfo}
if ($LineInfo.StartsWith("FAS9")) {$global:Fas9Desc = $LineInfo}
}
if ($Line.StartsWith("[echo] TIMER:")){
$Line = $Line.Replace("[echo] TIMER: ", "")
if ($Line.StartsWith("FAS1")) {$global:Fas1 = CleanString $Line}
if ($Line.StartsWith("FAS2")) {$global:Fas2 = CleanString $Line}
if ($Line.StartsWith("FAS3")) {$global:Fas3 = CleanString $Line}
if ($Line.StartsWith("FAS4")) {$global:Fas4 = CleanString $Line}
if ($Line.StartsWith("FAS5")) {$global:Fas5 = CleanString $Line}
if ($Line.StartsWith("FAS6")) {$global:Fas6 = CleanString $Line}
if ($Line.StartsWith("FAS7")) {$global:Fas7 = CleanString $Line}
if ($Line.StartsWith("FAS8")) {$global:Fas8 = CleanString $Line}
if ($Line.StartsWith("FAS9")) {$global:Fas9 = CleanString $Line}
if ($Line.StartsWith("Done")) {$global:FasDone = CleanString $Line}
$ReturnData = CleanString $Line
Write-host "CleanString har returnerat: $ReturnData"
}
}
Write-Host
Write-Host('===============================================')
Write-Host
if ($global:Fas1 -ne $null){
Write-host "Fas1 = $global:Fas1 sekunder"
WriteEventRPALog $global:Fas1 1 $global:RPAMacro $global:Fas1Desc #$EventMessage, $Fas, $Macro, $Description
}
if ($global:Fas2 -ne $null){
Write-host "Fas2 = $global:Fas2 sekunder"
WriteEventRPALog $global:Fas2 2 $global:RPAMacro $global:Fas2Desc #$EventMessage, $Fas, $Macro, $Description
}
if ($global:Fas3 -ne $null){
Write-host "Fas3 = $global:Fas3 sekunder"
WriteEventRPALog $global:Fas3 3 $global:RPAMacro $global:Fas3Desc #$EventMessage, $Fas, $Macro, $Description
}
if ($global:Fas4 -ne $null){
Write-host "Fas4 = $global:Fas4 sekunder"
WriteEventRPALog $global:Fas4 4 $global:RPAMacro $global:Fas4Desc #$EventMessage, $Fas, $Macro, $Description
}
if ($global:Fas5 -ne $null){
Write-host "Fas5 = $global:Fas5 sekunder"
WriteEventRPALog $global:Fas5 5 $global:RPAMacro $global:Fas5Desc #$EventMessage, $Fas, $Macro, $Description
}
if ($global:Fas6 -ne $null){
Write-host "Fas6 = $global:Fas6 sekunder"
WriteEventRPALog $global:Fas6 6 $global:RPAMacro $global:Fas6Desc #$EventMessage, $Fas, $Macro, $Description
}
if ($global:Fas7 -ne $null){
Write-host "Fas7 = $global:Fas7 sekunder"
WriteEventRPALog $global:Fas7 7 $global:RPAMacro $global:Fas7Desc #$EventMessage, $Fas, $Macro, $Description
}
if ($global:Fas8 -ne $null){
Write-host "Fas8 = $global:Fas8 sekunder"
WriteEventRPALog $global:Fas8 8 $global:RPAMacro $global:Fas8Desc #$EventMessage, $Fas, $Macro, $Description
}
if ($global:Fas9 -ne $null){
Write-host "Fas9 = $global:Fas9 sekunder"
WriteEventRPALog $global:Fas9 9 $global:RPAMacro $global:Fas9Desc #$EventMessage, $Fas, $Macro, $Description
}
Write-host "Klar efter = $global:FasDone sekunder"
}
function CleanString ($InString){
$MyData = $Line.SubString(0 ,($Line).IndexOf("-"))
$MyData = $Line.Replace($MyData, "")
#if ($Line.StartsWith("FAS")) {
$MyData = $MyData.Replace("-", "")
$MyData = $MyData.Replace(" ", "")
$MyData = $MyData.Replace("s", "")
#}
return $MyData
}
function ConvertCSVtoExcel ([string]$CSVFile, [string]$ExcelFile){
write-host "welcome to CSV to Excel converter"
#Define locations and delimiter
$csv = $CSVFile #Location of the source file
$xlsx = $ExcelFile #Desired location of output
$delimiter = "," #Specify the delimiter used in the file
write-host "Converting: $csv to save it as: $xlsx with delimiter: $delimiter"
# Create a new Excel workbook with one empty sheet
$excel = New-Object -ComObject excel.application
$workbook = $excel.Workbooks.Add(1)
$worksheet = $workbook.worksheets.Item(1)
# Build the QueryTables.Add command and reformat the data
$TxtConnector = ("TEXT;" + $csv)
$Connector = $worksheet.QueryTables.add($TxtConnector,$worksheet.Range("A1"))
$query = $worksheet.QueryTables.item($Connector.name)
$query.TextFileOtherDelimiter = $delimiter
$query.TextFileParseType = 1
$query.TextFileColumnDataTypes = ,1 * $worksheet.Cells.Columns.Count
$query.AdjustColumnWidth = 1
$query.TextFilePlatform = 65001 #Converts to readable ÅÄÖ (not utf8)
# Execute & delete the import query
$query.Refresh()
$query.Delete()
# Save & close the Workbook as XLSX.
$Workbook.SaveAs($xlsx,51)
$excel.Quit()
Write-host "CSV to Excel converter done"
}
function PlayAndWait ([string]$macro, [string]$arg1, [string]$arg2, [string]$arg3, $WaitTime){
$timeout_seconds = $WaitTime #max time in seconds allowed for macro to complete. Change this value if your macros takes longer to run.
$path_downloaddir = "C:\Skript\Run-UI.Vision-Macros\" #Where the script finds the kantu log files => *THIS MUST BE THE BROWSER DOWNLOAD FOLDER*, as specified in the browser settings
$path_autorun_html = "C:/Skript/Run-UI.Vision-Macros/ui.vision.html" #autorun page exported from API setttings page.
#Optional: Kill Chrome instances (if any open)
#taskkill /F /IM chrome.exe /T
#Create log file. Here the RPA software will store the result of the macro run
$log = "log_" + $(get-date -f MM-dd-yyyy_HH_mm_ss) + ".txt"
$path_log = $path_downloaddir + $log
#Build command line (1=CHROME, 2=FIREFOX, 3=EDGE)
$browser = 1
Switch ($browser) {
1 {$cmd = "${env:ProgramFiles}\Google\Chrome\Application\chrome.exe"; break}
2 {$cmd = "${env:ProgramFiles}\Mozilla Firefox\firefox.exe"; break} #For FIREFOX
3 {$cmd = "${env:ProgramFiles(x86)}\Microsoft\Edge\Application\msedge.exe"; break} #For EDGE
}
$arg = """file:///"+ $path_autorun_html + "?macro="+ $macro + "&direct=1&closeRPA=0&closeBrowser=0&savelog="+$log+""""
if ($arg1 -eq $null){$arg1 = ""}
if ($arg2 -eq $null){$arg2 = ""}
if ($arg3 -eq $null){$arg3 = ""}
$arg = $arg+"&cmd_var1="+$arg1+"&cmd_var2="+$arg2+"&cmd_var3="+$arg3
write-host $arg
#cmd_var1=helloworld&cmd_var2=helloworld2&cmd_var3=helloworld3&cmd_var4=helloworld4
Start-Process -FilePath $cmd -ArgumentList $arg #Launch the browser and run the macro
#############Wait for macro to complete => Wait for log file to appear in download folder
$status_runtime = 0
Write-Host "Log file will show up at " + $path_log
while (!(Test-Path $path_log) -and ($status_runtime -lt $timeout_seconds))
{
$CPULoad = Get-WmiObject Win32_Processor | Measure-Object -Property LoadPercentage -Average | Select Average
$CPULoad = $CPULoad.Average
Write-Host "Waiting for macro to finish, seconds=" $status_runtime "Cpu load avarage: $CPULoad %"
$status_runtime = $status_runtime + 1
}
#Macro done - or timeout exceeded:
if ($status_runtime -lt $timeout_seconds)
{
#Read FIRST line of log file, which contains the status of the last run
$status_text = Get-Content $path_log -First 1
#Check if macro completed OK or not
$status_int = -1
If ($status_text -contains "Status=OK") {$status_int = 1}
Write-host ""
write-host "$macro measurements of time spent:"
ReadLogFile $path_log
}
else
{
$status_text = "Macro did not complete within the time given:" + $timeout_seconds + " Killing the browser..."
Sleep 3
Taskkill /IM chrome.exe /F
Start-Process -FilePath "C:\Program Files\Google\Chrome\Application\chrome.exe" -ArgumentList "https://www.google.se"
#"C:\Program Files\Google\Chrome\Application\chrome.exe https://www.google.se"
$status_int = -2
}
remove-item $path_log #clean up - Denna rensar bort logilen efter körning.
Sleep 3
#Remove-Item -Path "C:\RPA\Download\*.*"
return $status_int, $status_text, $status_runtime
}
function RunRPA ([string]$macro, [string]$arg1, [string]$arg2, [string]$arg3, $WaitTime){
#Tar bort nerladdade filer.
#Remove-Item -Path "C:\RPA\Download\*.*" #Here is where the downloaded files from the browser is stored.
#Remove-item -Path "C:\Users\hyperv\Desktop\uivision\datasources\*.*" #Here is where the .csv files are saved in direct storage mode.
$global:RPAMacro = $macro
write-host "Running this RPA flow: $global:RPAMacro"
$admin = Test-Administrator
if ($admin) {
New-EventLog -source RPA -LogName RPA-Logs
[System.Diagnostics.EventLog]::CreateEventSource("Robot", "RPA-Logs")
} else {
write-host "Skriptet körs inte som admin, kan ej skapa eventlogg. Detta behövs bara göras engång på en ny maskin. Finns redan loggen behövs inget göras."
}
$MyDate = Get-Date -format "yyyy-MM-dd_HH.mm"
$MyFolder = $MyDate + "_" + $arg1
#New-Item "C:\RPA\Reports\$MyFolder" -ItemType directory
$result = PlayAndWait $macro """$arg1""" $arg2 $arg3 $WaitTime
$errortext = $result[1] #Get error text or OK
$runtime = $result[2] #Get runtime
$report = "Loop:" + $i + " Return code: " + $result[0]+ " Macro runtime: "+$runtime+" seconds, Result: "+ $errortext
$report = $(get-date -f yyyy-MM-dd_HH:mm:ss)+" Macro "+$Macro+" runtime: ("+$runtime+" seconds), result: "+$result[0]+" & "+ $errortext
Write-Host $report
Add-content $testreport -value ($report)
$CSVOrgFile = "C:\RPA\Download\$arg1.csv"
$CSVFile = "C:\RPA\Reports\$MyFolder\$arg1.csv"
$XlsxFile = "C:\RPA\Reports\$MyFolder\$arg1 - Summering.xlsx"
#Check if csv file exist, then convert it.
#if (Test-Path -Path $CSVOrgFile -PathType Leaf) {
# write-host "File: $CSVOrgFile exists, moveing on."
#If file exist, move it and convert it.
#Move files or they will be deleted.
#Move-Item "C:\RPA\Download\*" "C:\RPA\Reports\$MyFolder"
#ConvertCSVtoExcel $CSVFile $XlsxFile
#} else {
# If file dosent exist, wait and try to convert it.
# Write-host "Noting for me to do, not done? Will wait 20 sek and try again."
# Start-Sleep -Seconds 20
#Move files or they will be deleted.
#Move-Item "C:\RPA\Download\*" "C:\RPA\Reports\$MyFolder"
#ConvertCSVtoExcel $CSVFile $XlsxFile
#}
}
###########################################################################
# Settings
###########################################################################
$testreport = "c:\Skript\Run-UI.Vision-Macros\testreport_2.0.txt"
###########################################################################
# Main program starts here
###########################################################################
RunRPA Virkespriser "" "" "" 30
RunRPA Virkespriser "" "" "" 30
Sleep 5
Taskkill /IM chrome.exe /F