Skip to content

Commit 60f3167

Browse files
authored
Merge pull request #214 from plone/playwright-based-robot-test
Playwright based robot test
2 parents 51793c9 + dc7dc60 commit 60f3167

File tree

5 files changed

+98
-96
lines changed

5 files changed

+98
-96
lines changed

news/3813.feature

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Update robot framework tests to use
2+
`robotframework-browser` (`playwright` integration on robotframework).
3+
[gforcada]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
*** Keywords ***
2+
3+
I enable discussion on the document
4+
Go To ${PLONE_URL}/my-document/edit
5+
Get Text body contains Settings
6+
Click .autotoc-nav >> "Settings"
7+
Select Options By id=formfield-form-widgets-IAllowDiscussion-allow_discussion >> select text Yes
8+
Click "Save"
9+
10+
I add a comment
11+
Type Text id=form-widgets-comment-text This is a comment
12+
Click css=button[name="form.buttons.comment"]
13+
14+
I can see that the comment is gone
15+
Go To ${PLONE_URL}/my-document/view
16+
Get Element Count css=.comment-body == 0
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,77 @@
1-
*** Settings *****************************************************************
1+
*** Settings ***
22

3-
Resource plone/app/robotframework/keywords.robot
4-
Resource plone/app/robotframework/saucelabs.robot
5-
Resource plone/app/robotframework/selenium.robot
3+
Resource plone/app/robotframework/browser.robot
4+
Resource keywords.robot
65

76
Library Remote ${PLONE_URL}/RobotRemote
87

9-
Test Setup Run keywords Plone Test Setup
10-
Test Teardown Run keywords Plone Test Teardown
8+
Test Setup Run Keywords Plone test setup
9+
Test Teardown Run keywords Plone test teardown
1110

12-
13-
*** Test Cases ***************************************************************
11+
*** Test Cases ***
1412

1513
Scenario: Allow comments for Link Type
1614
Given a logged-in manager
1715
and Globally enabled comments
1816
and the types control panel
1917
When I select 'Link' in types dropdown
2018
and Allow discussion
21-
Then Wait until page contains Content Settings
19+
Then Wait For Condition Text //body contains Content Settings
20+
2221
When I add new Link 'my_link'
23-
Then Link 'my_link' should have comments enabled
22+
Then Link 'my_link' should have comments enabled
2423

2524

26-
*** Keywords *****************************************************************
25+
*** Keywords ***
2726

28-
# --- GIVEN ------------------------------------------------------------------
27+
# GIVEN
2928

3029
a logged-in manager
31-
Enable autologin as Manager
30+
Enable autologin as Manager
3231

3332
the types control panel
34-
Go to ${PLONE_URL}/@@content-controlpanel
35-
Wait until page contains Content Settings
33+
Go to ${PLONE_URL}/@@content-controlpanel
34+
Wait For Condition Text //body contains Content Settings
3635

3736
Globally enabled comments
38-
Go to ${PLONE_URL}/@@discussion-settings
39-
Wait until page contains Discussion settings
40-
Select checkbox name=form.widgets.globally_enabled:list
41-
Click button Save
42-
37+
Go to ${PLONE_URL}/@@discussion-settings
38+
Wait For Condition Text //body contains Discussion settings
39+
Check Checkbox //input[@name="form.widgets.globally_enabled:list"]
40+
Click //button[@name="form.buttons.save"]
4341

4442

45-
# --- WHEN -------------------------------------------------------------------
43+
# WHEN
4644

4745
I select '${content_type}' in types dropdown
48-
Select from list by label name=type_id ${content_type}
49-
Wait until page contains Globally addable
46+
Select Options By //select[@name="type_id"] label ${content_type}
47+
Wait For Condition Text //body contains Globally addable
5048

5149
Allow discussion
52-
Select checkbox name=allow_discussion:boolean
53-
Click Button Save
50+
Check Checkbox //input[@name="allow_discussion:boolean"]
51+
Click //button[@name="form.button.Save"]
5452

