-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[no-ci] improve documentation for ui drop-downs
- Loading branch information
Showing
3 changed files
with
133 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
karate-e2e-tests/src/test/java/driver/99_bootstrap.feature
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
Feature: | ||
|
||
Background: | ||
* driver serverUrl + '/99_bootstrap' | ||
|
||
Scenario: using the mouse to click and select something in a js-powered dropdown | ||
|
||
# can help for some pages that take time to load | ||
* waitUntil("document.readyState == 'complete'") | ||
|
||
# click on button to show dropdown options | ||
* mouse('button').click() | ||
|
||
# click on first option | ||
* mouse('a.dropdown-item').click() | ||
|
||
# asserted expected result | ||
* match text('#container') == 'First' | ||
|
||
|
||
Scenario: looping over data to repeat an action | ||
|
||
# can help for some pages that take time to load | ||
* waitUntil("document.readyState == 'complete'") | ||
|
||
# get all possible drop-down elements | ||
* def list = locateAll('a.dropdown-item') | ||
* def results = [] | ||
* def fun = | ||
""" | ||
function(e) { | ||
mouse('button').click(); | ||
e.mouse().click(); | ||
let result = text('#container').trim(); | ||
results.push(result); | ||
delay(2000); | ||
} | ||
""" | ||
|
||
# perform the loop to click on all dropdown items | ||
* list.forEach(fun) | ||
|
||
# assert at the end for the data collected | ||
* match results == ['First', 'Second', 'Third'] | ||
|
24 changes: 24 additions & 0 deletions
24
karate-e2e-tests/src/test/java/driver/html/99_bootstrap.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<title>Bootstrap</title> | ||
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-KK94CHFLLe+nY2dmCWGMq91rCGa5gtU4mk92HdvYe+M/SXH301p5ILy+dN9+nJOZ" crossorigin="anonymous"> | ||
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-ENjdO4Dr2bkBIFxQpeoTz1HIcje39Wm4jDKdf19U8gI4ddQ3GYNS7NTKfAdVQSZe" crossorigin="anonymous"></script> | ||
<script src="00.js"></script> | ||
<link rel="icon" href="00.ico"> | ||
</head> | ||
<body> | ||
<div class="dropdown"> | ||
<button class="btn btn-secondary dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false"> | ||
Dropdown button | ||
</button> | ||
<ul class="dropdown-menu"> | ||
<li><a class="dropdown-item" href="#" onclick="karate.setHtml('container', this.textContent)">First</a></li> | ||
<li><a class="dropdown-item" href="#" onclick="karate.setHtml('container', this.textContent)">Second</a></li> | ||
<li><a class="dropdown-item" href="#" onclick="karate.setHtml('container', this.textContent)">Third</a></li> | ||
</ul> | ||
</div> | ||
<div id="container"></div> | ||
</body> | ||
</html> | ||
|