Skip to content

Commit 49cc02b

Browse files
committed
Replaced getByPlaceholder with getByRole
1 parent d601488 commit 49cc02b

4 files changed

Lines changed: 45 additions & 47 deletions

File tree

tests/playwright.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export default defineConfig({
1818
/* Fail the build on CI if you accidentally left test.only in the source code. */
1919
forbidOnly: !!process.env.CI,
2020
/* Retry on CI only */
21-
retries: process.env.CI ? 2 : 0,
21+
retries: process.env.CI ? 2 : 1,
2222
/* Opt out of parallel tests on CI. */
2323
workers: process.env.CI ? 1 : undefined,
2424
/* Reporter to use. See https://playwright.dev/docs/test-reporters */

tests/playwright/form.spec.ts

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,15 @@ test.describe("Form page", () => {
1515
"CroCoder | Building Software that Builds Your Business",
1616
);
1717
await expect(page.getByText("get in touch")).toBeVisible();
18-
await expect(page.getByPlaceholder("Full name *")).toBeVisible();
19-
await expect(page.getByPlaceholder("E-mail *")).toBeVisible();
2018
await expect(
21-
page.getByPlaceholder("Tell us about your project *"),
19+
page.getByRole("textbox", { name: "Full name *" }),
20+
).toBeVisible();
21+
await expect(page.getByRole("textbox", { name: "E-mail *" })).toBeVisible();
22+
await expect(
23+
page.getByRole("textbox", { name: "Tell us about your project *" }),
24+
).toBeVisible();
25+
await expect(
26+
page.getByRole("checkbox", { name: "I give consent to CroCoder to" }),
2227
).toBeVisible();
2328
await expect(
2429
page.getByText(
@@ -44,15 +49,13 @@ test.describe("Form page", () => {
4449
}),
4550
});
4651
});
47-
await page.getByPlaceholder("Full name *").fill("Test name");
48-
await page.getByPlaceholder("E-mail *").fill("test@test.com");
52+
await page.getByRole("textbox", { name: "Full name *" }).fill("Test name");
53+
await page.getByRole("textbox", { name: "E-mail *" }).fill("test@test.com");
4954
await page
50-
.getByPlaceholder("Tell us about your project *")
55+
.getByRole("textbox", { name: "Tell us about your project *" })
5156
.fill("This is a test input");
5257
await page
53-
.getByText(
54-
"I give consent to CroCoder to use this information to contact me.",
55-
)
58+
.getByRole("checkbox", { name: "I give consent to CroCoder to" })
5659
.click();
5760
await page.getByRole("button", { name: "Get a free build review" }).click();
5861

@@ -82,15 +85,13 @@ test.describe("Form submission from home page", () => {
8285
await page.getByRole("navigation").getByText("Contact us").last().click();
8386

8487
await expect(page.getByText("get in touch")).toBeVisible();
85-
await page.getByPlaceholder("Full name *").fill("Test name");
86-
await page.getByPlaceholder("E-mail *").fill("test@test.com");
88+
await page.getByRole("textbox", { name: "Full name *" }).fill("Test name");
89+
await page.getByRole("textbox", { name: "E-mail *" }).fill("test@test.com");
8790
await page
88-
.getByPlaceholder("Tell us about your project *")
91+
.getByRole("textbox", { name: "Tell us about your project *" })
8992
.fill("This is a test input");
9093
await page
91-
.getByText(
92-
"I give consent to CroCoder to use this information to contact me.",
93-
)
94+
.getByRole("checkbox", { name: "I give consent to CroCoder to" })
9495
.click();
9596
await page.getByRole("button", { name: "Get a free build review" }).click();
9697

@@ -117,15 +118,13 @@ test.describe("Form submission from home page", () => {
117118
await page.getByRole("navigation").getByText("Contact us").last().click();
118119

119120
await expect(page.getByText("get in touch")).toBeVisible();
120-
await page.getByPlaceholder("Full name *").fill("Test name");
121-
await page.getByPlaceholder("E-mail *").fill("test@test.com");
121+
await page.getByRole("textbox", { name: "Full name *" }).fill("Test name");
122+
await page.getByRole("textbox", { name: "E-mail *" }).fill("test@test.com");
122123
await page
123-
.getByPlaceholder("Tell us about your project *")
124+
.getByRole("textbox", { name: "Tell us about your project *" })
124125
.fill("This is a test input");
125126
await page
126-
.getByText(
127-
"I give consent to CroCoder to use this information to contact me.",
128-
)
127+
.getByRole("checkbox", { name: "I give consent to CroCoder to" })
129128
.click();
130129
await page.getByRole("button", { name: "Get a free build review" }).click();
131130

tests/playwright/formMobile.spec.ts

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,15 @@ test.describe("Form page in mobile view", () => {
2929
"CroCoder | Building Software that Builds Your Business",
3030
);
3131
await expect(page.getByText("get in touch")).toBeVisible();
32-
await expect(page.getByPlaceholder("Full name *")).toBeVisible();
33-
await expect(page.getByPlaceholder("E-mail *")).toBeVisible();
3432
await expect(
35-
page.getByPlaceholder("Tell us about your project *"),
33+
page.getByRole("textbox", { name: "Full name *" }),
34+
).toBeVisible();
35+
await expect(page.getByRole("textbox", { name: "E-mail *" })).toBeVisible();
36+
await expect(
37+
page.getByRole("textbox", { name: "Tell us about your project *" }),
38+
).toBeVisible();
39+
await expect(
40+
page.getByRole("checkbox", { name: "I give consent to CroCoder to" }),
3641
).toBeVisible();
3742
await expect(
3843
page.getByText(
@@ -56,15 +61,13 @@ test.describe("Form page in mobile view", () => {
5661
}),
5762
});
5863
});
59-
await page.getByPlaceholder("Full name *").fill("Test name");
60-
await page.getByPlaceholder("E-mail *").fill("test@test.com");
64+
await page.getByRole("textbox", { name: "Full name *" }).fill("Test name");
65+
await page.getByRole("textbox", { name: "E-mail *" }).fill("test@test.com");
6166
await page
62-
.getByPlaceholder("Tell us about your project *")
67+
.getByRole("textbox", { name: "Tell us about your project *" })
6368
.fill("This is a test input");
6469
await page
65-
.getByText(
66-
"I give consent to CroCoder to use this information to contact me.",
67-
)
70+
.getByRole("checkbox", { name: "I give consent to CroCoder to" })
6871
.click();
6972
await page.getByRole("button", { name: "Get a free build review" }).click();
7073

@@ -107,15 +110,13 @@ test.describe("Form submission in mobile view from home page", () => {
107110
await page.getByRole("link", { name: "Contact us", exact: true }).click();
108111

109112
await expect(page.getByText("get in touch")).toBeVisible();
110-
await page.getByPlaceholder("Full name *").fill("Test name");
111-
await page.getByPlaceholder("E-mail *").fill("test@test.com");
113+
await page.getByRole("textbox", { name: "Full name *" }).fill("Test name");
114+
await page.getByRole("textbox", { name: "E-mail *" }).fill("test@test.com");
112115
await page
113-
.getByPlaceholder("Tell us about your project *")
116+
.getByRole("textbox", { name: "Tell us about your project *" })
114117
.fill("This is a test input");
115118
await page
116-
.getByText(
117-
"I give consent to CroCoder to use this information to contact me.",
118-
)
119+
.getByRole("checkbox", { name: "I give consent to CroCoder to" })
119120
.click();
120121
await page.getByRole("button", { name: "Get a free build review" }).click();
121122

@@ -142,15 +143,13 @@ test.describe("Form submission in mobile view from home page", () => {
142143
await page.getByRole("link", { name: "Contact us", exact: true }).click();
143144

144145
await expect(page.getByText("get in touch")).toBeVisible();
145-
await page.getByPlaceholder("Full name *").fill("Test name");
146-
await page.getByPlaceholder("E-mail *").fill("test@test.com");
146+
await page.getByRole("textbox", { name: "Full name *" }).fill("Test name");
147+
await page.getByRole("textbox", { name: "E-mail *" }).fill("test@test.com");
147148
await page
148-
.getByPlaceholder("Tell us about your project *")
149+
.getByRole("textbox", { name: "Tell us about your project *" })
149150
.fill("This is a test input");
150151
await page
151-
.getByText(
152-
"I give consent to CroCoder to use this information to contact me.",
153-
)
152+
.getByRole("checkbox", { name: "I give consent to CroCoder to" })
154153
.click();
155154
await page.getByRole("button", { name: "Get a free build review" }).click();
156155

tests/playwright/navigationMobile.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ test.describe("Mobile view navigation via navigation bar to", () => {
4848

4949
test("For CTOs page", async () => {
5050
await expect(page.getByRole("navigation")).toBeVisible();
51-
await page.locator("#top-line").click();
51+
await page.getByRole("button", { name: "Toggle menu" }).click();
5252

5353
const forCtosLink = page
5454
.locator("#mobile-list")
@@ -65,7 +65,7 @@ test.describe("Mobile view navigation via navigation bar to", () => {
6565

6666
test("Blog page", async () => {
6767
await expect(page.getByRole("navigation")).toBeVisible();
68-
await page.locator("#top-line").click();
68+
await page.getByRole("button", { name: "Toggle menu" }).click();
6969

7070
const blogLink = page
7171
.locator("#mobile-list")
@@ -82,7 +82,7 @@ test.describe("Mobile view navigation via navigation bar to", () => {
8282

8383
test("Book a call section", async () => {
8484
await expect(page.getByRole("navigation")).toBeVisible();
85-
await page.locator("#top-line").click();
85+
await page.getByRole("button", { name: "Toggle menu" }).click();
8686

8787
const bookACallLink = page
8888
.locator("#mobile-list")
@@ -97,7 +97,7 @@ test.describe("Mobile view navigation via navigation bar to", () => {
9797

9898
test("Contact us page", async () => {
9999
await expect(page.getByRole("navigation")).toBeVisible();
100-
await page.locator("#top-line").click();
100+
await page.getByRole("button", { name: "Toggle menu" }).click();
101101

102102
const contactUsLink = page
103103
.locator("#mobile-list")

0 commit comments

Comments
 (0)