5553
I add new Link '${id}'
56-
Go to ${PLONE_URL}
57-
Wait until page contains Plone site
58-
Create content type=Link id=${id} title=${id} remoteUrl=http://www.starzel.de
54+
Go to ${PLONE_URL}
55+
Wait For Condition Text //body contains Plone site
56+
Create content
57+
... type=Link
58+
... id=${id}
59+
... title=${id}
60+
... remoteUrl=http://www.starzel.de
5961

6062

61-
# --- THEN -------------------------------------------------------------------
63+
# THEN
6264

6365
Link '${id}' should have comments enabled
64-
Go to ${PLONE_URL}/${id}
65-
Wait until page contains ${id}
66-
Page should contain element xpath=//div[@id="commenting"]
66+
Go to ${PLONE_URL}/${id}
67+
Wait For Condition Text //body contains ${id}
68+
Get Element Count //div[@id="commenting"] should be 1
69+
70+
# Misc
71+
72+
Pause
73+
[Documentation] Visually pause test execution with interactive dialog by
74+
... importing **Dialogs**-library and calling its
75+
... **Pause Execution**-keyword.
76+
Import library Dialogs
77+
Pause execution
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,13 @@
1-
# ============================================================================
2-
# Test basic discussion features (adding, replying, deleting)
3-
# ============================================================================
4-
#
5-
# $ bin/robot-server plone.app.discussion.testing.PLONE_APP_DISCUSSION_ROBOT_TESTING
6-
# $ bin/robot src/plone.app.discussion/src/plone/app/discussion/tests/robot/test_discussion.robot
7-
#
8-
# ============================================================================
9-
101
*** Settings ***
112

12-
Resource plone/app/robotframework/saucelabs.robot
13-
Resource plone/app/robotframework/selenium.robot
3+
Resource plone/app/robotframework/browser.robot
4+
Resource keywords.robot
145

156
Library Remote ${PLONE_URL}/RobotRemote
167

178
Test Setup Run Keywords Plone test setup
189
Test Teardown Run keywords Plone test teardown
1910

20-
2111
*** Test Cases ***
2212

2313
Enable Discussion on a Document
@@ -35,11 +25,16 @@ Add Comment to a Document
3525
Reply to a comment on a Document
3626
Given a logged-in Site Administrator
3727
and a document with discussion enabled
28+
and I add a comment
29+
When I reply to a comment
30+
Then I can see the reply
3831

3932
Delete Comment from a Document
4033
Given a logged-in Site Administrator
4134
and a document with discussion enabled
42-
35+
and I add a comment
36+
When I delete the comment
37+
Then I can see that the comment is gone
4338

4439
*** Keywords ***
4540

@@ -58,28 +53,26 @@ a document with discussion enabled
5853

5954
# When
6055

61-
I enable discussion on the document
62-
Go To ${PLONE_URL}/my-document/edit
63-
Wait until page contains Settings
64-
Click Link Settings
65-
Wait until element is visible name=form.widgets.IAllowDiscussion.allow_discussion:list
66-
Select From List By Value name=form.widgets.IAllowDiscussion.allow_discussion:list True
67-
Click Button Save
68-
69-
I add a comment
70-
Wait until page contains element id=form-widgets-comment-text
71-
Input Text id=form-widgets-comment-text This is a comment
72-
Click Button Comment
56+
I reply to a comment
57+
Click "Reply"
58+
Fill Text css=div[id^=formfield-form-widgets-new] > textarea My reply text
59+
Click css=.discussion button[name="form.buttons.comment"]
7360

61+
I delete the comment
62+
Click css=button[name="form.button.DeleteComment"]
7463

7564
# Then
7665

7766
I can see a comment form on the document
7867
Go To ${PLONE_URL}/my-document/view
79-
Wait until page contains My Document
80-
Page should contain Add comment
81-
Page should contain element id=form-widgets-comment-text
68+
Get Text h1 == My Document
69+
Get Text legend == Add comment
70+
Get Element id=form-widgets-comment-text
8271

