-
Notifications
You must be signed in to change notification settings - Fork 33
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
2 changed files
with
32 additions
and
1 deletion.
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
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,31 @@ | ||
import { test, expect, APIRequestContext } from '@playwright/test'; | ||
import ContactPage from '../pages/contact.page'; | ||
import { faker } from '@faker-js/faker'; | ||
|
||
test.describe('Contact', () => { | ||
let contactPage: ContactPage; | ||
let fakerApi: APIRequestContext; | ||
|
||
test.beforeAll(async ({ playwright }) => { | ||
fakerApi = await playwright.request.newContext({ | ||
baseURL: 'https://jsonplaceholder.typicode.com/' | ||
}); | ||
|
||
const response = await fakerApi.get('users'); | ||
console.log(await response.json()); | ||
}) | ||
|
||
|
||
test('Fill contact form and verify success message', async ({ page }) => { | ||
contactPage = new ContactPage(page); | ||
|
||
// open contact page | ||
await contactPage.navigate() | ||
|
||
// fill out the input fields and submit | ||
await contactPage.submitForm(faker.name.findName(), faker.internet.email(), faker.phone.number(), faker.lorem.paragraphs(2)); | ||
|
||
// verify success message | ||
await expect(contactPage.successTxt).toHaveText('Thanks for contacting us! We will be in touch with you shortly') | ||
}) | ||
}) |