-
Notifications
You must be signed in to change notification settings - Fork 0
/
tasks.robot
113 lines (97 loc) · 4.04 KB
/
tasks.robot
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
*** Settings ***
Documentation Orders robots from RobotSpareBin Industries Inc.
... Saves the order HTML receipt as a PDF file.
... Saves the screenshot of the ordered robot.
... Embeds the screenshot of the robot to the PDF receipt.
... Creates ZIP archive of the receipts and the images.
Library RPA.Robocorp.Vault
Library RPA.Dialogs
Library RPA.HTTP
Library RPA.Tables
Library RPA.Browser.Selenium auto_close=${FALSE}
Library RPA.PDF
Library RPA.Archive
Library RPA.FileSystem
Task Setup Reset Temp Folder
Task Teardown Reset Temp Folder
*** Variables ***
&{ASSETS}
${TEMP_DIR}= temp
*** Tasks ***
Order robots from RobotSpareBin Industries Inc
${ASSETS}= Get Secret assets
Open the robot order website ${ASSETS}[target_url]
${orders}= Get orders ${ASSETS}[orderfile_url]
FOR ${order} IN @{orders}
Close the annoying modal
Fill the form ${order}
Wait Until Keyword Succeeds 30s 1s Preview the robot
Wait Until Keyword Succeeds 30s 1s Submit the order
${pdf}= Store the receipt as a PDF file ${order}[Order number]
${screenshot}= Take a screenshot of the robot ${order}[Order number]
Embed the robot screenshot to the receipt PDF file ${screenshot} ${pdf}
Go to order another robot
END
[Teardown] myTeardown
*** Keywords ***
Reset Temp Folder
${dir_exists}= Does Directory Exist ${TEMP_DIR}
IF ${dir_exists}
Remove Directory ${TEMP_DIR} recursive=True
END
Create Directory ${TEMP_DIR}
Open the robot order website
[Arguments] ${url}
Log ${url}
Open Available Browser ${url} maximized=true
Get orders
[Arguments] ${url}
Download ${url} ${TEMP_DIR}${/}orders.csv overwrite=True
${orders}= Read table from CSV ${TEMP_DIR}${/}orders.csv
Log Found columns: ${orders.columns}
[Return] ${orders}
Close the annoying modal
Click Button xpath://button[contains(.,'OK')]
Fill the form
[Arguments] ${row}
Wait Until Element Is Visible id:head
Select From List By Value id:head ${row}[Head]
Click Element xpath=//*[@id="id-body-${row}[Body]"]
Input Text xpath=//input[@placeholder="Enter the part number for the legs"] ${row}[Legs]
Input Text css:#address ${row}[Address]
Preview the robot
Click Element id:preview
Wait Until Element Is Visible id:preview 2s
Submit the order
Click Element id:order
Wait Until Element Is Visible id:order-completion 2s
Store the receipt as a PDF file
[Arguments] ${order_number}
${order_completion_html}= Get Element Attribute id:order-completion innerHTML
Html To Pdf ${order_completion_html} ${TEMP_DIR}${/}orders${/}order_${order_number}.pdf
Take a screenshot of the robot
[Arguments] ${order_number}
Screenshot id:robot-preview-image ${TEMP_DIR}${/}previews${/}robot_preview_${order_number}.png
Open Pdf ${TEMP_DIR}${/}orders${/}order_${order_number}.pdf
${files}= Create List ${TEMP_DIR}${/}previews${/}robot_preview_${order_number}.png
Add Files To Pdf ${files} ${TEMP_DIR}${/}orders${/}order_${order_number}.pdf append=True
Close Pdf
Embed the robot screenshot to the receipt PDF file
[Arguments] ${screenshot} ${pdf}
No Operation
Go to order another robot
Click Element id:order-another
Create a ZIP file of the receipts
Archive Folder With ZIP ${TEMP_DIR}${/}orders ${OUTPUT_DIR}${/}orders.zip recursive=False include=order*.pdf
Close the browser
Add icon Warning
Add heading Close the browser?
Add submit buttons buttons=No,Yes default=Yes
${result}= Run dialog
IF $result.submit == "Yes"
Close Browser
END
myTeardown
Create a ZIP file of the receipts
Close the browser
Reset Temp Folder