Skip to content

Commit 4b50754

Browse files
committed
Squashed commit of the following:
commit 196329a Author: Ryan Chia <[email protected]> Date: Tue Nov 12 17:25:34 2024 +0800 remove webdriver working workflow commit 1add73d Author: Ryan Chia <[email protected]> Date: Tue Nov 12 17:16:25 2024 +0800 asd commit 974caa6 Author: Ryan Chia <[email protected]> Date: Tue Nov 12 16:09:05 2024 +0800 asad commit f1e3deb Merge: 5dbc8a0 77f62db Author: Ryan Chia <[email protected]> Date: Tue Nov 12 16:04:54 2024 +0800 Merge branch 'browser-compatibility-tests' into browser-tests commit 5dbc8a0 Author: Ryan Chia <[email protected]> Date: Tue Nov 12 15:50:20 2024 +0800 asd
1 parent 1be60da commit 4b50754

File tree

2 files changed

+43
-12
lines changed

2 files changed

+43
-12
lines changed

.github/workflows/test.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,8 +237,15 @@ jobs:
237237
uses: nanasess/setup-chromedriver@v2
238238
with:
239239
chromedriver-version: '130.0.6723.116'
240+
- name: Install Edge
241+
uses: browser-actions/setup-edge@v1
242+
with:
243+
edge-version: stable
240244

245+
- name: Install Geckodriver
246+
uses: browser-actions/setup-geckodriver@latest
247+
241248
- name: Run Browser Test
242249
run: |
243250
cd ./apps/frontend
244-
pnpm browser-test
251+
pnpm browser-test

apps/frontend/__tests__/browser-tests/browser.test.ts

Lines changed: 35 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,53 @@
1-
import { Actions, Browser, Builder, By, Key, until, WebDriver } from "selenium-webdriver"
1+
import { Actions, Browser, Builder, By, Capabilities, Key, until, WebDriver } from "selenium-webdriver"
2+
3+
import {Options as ChromeOptions} from "selenium-webdriver/chrome"
4+
import {Options as EdgeOptions} from "selenium-webdriver/edge"
5+
import {Options as FirefoxOptions} from "selenium-webdriver/firefox"
26

3-
import Chrome from "selenium-webdriver/chrome"
47
const URL = 'http://localhost:3000/';
58
const ETERNAL_JWT = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyLCJleHAiOjk5OTk5OTk5OTk5fQ.Z4_FVGQ5lIcouP3m4YLMr6pGMF17IJFfo2yOTiN58DY"
69

7-
describe("chrome browser", () => {
8-
const options = new Chrome.Options()
9-
.addArguments("--headless=new") as Chrome.Options; // uncomment locally to see the steps in action
10-
const builder = new Builder().forBrowser(Browser.CHROME).setChromeOptions(options);
10+
const CHROME_OPTIONS = new ChromeOptions()
11+
.addArguments("--headless=new") as ChromeOptions; // uncomment locally to see the steps in action
12+
const EDGE_OPTIONS = new EdgeOptions()
13+
.setBinaryPath("/opt/hostedtoolcache/msedge/stable/x64/msedge") // need to point to the correct path
14+
.addArguments("--headless=new") as EdgeOptions;
15+
16+
const FIREFOX_OPTIONS = new FirefoxOptions()
17+
.addArguments("--headless") as FirefoxOptions;
18+
19+
const builder = new Builder()
20+
.setChromeOptions(CHROME_OPTIONS)
21+
.setEdgeOptions(EDGE_OPTIONS)
22+
.setFirefoxOptions(FIREFOX_OPTIONS)
23+
24+
describe.each([Browser.CHROME, Browser.EDGE, Browser.FIREFOX])("%s driver test", (browser) => {
1125
let driver: WebDriver;
26+
beforeAll(() => {
27+
const cap = new Capabilities().setBrowserName(browser)
28+
builder.withCapabilities(cap);
29+
})
1230

1331
beforeEach(async () => {
32+
console.log(browser + ": building...");
1433
driver = await builder.build();
15-
})
34+
console.log(browser + ": built");
35+
}, 20000)
1636

1737
afterEach(async () => {
18-
await driver.quit();
38+
if (driver) {
39+
await driver.quit();
40+
}
1941
})
2042

21-
describe("chrome webdriver installed correctly", () => {
43+
describe("webdriver installed correctly", () => {
2244
it("does google search", async () => {
2345
await driver.get('http://www.google.com');
2446
await driver.findElement(By.name('q')).sendKeys('webdriver', Key.RETURN);
2547
await driver.wait(until.titleIs('webdriver - Google Search'), 1000);
2648
}, 10000);
27-
it("does another google search", async () => {
49+
50+
it.skip("does another google search", async () => {
2851
await driver.get('http://www.google.com');
2952
await driver.findElement(By.name('q')).sendKeys('webdriver', Key.RETURN);
3053
await driver.wait(until.titleIs('webdriver - Google Search'), 1000);
@@ -52,7 +75,8 @@ describe("chrome browser", () => {
5275
expect(slogan2).toBe("peers");
5376
}, 10000);
5477
})
55-
})
78+
}, 60000)
79+
5680

5781

5882

0 commit comments

Comments
 (0)