8372
I can see the comment below the document
8473
Go To ${PLONE_URL}/my-document/view
85-
Page should contain This is a comment
74+
Get Text css=.comment-body > p == This is a comment
75+
76+
I can see the reply
77+
Go To ${PLONE_URL}/my-document/view
78+
Get Text css=.level-1 .comment-body > p == My reply text
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
*** Settings ***
22

3-
Resource plone/app/robotframework/saucelabs.robot
4-
Resource plone/app/robotframework/selenium.robot
3+
Resource plone/app/robotframework/browser.robot
4+
Resource keywords.robot
55

66
Library Remote ${PLONE_URL}/RobotRemote
77

@@ -16,7 +16,7 @@ Add a Comment to a Document and bulk delete it
1616
and workflow multiple enabled
1717
and a document with discussion enabled
1818
When I add a comment and delete it
19-
Then I can not see the comment below the document
19+
Then I can see that the comment is gone
2020

2121
Last history entry is shown
2222
Given a logged-in Site Administrator
@@ -49,49 +49,28 @@ a document with discussion enabled
4949

5050
# When
5151

52-
I enable discussion on the document
53-
Go To ${PLONE_URL}/my-document/edit
54-
Wait until page contains Settings
55-
Click Link Settings
56-
Wait until element is visible name=form.widgets.IAllowDiscussion.allow_discussion:list
57-
Select From List By Value name=form.widgets.IAllowDiscussion.allow_discussion:list True
58-
Click Button Save
59-
60-
I add a comment
61-
Wait until page contains element id=form-widgets-comment-text
62-
Input Text id=form-widgets-comment-text This is a comment
63-
Click Button Comment
64-
6552
I add a comment and delete it
66-
Wait until page contains element id=form-widgets-comment-text
67-
Input Text id=form-widgets-comment-text This is a comment
68-
Click Button Comment
53+
Fill Text id=form-widgets-comment-text This is a comment
54+
Click css=button[name="form.buttons.comment"]
6955
Go To ${PLONE_URL}/@@moderate-comments?review_state=all
70-
Wait Until Element Is Visible css=option[value=delete]
71-
Wait Until Keyword Succeeds 5x 1s Select And Check xpath://select[@name='form.select.BulkAction'] delete
72-
Wait Until Element Is Visible css=[name=check_all]
73-
Wait Until Element Is Enabled css=[name=check_all]
74-
Wait Until Element Is Visible css=[name="paths:list"]
75-
Wait Until Element Is Enabled css=[name="paths:list"]
76-
Wait for Condition return jQuery._data( jQuery('[name=check_all]')[0], "events" )?.click?.length == 2
77-
Select Checkbox name=check_all
78-
Wait Until Element Is Visible css=[name="paths:list"]:checked
79-
Wait For Then Click Element css=button[name="form.button.BulkAction"]
80-
Wait Until Page Does Not Contain This is a comment
56+
Get Text body contains Bulk Actions
57+
Select Options By select[name="form.select.BulkAction"] text Delete
58+
Check Checkbox input[name="check_all"]
59+
Click "Apply"
60+
Get Element Count table > tbody > tr == 0.0
8161

8262
workflow multiple enabled
8363
Go To ${PLONE_URL}/@@content-controlpanel?type_id=Discussion%20Item&new_workflow=comment_review_workflow
84-
Execute Javascript window.scroll(0, 2000)
85-
Click Button Save
64+
Click "Save"
8665

8766
# Then
8867

8968
I can not see the comment below the document
9069
Go To ${PLONE_URL}/my-document/view
91-
Wait until page contains My Document
70+
Get Text body contains My Document
9271
Page should not contain This is a comment
9372

9473
I can see the last history entry in moderation view
9574
Go To ${PLONE_URL}/@@moderate-comments?review_state=all
96-
Wait until page contains element name=form.select.BulkAction
97-
Page should contain Create
75+
Get Text body contains Bulk Actions
76+
Get Text table contains Create

0 commit comments

Comments
 (0)