Skip to content

Commit e94fa77

Browse files
authored
Revise example structure (#49)
* init login form * Init form submit demo * Init register form example * add register and example * Add example login * Add browser management demo * Add second test case * Update example for form submitand add debug mode * Add example for element properties * Fix debug mode * Clean up demo scripts * Add form handler * Update example and remove unused demo form * Add pre load puppeteer * update install browser command * Fix headless variable
1 parent 2cbc5ae commit e94fa77

34 files changed

+725
-530
lines changed

.github/workflows/pythonpackage.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ jobs:
3131
- name: System test
3232
run: |
3333
python setup.py install
34+
pyppeteer-install
3435
pip install -r demoapp/requirements.txt
3536
python demoapp/server.py &
3637
robot -v HEADLESS:True -e Ignore Examples
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
11
*** Settings ***
22
Library PuppeteerLibrary
33
Test Setup Open browser to test page
4-
Test Teardown Close Browser
5-
4+
Test Teardown Close All Browser
5+
Suite Teardown Close Puppeteer
66

77
*** Variables ***
8-
${HOME_PAGE_URL} http://127.0.0.1:7272
9-
8+
${HOME_PAGE_URL} http://127.0.0.1:7272/basic-html-elements.html
109

1110
*** Test Cases ***
12-
Accept Handle alert
11+
Accept alert
1312
Run Async Keywords
1413
... Handle Alert ACCEPT AND
1514
... Click Button id=alert_confirm
1615
Click Element id:get_ajax
1716

18-
Dismiss Hadle alert
17+
Dismiss alert
1918
Run Async Keywords
2019
... Handle Alert DISMISS AND
2120
... Click Button id=alert_confirm
2221
Click Element id:get_ajax
23-
22+
2423
*** Keywords ***
2524
Open browser to test page
2625
${HEADLESS} Get variable value ${HEADLESS} ${False}
2726
&{options} = create dictionary headless=${HEADLESS}
2827
Open browser ${HOME_PAGE_URL} options=${options}
28+

Examples/request-api-demo.robot renamed to Examples/api/mock-api.robot

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,26 @@
11
*** Settings ***
2-
Library Dialogs
32
Library PuppeteerLibrary
4-
Test Setup Open browser to test page
5-
Test Teardown Close Browser
6-
3+
Test Setup Open browser to test page
4+
Test Teardown Close All Browser
5+
Suite Teardown Close Puppeteer
76

87
*** Variables ***
9-
${HOME_PAGE_URL} http://127.0.0.1:7272
8+
${HOME_PAGE_URL} http://127.0.0.1:7272/basic-html-elements.html
109

1110

1211
*** Test Cases ***
13-
Mock response for api request
14-
&{response} Create Dictionary body=I'm a mock response
12+
Mock ajax response with raw text
13+
&{response} Create Dictionary body=I'm a mock response text
1514
Mock Current Page Api Response /ajax_info.json\\?count=3 ${response}
1615
Click Element id=get_ajax
17-
Wait Until Page Contains I'm a mock response
16+
Wait Until Page Contains I'm a mock response text
1817

19-
Mock response with json response
20-
&{response} Create Dictionary body={ 'data': 'I\'m a mock response'} contentType=application/json
18+
Mock ajax response with json response
19+
&{response} Create Dictionary body={ 'data': 'I\'m a mock response json'} contentType=application/json
2120
Mock Current Page Api Response /ajax_info.json\\?count=3 ${response}
2221
Click Element id=get_ajax
23-
Wait Until Page Contains I'm a mock response
24-
22+
Wait Until Page Contains I'm a mock response json
23+
2524
*** Keywords ***
2625
Open browser to test page
2726
${HEADLESS} Get variable value ${HEADLESS} ${False}

Examples/browser-demo.robot

Lines changed: 0 additions & 49 deletions
This file was deleted.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
*** Settings ***
2+
Library PuppeteerLibrary
3+
Suite Teardown Close Puppeteer
4+
5+
*** Test Cases ***
6+
Example enable emulator mode
7+
[Teardown] Close All Browser
8+
${HEADLESS} Get variable value ${HEADLESS} ${False}
9+
&{options} = create dictionary headless=${HEADLESS}
10+
Open browser http://127.0.0.1:7272/basic-html-elements.html options=${options} alias=Browser 1
11+
Enable emulate mode iPhone SE
12+
Capture page screenshot
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
*** Settings ***
2+
Library PuppeteerLibrary
3+
Suite Teardown Close Puppeteer
4+
Test Teardown Close All Browser
5+
6+
*** Test Cases ***
7+
Switch to new browser
8+
${HEADLESS} Get variable value ${HEADLESS} ${False}
9+
&{options} = create dictionary headless=${HEADLESS}
10+
Open browser http://127.0.0.1:7272/basic-html-elements.html options=${options}
11+
Run Async Keywords
12+
... Wait For New Window Open AND
13+
... Click Element id=open-new-tab
14+
Switch Window NEW
15+
Wait Until Page Contains Element id=exampleInputEmail1
16+
Switch Window title=Basic HTML Elements
17+
Wait Until Page Contains Element id=open-new-tab
18+
19+
Handle multiple browser
20+
${HEADLESS} Get variable value ${HEADLESS} ${False}
21+
&{options} = create dictionary headless=${HEADLESS}
22+
Open browser http://127.0.0.1:7272/basic-html-elements.html options=${options} alias=Browser 1
23+
Run Async Keywords
24+
... Wait For New Window Open AND
25+
... Click Element id=open-new-tab
26+
Switch Window NEW
27+
Open browser http://127.0.0.1:7272/basic-html-elements.html options=${options} alias=Browser 2
28+
Switch Browser Browser 1
29+
Wait Until Page Contains Login form
30+
Switch Browser Browser 2
31+
Wait Until Page Contains Browser Management
32+
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
*** Settings ***
2+
Library PuppeteerLibrary
3+
Test Teardown Close All Browser
4+
Suite Teardown Close Puppeteer
5+
6+
7+
*** Test Cases ***
8+
Enable debug mode
9+
Open browser to test page http://127.0.0.1:7272/login-form-example.html
10+
Input Text id=exampleInputEmail1 demo@qahive.com
11+
Input Text id=exampleInputPassword1 123456789
12+
13+
*** Keywords ***
14+
Open browser to test page
15+
[Arguments] ${url}
16+
${HEADLESS} Get variable value ${HEADLESS} ${False}
17+
Run Keyword If ${HEADLESS} == ${False} Enable Debug Mode
18+
&{options} = create dictionary headless=${HEADLESS}
19+
Open browser ${url} options=${options}

Examples/element-properties-demo.robot

Lines changed: 0 additions & 46 deletions
This file was deleted.

Examples/file-upload.robot

Lines changed: 0 additions & 20 deletions
This file was deleted.
Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
*** Settings ***
2-
Library Dialogs
32
Library PuppeteerLibrary
4-
Test Setup Open browser to test page
5-
Test Teardown Close Browser
6-
3+
Test Setup Open browser to test page
4+
Test Teardown Close All Browser
5+
Suite Teardown Close Puppeteer
76

87
*** Variables ***
9-
${HOME_PAGE_URL} http://127.0.0.1:7272/form.html
8+
${HOME_PAGE_URL} http://127.0.0.1:7272/basic-html-elements.html
109

1110

1211
*** Test Cases ***
@@ -20,11 +19,10 @@ Select dropdown list by labels with id
2019
Select From List By Label id=cars Audi
2120

2221
Select dropdown list by labels with xpath
23-
Select From List By Label xpath=//select[@id="cars"] Audi
22+
Select From List By Label xpath=//select[@id="cars"] Audi
2423

2524
*** Keywords ***
2625
Open browser to test page
2726
${HEADLESS} Get variable value ${HEADLESS} ${False}
2827
&{options} = create dictionary headless=${HEADLESS}
2928
Open browser ${HOME_PAGE_URL} options=${options}
30-
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
*** Settings ***
2+
Library PuppeteerLibrary
3+
Test Setup Open browser to test page
4+
Test Teardown Close All Browser
5+
Suite Teardown Close Puppeteer
6+
7+
*** Variables ***
8+
${HOME_PAGE_URL} http://127.0.0.1:7272/basic-html-elements.html
9+
10+
11+
*** Test Cases ***
12+
Element proprty is enable
13+
Element Should Be Enabled id:prop-enable
14+
15+
Element property is disable
16+
Element Should Be Disabled id:prop-disable
17+
Run Keyword And Expect Error REGEXP:Element 'id:prop-enable' is enabled Element Should Be Disabled id:prop-enable
18+
19+
Element is visible and not visible
20+
Element Should Be Visible id:prop-visible
21+
Element Should Not Be Visible id:prop-hide
22+
Run Keyword And Expect Error REGEXP:Element 'id:prop-hide' is not be visible Element Should Be Visible id:prop-hide
23+
24+
Element should containt text
25+
Element Should Contain id=prop-text Please ${True}
26+
27+
Element should not contain text
28+
Element Should Not Contain id=prop-text Please input2 ${True}
29+
30+
Element text should be
31+
Element Text Should Be id=prop-text Please input ${True}
32+
33+
Element text should not be
34+
Element Text Should Not Be id=prop-text Please ${True}
35+
36+
*** Keywords ***
37+
Open browser to test page
38+
${HEADLESS} Get variable value ${HEADLESS} ${False}
39+
&{options} = create dictionary headless=${HEADLESS}
40+
Open browser ${HOME_PAGE_URL} options=${options}
Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
11
*** Settings ***
22
Library PuppeteerLibrary
3-
Test Setup Open browser to test page
4-
Test Teardown Close Browser
3+
Test Setup Open browser to test page
4+
Test Teardown Close All Browser
5+
Suite Teardown Close Puppeteer
56

67

78
*** Variables ***
8-
${HOME_PAGE_URL} http://127.0.0.1:7272
9+
${HOME_PAGE_URL} http://127.0.0.1:7272/basic-html-elements.html
910

1011

1112
*** Test Cases ***
12-
Generate pdf file
13-
[Documentation] Only support on headless mode
14-
Print as pdf
15-
13+
Upload file
14+
Upload file id=fileToUpload ${CURDIR}/file-upload.robot
15+
1616
*** Keywords ***
1717
Open browser to test page
1818
${HEADLESS} Get variable value ${HEADLESS} ${False}
1919
&{options} = create dictionary headless=${HEADLESS}
2020
Open browser ${HOME_PAGE_URL} options=${options}
21-

0 commit comments

Comments
 (0)