Skip to content

Commit

Permalink
Merge pull request #2470 from f-delahaye/2291-refactor-locator-first
Browse files Browse the repository at this point in the history
Better handling of Playwright's strict mode
  • Loading branch information
ptrthomas authored Jan 2, 2024
2 parents 1008f7d + de00f73 commit 371ef76
Show file tree
Hide file tree
Showing 11 changed files with 214 additions and 233 deletions.
8 changes: 8 additions & 0 deletions karate-e2e-tests/src/test/java/driver/15.feature
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ Scenario:

# get first ul in entire document
* def first = locate('//ul')
# validates that operations other than locate also work...
* match attribute('//ul', 'id') == 'first'

# relative xpath - locate
* def second = first.locate('./ul/li')
Expand All @@ -25,9 +27,15 @@ Scenario:
* match (seconds[1].text) == 'item 2.2'

# relative xpath - script all
* match first.locateAll('./li').length == 3
* def level1 = first.scriptAll('./li', '_.textContent')
* match level1 == ['item 1', 'item 2', 'item 3']

# relative xpath (any depth) script all
* def all = first.scriptAll('.//li', '_.textContent')
* match all == ['item 1', 'item 2', 'item 2.1', 'item 2.2', 'item 3']

* def children = first.children
* match (children.length) == 4
* match (children[0].text) == 'item 1'
* match (children[0].parent).attribute('id') == 'first'
2 changes: 1 addition & 1 deletion karate-e2e-tests/src/test/java/driver/html/14.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
</head>
<body>
<div id="container1">
<iframe src="14_embedded" id="nestedParent" width="800" height="400"></iframe>
<iframe src="14_embedded" id="nestedParent" width="1200" height="400"></iframe>
<br/>
<button id="continueButton" onclick="simulateProcessing()">Continue</button>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
<link rel="icon" href="00.ico">
</head>
<body>
<iframe id="nestedChild" src="https://en.wikipedia.org/wiki/Main_Page" width="800" height="400"></iframe>
<iframe id="nestedChild" src="https://en.wikipedia.org/wiki/Main_Page" width="1200" height="400"></iframe>
</body>
</html>
2 changes: 1 addition & 1 deletion karate-e2e-tests/src/test/java/driver/html/15.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<link rel="icon" href="00.ico">
</head>
<body>
<ul>
<ul id="first">
<li>item 1</li>
<li>item 2</li>
<ul>
Expand Down
Loading

0 comments on commit 371ef76

Please sign in to comment.