-
Notifications
You must be signed in to change notification settings - Fork 0
/
tasks.robot
167 lines (122 loc) · 5.21 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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
# +
*** 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.
... Author --- Abhilash ---
#imported Libraries
Library RPA.Browser.Selenium
Library RPA.HTTP
Library RPA.Tables
Library RPA.Robocorp.Vault
Library OperatingSystem
Library RPA.PDF
Library RPA.Archive
Library RPA.Dialogs
# +
*** Variables ***
${VAULT_SECRET_KEY} urls
${ORDER_URL_TYPE} orderUrl
${ORDER_DATA_URL_TYPE} orderDataUrl
${IMAGE_SCREENSHOTS_DIR} ${CURDIR}${/}output${/}screenshots
${RECEIPTS_PDF_DIR} ${CURDIR}${/}output${/}receipts
# +
*** Keywords ***
Greet the User
Add heading Please enter your Name
Add text input userName
${dialogueData} = Run dialog
Log Welcome ${dialogueData.userName} to Order Process Management in RobotSpareBin console=true
Get Url From Vault
[Arguments] ${urlType}
${secretUrls}= Get Secret ${VAULT_SECRET_KEY}
[return] ${secretUrls}[${urlType}]
Open the robot order website
${orderUrl}= Get Url From Vault ${ORDER_URL_TYPE}
Open Available Browser ${orderUrl}
Close the annoying modal
Wait Until Page Contains Element class:modal-dialog
Click Button I guess so...
Download the CSV file
${orderDataUrl}= Get Url From Vault ${ORDER_DATA_URL_TYPE}
Download ${orderDataUrl} overwrite=True
Read orders csv file into Orders variable
${orders}=
... Read Table From Csv
... orders.csv
... header=True
Log ${orders}
[return] ${orders}
Submit the Robot Order Form And Open the Recipet Page
Click Element id:order
Wait Until Page Contains Element id:receipt
Create screenshot and pdf output Directories
Create Directory ${IMAGE_SCREENSHOTS_DIR}
Empty Directory ${IMAGE_SCREENSHOTS_DIR}
Create Directory ${RECEIPTS_PDF_DIR}
Empty Directory ${RECEIPTS_PDF_DIR}
Save a screenshot of each of the ordered robot
[Arguments] ${id}
Sleep 1s
Wait Until Page Contains Element id:robot-preview-image timeout=25
Screenshot id:robot-preview-image ${IMAGE_SCREENSHOTS_DIR}${/}${id}.png
[return] ${IMAGE_SCREENSHOTS_DIR}${/}${id}.png
Save each order HTML receipt as a PDF file
[Arguments] ${id}
${receiptHTMLData} = Get Element Attribute id:receipt outerHTML
Html To Pdf ${receiptHTMLData} ${RECEIPTS_PDF_DIR}${/}${id}.pdf
[Return] ${RECEIPTS_PDF_DIR}${/}${id}.pdf
Embed the screenshot of the robot to the PDF receipt
[Arguments] ${img} ${pdf}
Open Pdf ${pdf}
${listImg} = Create List ${img}
Add Files To Pdf ${listImg} ${pdf} append=True
Close Pdf
Fill and submit the robot order form for single robot
[Arguments] ${data}
Select From List By Value head ${data}[Head]
Click Element //input[@name="body"][@value=${data}[Body]]
Input Text //input[@placeholder="Enter the part number for the legs"] ${data}[Legs]
Input Text address ${data}[Address]
# Preview the robot
Click Button id:preview
#this form submission fails in site with error some times so need to try again in case
Wait Until Keyword Succeeds 10x 1s Submit the Robot Order Form And Open the Recipet Page
${screenshotTaken} = Save a screenshot of each of the ordered robot ${data}[Order number]
${pdfFile} = Save each order HTML receipt as a PDF file ${data}[Order number]
Embed the screenshot of the robot to the PDF receipt ${screenshotTaken} ${pdfFile}
# Go to order another robot
Click Button id:order-another
Get the data for placing the order
Download the CSV file
Create Consolidated Reciepts in Zip format
Archive Folder With Zip ${CURDIR}${/}output${/}receipts ${CURDIR}${/}output${/}consolidatedReciepts.zip
Inform User about Order Completion
Add icon Success
Add heading Your all robot orders have been processed and the zip file is generated in output directory!!!
Run dialog title=Success
Place the robot order one by one from the order data Obtained
${allOrders}= Read orders csv file into Orders variable
Open the robot order website
FOR ${order} IN @{allOrders}
#the annoying modal comes in each iteration
Close the annoying modal
Fill and submit the robot order form for single robot ${order}
END
# -
*** Tasks ***
Order the robots one by one from RobotSpareBin Industries Inc
Greet the User
#step 1
Get the data for placing the order
#step 2
Create screenshot and pdf output Directories
#step 3
Place the robot order one by one from the order data Obtained
#step 4
Create Consolidated Reciepts in Zip format
Inform User about Order Completion
[Teardown] Close All Browsers
Log Your Ordering is Completed.