-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
41 changed files
with
659 additions
and
105 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
node_modules/ | ||
results/ | ||
**/snapshots/**/actual | ||
**/snapshots/**/diff |
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
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
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 |
---|---|---|
@@ -1,13 +1,13 @@ | ||
# Feature: II. Form Elements - Checkbox | ||
Feature: II. Form Elements - Checkbox | ||
|
||
# Background: | ||
# Given I am on the "demo" site | ||
# And I click the "II. Form Elements" navigation item | ||
# And I expect the section header "II. Form Elements" to exist | ||
Background: | ||
Given I am on the "demo" site | ||
And I click the "II. Form Elements" navigation item | ||
And I expect the section header "II. Form Elements" to exist | ||
|
||
# Scenario: S01: Checkboxes | ||
# When I select the "#input-checkbox-1" check box | ||
# Then I expect the "#input-checkbox-1" check box to be selected | ||
# But I deselect the "#input-checkbox-1" check box | ||
# Then I expect the "#input-checkbox-1" check box to not be selected | ||
# And I expect the "#input-checkbox-2" check box to be selected | ||
Scenario: S01: Checkboxes | ||
When I select the "#input-checkbox-1" check box | ||
Then I expect the "#input-checkbox-1" check box to be selected | ||
But I deselect the "#input-checkbox-1" check box | ||
Then I expect the "#input-checkbox-1" check box to not be selected | ||
And I expect the "#input-checkbox-2" check box to be selected |
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,13 @@ | ||
Feature: II. Form Elements - Radio | ||
|
||
Background: | ||
Given I am on the "demo" site | ||
And I click the "II. Form Elements" navigation item | ||
And I expect the section header "II. Form Elements" to exist | ||
|
||
Scenario: S01: Radio options | ||
When I select the "#input-radio-1" radio button | ||
Then I expect the "#input-radio-1" radio button to be selected | ||
But I select the "#input-radio-2" radio button | ||
Then I expect the "#input-radio-1" radio button to not be selected | ||
And I expect the "#input-radio-2" radio button to be selected |
37 changes: 37 additions & 0 deletions
37
demo/test/features/iii-browser-context/4-browser-windows.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,37 @@ | ||
Feature: III. Browser Context - Browser windows | ||
|
||
Background: | ||
Given I am on the "demo" site | ||
And I click the "III. Browser Context" navigation item | ||
And I expect the section header "III. Browser Context" to exist | ||
|
||
Scenario: S01: Open on same window | ||
When I click the "#open-same-window" button | ||
Then I expect the tab count to be 1 | ||
And I expect to be on the "iframe" page | ||
But I navigate back from the current page | ||
Then I expect to be on the "demo" site | ||
When I navigate forward from the current page | ||
Then I expect to be back on the "iframe" page | ||
|
||
Scenario: S02: Open on new window | ||
When I open the "demo" page's url on a new window | ||
Then I expect the tab count to be more than 1 | ||
And I expect the tab count to be less than 3 | ||
But I close the last opened window | ||
Then I expect the tab count to not be more than 1 | ||
And I expect the tab count to not be less than 1 | ||
When I click the "#open-new-window" button | ||
Then I expect to still be on the "demo" page | ||
But I focus on the last opened window | ||
Then I expect to be on the "iframe" page | ||
And I expect the page title to be "Demo Iframe" | ||
And I expect the page title to be the "iframe" page's title | ||
And I expect the url to be the "iframe" page's url | ||
And I expect the "#card-1" element to match the snapshot "iii-browser-context/3-browser-windows/card" | ||
And I expect the viewport to match the snapshot "iii-browser-context/3-browser-windows/viewport" | ||
But I close all other windows | ||
Then I expect the page title to not be "Demo Iframe" | ||
And I expect the page title to not be the "iframe" page's title | ||
And I expect the url to not be the "iframe" page's url | ||
And I expect the page to match the snapshot "iii-browser-context/3-browser-windows/page" |
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 @@ | ||
import * as playwright from "@playwright/test"; | ||
|
||
import { | ||
expect, | ||
given, | ||
locator, | ||
scrollTo, | ||
scrollToBottom, | ||
scrollToTop | ||
} from "@commands/page"; | ||
import { Page } from "@generics"; | ||
|
||
export function addPageCommands(this: playwright.BrowserContext | any, ...args: any) { | ||
const [page] = args; | ||
page[expect.name] = (...args: Parameters<typeof expect>) => expect.call(page, ...args); | ||
page[given.name] = () => given.call(page); | ||
page[locator.name] = (...args: Parameters<typeof locator>) => locator.call(page, ...args); | ||
page[scrollToBottom.name] = (...args: Parameters<typeof scrollToBottom>) => scrollToBottom.call(page, ...args); | ||
page[scrollToTop.name] = (...args: Parameters<typeof scrollToTop>) => scrollToTop.call(page, ...args); | ||
page[scrollTo.name] = (...args: Parameters<typeof scrollTo>) => scrollTo.call(page, ...args); | ||
page.config = this.config; | ||
return page as Page; | ||
} | ||
|
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,12 @@ | ||
import * as playwright from "@playwright/test"; | ||
|
||
import { Page } from "@generics"; | ||
|
||
export async function closeLastPage(this: playwright.BrowserContext) { | ||
const pages = this.pages(); | ||
const [page] = pages.slice(-1); | ||
await page.close(); | ||
|
||
return pages[0] as Page; | ||
} | ||
|
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,17 @@ | ||
import * as playwright from "@playwright/test"; | ||
|
||
import { Page } from "@generics"; | ||
|
||
export async function closeOtherPages(this: playwright.BrowserContext) { | ||
let pages = this.pages(); | ||
|
||
while (pages.length > 1) { | ||
const last = pages.slice(-1)[0]; | ||
|
||
await last.close(); | ||
pages = this.pages(); | ||
} | ||
|
||
return pages[0] as Page; | ||
} | ||
|
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,5 @@ | ||
export * from "./add-page-commands"; | ||
export * from "./close-last-page"; | ||
export * from "./close-other-pages"; | ||
export * from "./last-page"; | ||
export * from "./new-page"; |
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,8 @@ | ||
import { BrowserContext } from "@generics"; | ||
|
||
export function lastPage(this: BrowserContext) { | ||
const pages = this.pages(); | ||
const [page] = pages.slice(-1); | ||
return this.addPageCommands(page); | ||
} | ||
|
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,10 @@ | ||
import * as playwright from "@playwright/test"; | ||
|
||
export async function newPage(this: playwright.BrowserContext | any) { | ||
if (this._ownerPage) throw new Error("Please use browser.newContext()"); | ||
const { Page } = require("node_modules/playwright-core/lib/client/page.js"); | ||
|
||
const page = Page.from((await this._channel.newPage()).page); | ||
return this.addPageCommands(page); | ||
} | ||
|
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
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
This file was deleted.
Oops, something went wrong.
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 @@ | ||
export * as string from "./string"; |
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,18 @@ | ||
export function isURL(str: string) { | ||
try { | ||
const url = new URL(str); | ||
return ["http:", "https:"].includes(url.protocol); | ||
} catch (e) { | ||
return false; | ||
} | ||
} | ||
|
||
export function isJSON(str: string) { | ||
if (typeof str !== "string") return false; | ||
try { | ||
const result = JSON.parse(str); | ||
return result instanceof Array || result instanceof Object; | ||
} catch (e) { | ||
return false; | ||
} | ||
} |
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
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
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,14 @@ | ||
import { SnapshotMatch as ExpectedCondition } from "@conditions/page/snapshot-match"; | ||
import { LocatorSnapshotOptions } from "@generics"; | ||
|
||
export class SnapshotMatch extends ExpectedCondition { | ||
|
||
public constructor(filename: string, options?: LocatorSnapshotOptions, preferred?: boolean) { | ||
super(filename, options, preferred); | ||
} | ||
|
||
async evaluate() { | ||
this.page = this.locator.page(); | ||
return super.evaluate(); | ||
} | ||
} |
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
Oops, something went wrong.