forked from brain-tec/odoo-robot-framework
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathodoo_8_0.robot
212 lines (169 loc) · 13.9 KB
/
odoo_8_0.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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
** Settings ***
Documentation Common keywords for OpenERP tests
... versions of the application. The correct SUT specific resource
... is imported based on ${SUT} variable. SeleniumLibrary is also
... imported here so that no other file needs to import it.
Library Selenium2Library
Library String
Variables config_80.py
*** Keywords ***
# checked: 8.0 ok
Login [Arguments] ${user}=${ODOO_USER} ${password}=${ODOO_PASSWORD} ${db}=${ODOO_DB}
Open Browser ${ODOO URL} browser=${BROWSER}
Maximize Browser Window
Go To ${ODOO URL}
Set Selenium Speed ${SELENIUM_DELAY}
Set Selenium Timeout ${SELENIUM_TIMEOUT}
Set Selenium Implicit Wait ${SELENIUM_TIMEOUT}
Run Keyword If '${db}' != 'None' Wait Until Page Contains Element xpath=//select[@id='db']
Run Keyword If '${db}' != 'None' Select From List By Value xpath=//select[@id='db'] ${db}
Wait Until Page Contains Element name=login
Input Text name=login ${user}
Input Password name=password ${password}
Click Button xpath=//div[contains(@class,'oe_login_buttons')]/button[@type='submit']
Wait Until Page Contains Element xpath=//div[@id='oe_main_menu_placeholder']/ul/li/a/span
# checked: 8.0 ok
MainMenu [Arguments] ${menu}
Click Link xpath=//div[@id='oe_main_menu_placeholder']/ul/li/a[@data-menu='${menu}']
Wait Until Page Contains Element xpath=//div[contains(@class, 'oe_secondary_menus_container')]/div[contains(@class, 'oe_secondary_menu') and not(contains(@style, 'display: none'))]
ElementPostCheck
# checked: 8.0 ok
SubMenu [Arguments] ${menu}
Click Link xpath=//td[contains(@class,'oe_leftbar')]//ul/li/a[@data-menu='${menu}']
Wait Until Page Contains Element xpath=//div[contains(@class,'oe_view_manager_body')]
# checked: 8.0 ok
ChangeView [Arguments] ${view}
Click Link xpath=//div[contains(@class,'openerp')][last()]//ul[contains(@class,'oe_view_manager_switch')]//a[contains(@data-view-type,'${view}')]
Wait Until Page Contains Element xpath=//div[contains(@class,'openerp')][last()]//div[contains(@class,'oe_view_manager_view_${view}') and not(contains(@style, 'display: none'))]
ElementPostCheck
# main window
# view-manager-main-content
# Checks that are done always before a element is executed
ElementPreCheck [Arguments] ${element}
Execute Javascript console.log("${element}");
# Element may be in a tab. So click the parent tab. If there is no parent tab, forget about the result
Execute Javascript var path="${element}".replace('xpath=','');var id=document.evaluate("("+path+")/ancestor::div[contains(@class,'oe_notebook_page')]/@id",document,null,XPathResult.STRING_TYPE,null).stringValue; if(id != ''){ window.location = "#"+id; $("a[href='#"+id+"']").click(); console.log("Clicked at #" + id); } return true;
ElementPostCheck
# Check that page is not blocked by RPC Call
Wait Until Page Contains Element xpath=//body[not(contains(@class, 'oe_wait'))]
# Wait Until Page Contains Element xpath=//div[contains(@class,'openerp_webclient_container') and not(contains(@class, 'oe_wait'))]
WriteInField [Arguments] ${model} ${fieldname} ${value}
ElementPreCheck xpath=//div[contains(@class,'openerp')][last()]//input[@data-bt-testing-model_name='${model}' and @data-bt-testing-name='${fieldname}']|textarea[@data-bt-testing-model_name='${model}' and @data-bt-testing-name='${fieldname}']
Input Text xpath=//div[contains(@class,'openerp')][last()]//input[@data-bt-testing-model_name='${model}' and @data-bt-testing-name='${fieldname}']|textarea[@data-bt-testing-model_name='${model}' and @data-bt-testing-name='${fieldname}'] ${value}
# checked: 8.0 ok
Button [Arguments] ${model} ${button_name}
Click Button xpath=//div[contains(@class,'openerp')][last()]//*[not(contains(@style,'display:none'))]//button[@data-bt-testing-name='${button_name}']
Wait For Condition return true; 20.0
ElementPostCheck
# checked: 8.0 ok
Many2OneSelect [Arguments] ${model} ${field} ${value}
ElementPreCheck xpath=//div[contains(@class,'openerp')][last()]//input[@data-bt-testing-model_name='${model}' and @data-bt-testing-name='${field}']
Input Text xpath=//div[contains(@class,'openerp')][last()]//input[@data-bt-testing-model_name='${model}' and @data-bt-testing-name='${field}'] ${value}
Click Link xpath=//ul[contains(@class,'ui-autocomplete') and not(contains(@style,'display: none'))]/li[1]/a
Textfield Should Contain xpath=//div[contains(@class,'openerp')][last()]//input[@data-bt-testing-model_name='${model}' and @data-bt-testing-name='${field}'] ${value}
ElementPostCheck
Date [Arguments] ${model} ${field} ${value}
ElementPreCheck xpath=//div[contains(@class,'openerp')][last()]//input[@data-bt-testing-model_name='${model}' and @data-bt-testing-name='${field}']
Input Text xpath=//div[contains(@class,'openerp')][last()]//input[@data-bt-testing-model_name='${model}' and @data-bt-testing-name='${field}'] ${value}
ElementPostCheck
Char [Arguments] ${model} ${field} ${value}
ElementPreCheck xpath=//div[contains(@class,'openerp')][last()]//input[@data-bt-testing-model_name='${model}' and @data-bt-testing-name='${field}']
Execute Javascript $("div.openerp:last input[data-bt-testing-model_name='${model}'][data-bt-testing-name='${field}']").val(''); return true;
Input Text xpath=//div[contains(@class,'openerp')][last()]//input[@data-bt-testing-model_name='${model}' and @data-bt-testing-name='${field}'] ${value}
ElementPostCheck
Float [Arguments] ${model} ${field} ${value}
ElementPreCheck xpath=//div[contains(@class,'openerp')][last()]//input[@data-bt-testing-model_name='${model}' and @data-bt-testing-name='${field}']
Input Text xpath=//div[contains(@class,'openerp')][last()]//input[@data-bt-testing-model_name='${model}' and @data-bt-testing-name='${field}'] ${value}
ElementPostCheck
Text [Arguments] ${model} ${field} ${value}
ElementPreCheck xpath=//div[contains(@class,'openerp')][last()]//textarea[@data-bt-testing-model_name='${model}' and @data-bt-testing-name='${field}']
Input Text xpath=//div[contains(@class,'openerp')][last()]//textarea[@data-bt-testing-model_name='${model}' and @data-bt-testing-name='${field}'] ${value}
ElementPostCheck
Select-Option [Arguments] ${model} ${field} ${value}
ElementPreCheck xpath=//div[contains(@class,'openerp')][last()]//select[@data-bt-testing-model_name='${model}' and @data-bt-testing-name='${field}']
Select From List By Label xpath=//div[contains(@class,'openerp')][last()]//select[@data-bt-testing-model_name='${model}' and @data-bt-testing-name='${field}'] ${value}
ElementPostCheck
Checkbox [Arguments] ${model} ${field}
ElementPreCheck xpath=//div[contains(@class,'openerp')][last()]//input[@type='checkbox' and @data-bt-testing-name='${field}']
Checkbox Should Not Be Selected xpath=//div[contains(@class,'openerp')][last()]//input[@type='checkbox' and @data-bt-testing-name='${field}']
Click Element xpath=//div[contains(@class,'openerp')][last()]//input[@type='checkbox' and @data-bt-testing-name='${field}']
ElementPostCheck
NotebookPage [Arguments] ${model}=None
Wait For Condition return true;
# checked: 8.0 ok
NewOne2Many [Arguments] ${model} ${field}
ElementPreCheck xpath=//div[contains(@class,'openerp')][last()]//div[contains(@class,'oe_form_field_one2many')]/div[@data-bt-testing-model_name='${model}' and @data-bt-testing-name='${field}']//tr/td[contains(@class,'oe_form_field_one2many_list_row_add')]/a
Click Link xpath=//div[contains(@class,'openerp')][last()]//div[contains(@class,'oe_form_field_one2many')]/div[@data-bt-testing-model_name='${model}' and @data-bt-testing-name='${field}']//tr/td[contains(@class,'oe_form_field_one2many_list_row_add')]/a
ElementPostCheck
One2ManySelectRecord [Arguments] ${model} ${field} ${submodel} @{fields}
ElementPreCheck xpath=//div[@data-bt-testing-model_name='${model}' and @data-bt-testing-name='${field}']
# Initialize variable
${pre_check_xpath}= Set Variable
${post_check_xpath}= Set Variable
${pre_click_xpath}= Set Variable
${post_click_xpath}= Set Variable
${pre_check_xpath}= Catenate (//div[@data-bt-testing-model_name='${model}' and @data-bt-testing-name='${field}']//table[contains(@class,'oe_list_content')]//tr[descendant::td[
${post_check_xpath}= Catenate ]])[1]
${pre_click_xpath}= Catenate (//div[@data-bt-testing-model_name='${model}' and @data-bt-testing-name='${field}']//table[contains(@class,'oe_list_content')]//tr[
${post_click_xpath}= Catenate ]/td)[1]
${xpath}= Set Variable
# Got throught all field=value and to select the correct record
: FOR ${field} IN @{fields}
# Split the string in fieldname=fieldvalue
\ ${fieldname} ${fieldvalue}= Split String ${field} separator== max_split=1
\ ${fieldxpath}= Catenate @data-bt-testing-model_name='${submodel}' and @data-field='${fieldname}'
# We first check if this field is in the view and visible
# otherwise a single field can break the whole command
\ ${checkxpath}= Catenate ${pre_check_xpath} ${fieldxpath} ${post_check_xpath}
\ Log To Console ${checkxpath}
\ ${status} ${value}= Run Keyword And Ignore Error Page Should Contain Element xpath=${checkxpath}
# In case the field is not there, log a error
\ Run Keyword Unless '${status}' == 'PASS' Log Field ${fieldname} not in the view or unvisible
# In case the field is there, add the path to the xpath
\ ${xpath}= Set Variable If '${status}' == 'PASS' ${xpath} and descendant::td[${fieldxpath} and string()='${fieldvalue}'] ${xpath}
# remove first " and " again (5 characters)
${xpath}= Get Substring ${xpath} 5
${xpath}= Catenate ${pre_click_xpath} ${xpath} ${post_click_xpath}
Click Element xpath=${xpath}
ElementPostCheck
SelectListView [Arguments] ${model} @{fields}
# Initialize variable
${xpath}= Set Variable
# Got throught all field=value and to select the correct record
: FOR ${field} IN @{fields}
# Split the string in fieldname=fieldvalue
\ ${fieldname} ${fieldvalue}= Split String ${field} separator== max_split=1
\ ${fieldxpath}= Catenate @data-bt-testing-model_name='${model}' and @data-field='${fieldname}'
# We first check if this field is in the view and visible
# otherwise a single field can break the whole command
\ ${checkxpath}= Catenate (//table[contains(@class,'oe_list_content')]//tr[descendant::td[${fieldxpath}]])[1]
\ ${status} ${value}= Run Keyword And Ignore Error Page Should Contain Element xpath=${checkxpath}
# In case the field is not there, log a error
\ Run Keyword Unless '${status}' == 'PASS' Log Field ${fieldname} not in the view or unvisible
# In case the field is there, add the path to the xpath
\ ${xpath}= Set Variable If '${status}' == 'PASS' ${xpath} and descendant::td[${fieldxpath} and string()='${fieldvalue}'] ${xpath}
# remove first " and " again (5 characters)
${xpath}= Get Substring ${xpath} 5
${xpath}= Catenate (//table[contains(@class,'oe_list_content')]//tr[${xpath}]/td)[1]
Click Element xpath=${xpath}
ElementPostCheck
SidebarAction [Arguments] ${type} ${id}
ClickElement xpath=//div[contains(@class,'oe_view_manager_sidebar')]/div[not(contains(@style,'display: none'))]//div[contains(@class,'oe_sidebar')]//div[contains(@class,'oe_form_dropdown_section') and descendant::a[@data-bt-type='${type}' and @data-bt-id='${id}']]/button[contains(@class,'oe_dropdown_toggle')]
ClickLink xpath=//div[contains(@class,'oe_view_manager_sidebar')]/div[not(contains(@style,'display: none'))]//div[contains(@class,'oe_sidebar')]//a[@data-bt-type='${type}' and @data-bt-id='${id}']
ElementPostCheck
MainWindowButton [Arguments] ${button_text}
Click Button xpath=//td[@class='oe_application']//div[contains(@class,'oe_view_manager_current')]//button[contains(text(), '${button_text}')]
ElementPostCheck
MainWindowNormalField [Arguments] ${field} ${value}
Input Text xpath=//td[contains(@class, 'view-manager-main-content')]//input[@name='${field}'] ${value}
ElementPostCheck
MainWindowSearchTextField [Arguments] ${field} ${value}
Input Text xpath=//div[@id='oe_app']//div[contains(@id, '_search')]//input[@name='${field}'] ${value}
ElementPostCheck
MainWindowSearchNow
MainWindowMany2One [Arguments] ${field} ${value}
Click Element xpath=//td[contains(@class, 'view-manager-main-content')]//input[@name='${field}'] don't wait
Input Text xpath=//td[contains(@class, 'view-manager-main-content')]//input[@name='${field}'] ${value}
Click Element xpath=//td[contains(@class, 'view-manager-main-content')]//input[@name='${field}']/following-sibling::span[contains(@class, 'oe-m2o-drop-down-button')]/img don't wait
Click Link xpath=//ul[contains(@class, 'ui-autocomplete') and not(contains(@style, 'display: none'))]//a[self::*/text()='${value}'] don't wait
ElementPostCheck