Skip to content

Commit 9466d79

Browse files
authored
Add support selenium element keywords (#60)
* Add 'Press Keys' keyword * Add keyword 'get_element_count' * Add keyword 'Get Element Attribute' * Add keyword 'Get Selected List Label' * Add keyword 'Get Selected List Value' * Add webkit keyword 'Click Element At Coordinate' * Add keywords 'Checkbox' * Add keywors 'Delete All Cookies' * Add keyword 'Close Window' for puppeteer * Add keyword 'Close Window' for playwright * Add keyword 'Get Window Count' * Update default browser * Add keyword 'Scroll Element Into View' * Add keywords 'Set Screenshot Directory'
1 parent 7339d6f commit 9466d79

34 files changed

+587
-42
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,4 @@ log.html
2222
report.html
2323
/Examples/*.png
2424
*.pdf
25+
Examples/logs/
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
*** Settings ***
2+
Library PuppeteerLibrary
3+
Suite Teardown Close Puppeteer
4+
Test Teardown Close All Browser
5+
6+
*** Variables ***
7+
${DEFAULT_BROWSER} chrome
8+
9+
10+
*** Test Cases ***
11+
Delete all cookies
12+
${BROWSER} = Get variable value ${BROWSER} ${DEFAULT_BROWSER}
13+
${HEADLESS} = Get variable value ${HEADLESS} ${False}
14+
&{options} = create dictionary headless=${HEADLESS}
15+
Open browser http://127.0.0.1:7272/basic-html-elements.html browser=${BROWSER} options=${options}
16+
Delete All Cookies

Examples/browser-management/open-close-browser.robot

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,30 @@ Handle multiple browser
3636
Wait Until Page Contains Login form
3737
Switch Browser Browser 2
3838
Wait Until Page Contains Browser Management
39-
39+
40+
Close current window
41+
[Teardown] Capture Page Screenshot
42+
${BROWSER} = Get variable value ${BROWSER} ${DEFAULT_BROWSER}
43+
${HEADLESS} Get variable value ${HEADLESS} ${False}
44+
&{options} = create dictionary headless=${HEADLESS}
45+
Open browser http://127.0.0.1:7272/basic-html-elements.html browser=${BROWSER} options=${options} alias=Browser 1
46+
Run Async Keywords
47+
... Wait For New Window Open AND
48+
... Click Element id=open-new-tab
49+
Switch Window NEW
50+
Wait Until Page Contains Login form
51+
Close Window
52+
53+
Window count
54+
[Teardown] Capture Page Screenshot
55+
${BROWSER} = Get variable value ${BROWSER} ${DEFAULT_BROWSER}
56+
${HEADLESS} Get variable value ${HEADLESS} ${False}
57+
&{options} = create dictionary headless=${HEADLESS}
58+
Open browser http://127.0.0.1:7272/basic-html-elements.html browser=${BROWSER} options=${options} alias=Browser 1
59+
${no of window} = Get Window Count
60+
Should Be Equal As Numbers 1 ${no of window}
61+
Run Async Keywords
62+
... Wait For New Window Open AND
63+
... Click Element id=open-new-tab
64+
${no of window} = Get Window Count
65+
Should Be Equal As Numbers 2 ${no of window}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
*** Settings ***
2+
Library PuppeteerLibrary
3+
Suite Teardown Close Puppeteer
4+
Test Teardown Close All Browser
5+
6+
*** Variables ***
7+
${DEFAULT_BROWSER} chrome
8+
9+
10+
*** Test Cases ***
11+
Scroll into view
12+
${BROWSER} = Get variable value ${BROWSER} ${DEFAULT_BROWSER}
13+
${HEADLESS} = Get variable value ${HEADLESS} ${False}
14+
&{options} = create dictionary headless=${HEADLESS}
15+
Open browser http://127.0.0.1:7272/basic-html-elements.html browser=${BROWSER} options=${options}
16+
Scroll Element Into View id=click_and_hide
17+
Scroll Element Into View id=get_ajax
18+
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
*** Settings ***
2+
Library PuppeteerLibrary
3+
Test Teardown Close All Browser
4+
Suite Teardown Close Puppeteer
5+
6+
*** Variables ***
7+
${DEFAULT_BROWSER} chrome
8+
9+
10+
*** Test Cases ***
11+
Select Checkbox element
12+
Open browser to test page http://127.0.0.1:7272/login-form-example.html
13+
Select Checkbox id=exampleCheck1
14+
Checkbox Should Be Selected id=exampleCheck1
15+
16+
Unselect Checkbox element
17+
Open browser to test page http://127.0.0.1:7272/login-form-example.html
18+
Select Checkbox id=exampleCheck1
19+
Unselect Checkbox id=exampleCheck1
20+
Checkbox Should Not Be Selected id=exampleCheck1
21+
22+
23+
24+
*** Keywords ***
25+
Open browser to test page
26+
[Arguments] ${url}
27+
${BROWSER} = Get variable value ${BROWSER} ${DEFAULT_BROWSER}
28+
${HEADLESS} Get variable value ${HEADLESS} ${False}
29+
&{options} = create dictionary headless=${HEADLESS}
30+
Open browser ${url} browser=${BROWSER} options=${options}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
*** Settings ***
2+
Library PuppeteerLibrary
3+
Test Teardown Close All Browser
4+
Suite Teardown Close Puppeteer
5+
6+
*** Variables ***
7+
${DEFAULT_BROWSER} chrome
8+
9+
10+
*** Test Cases ***
11+
Click element at coordiator
12+
Open browser to test page http://127.0.0.1:7272/login-form-example.html
13+
Run Async Keywords
14+
... Wait For New Window Open AND
15+
... Click Element At Coordinate css=button[type="submit"] 1 1
16+
17+
18+
*** Keywords ***
19+
Open browser to test page
20+
[Arguments] ${url}
21+
${BROWSER} = Get variable value ${BROWSER} ${DEFAULT_BROWSER}
22+
${HEADLESS} Get variable value ${HEADLESS} ${False}
23+
&{options} = create dictionary headless=${HEADLESS}
24+
Open browser ${url} browser=${BROWSER} options=${options}

Examples/form-handler/dropdown-list.robot

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,16 @@ Select dropdown list by labels with id
2222

2323
Select dropdown list by labels with xpath
2424
Select From List By Label xpath=//select[@id="cars"] Audi
25+
26+
Get selected dropdown list label
27+
Select From List By Label id=cars Audi
28+
${Label} = Get Selected List Label xpath=//select[@id="cars"]
29+
Should Be Equal As Strings Audi ${Label}
30+
31+
Get selected dropdown list value
32+
Select From List By Label id=cars Audi
33+
${Value} = Get Selected List Value xpath=//select[@id="cars"]
34+
Should Be Equal As Strings audi ${Value}
2535

2636
*** Keywords ***
2737
Open browser to test page

Examples/form-handler/element-properties.robot

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@ ${HOME_PAGE_URL} http://127.0.0.1:7272/basic-html-elements.html
1010

1111

1212
*** Test Cases ***
13+
Count element
14+
${No of h2} = Get Element Count css=h2
15+
Should Be Equal As Numbers 12 ${No of h2}
16+
17+
Get element attribute
18+
${type value} = Get Element Attribute id=alert_confirm type
19+
Should Be Equal As Strings button ${type value}
20+
1321
Element proprty is enable
1422
Element Should Be Enabled id:prop-enable
1523

Examples/form-handler/form-submit.robot

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ Submit register form
2828
Select From List By Value id=inputState 5
2929
Input Text id=inputZip 1234
3030
Click Element css=button[type="submit"]
31+
3132

3233
*** Keywords ***
3334
Open browser to test page

Examples/input/keyboard.robot

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
*** Settings ***
2+
Library Dialogs
3+
Library PuppeteerLibrary
4+
Test Setup Open browser to test page
5+
Test Teardown Close All Browser
6+
Suite Teardown Close Puppeteer
7+
8+
*** Variables ***
9+
${DEFAULT_BROWSER} chrome
10+
${HOME_PAGE_URL} http://127.0.0.1:7272/login-form-example.html
11+
12+
13+
*** Test Cases ***
14+
Element press keys
15+
Input Text id=exampleInputEmail1 [email protected]
16+
Input Text id=exampleInputPassword1 123456789
17+
Run Async Keywords
18+
... Wait For New Window Open AND
19+
... Press Keys id=exampleInputPassword1 Enter
20+
21+
*** Keywords ***
22+
Open browser to test page
23+
${BROWSER} = Get variable value ${BROWSER} ${DEFAULT_BROWSER}
24+
${HEADLESS} Get variable value ${HEADLESS} ${False}
25+
&{options} = create dictionary headless=${HEADLESS}
26+
Open browser ${HOME_PAGE_URL} browser=${BROWSER} options=${options}

0 commit comments

Comments
 (0)