Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit 196329a
Author: Ryan Chia <ryan_chia8@hotmail.com>
Date:   Tue Nov 12 17:25:34 2024 +0800

    remove webdriver working workflow

commit 1add73d
Author: Ryan Chia <ryan_chia8@hotmail.com>
Date:   Tue Nov 12 17:16:25 2024 +0800

    asd

commit 974caa6
Author: Ryan Chia <ryan_chia8@hotmail.com>
Date:   Tue Nov 12 16:09:05 2024 +0800

    asad

commit f1e3deb
Merge: 5dbc8a0 77f62db
Author: Ryan Chia <ryan_chia8@hotmail.com>
Date:   Tue Nov 12 16:04:54 2024 +0800

    Merge branch 'browser-compatibility-tests' into browser-tests

commit 5dbc8a0
Author: Ryan Chia <ryan_chia8@hotmail.com>
Date:   Tue Nov 12 15:50:20 2024 +0800

    asd
  • Loading branch information
chiaryan committed Nov 12, 2024
1 parent 1be60da commit 4b50754
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 12 deletions.
9 changes: 8 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,15 @@ jobs:
uses: nanasess/setup-chromedriver@v2
with:
chromedriver-version: '130.0.6723.116'
- name: Install Edge
uses: browser-actions/setup-edge@v1
with:
edge-version: stable

- name: Install Geckodriver
uses: browser-actions/setup-geckodriver@latest

- name: Run Browser Test
run: |
cd ./apps/frontend
pnpm browser-test
pnpm browser-test
46 changes: 35 additions & 11 deletions apps/frontend/__tests__/browser-tests/browser.test.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,53 @@
import { Actions, Browser, Builder, By, Key, until, WebDriver } from "selenium-webdriver"
import { Actions, Browser, Builder, By, Capabilities, Key, until, WebDriver } from "selenium-webdriver"

import {Options as ChromeOptions} from "selenium-webdriver/chrome"
import {Options as EdgeOptions} from "selenium-webdriver/edge"
import {Options as FirefoxOptions} from "selenium-webdriver/firefox"

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

describe("chrome browser", () => {
const options = new Chrome.Options()
.addArguments("--headless=new") as Chrome.Options; // uncomment locally to see the steps in action
const builder = new Builder().forBrowser(Browser.CHROME).setChromeOptions(options);
const CHROME_OPTIONS = new ChromeOptions()
.addArguments("--headless=new") as ChromeOptions; // uncomment locally to see the steps in action
const EDGE_OPTIONS = new EdgeOptions()
.setBinaryPath("/opt/hostedtoolcache/msedge/stable/x64/msedge") // need to point to the correct path
.addArguments("--headless=new") as EdgeOptions;

const FIREFOX_OPTIONS = new FirefoxOptions()
.addArguments("--headless") as FirefoxOptions;

const builder = new Builder()
.setChromeOptions(CHROME_OPTIONS)
.setEdgeOptions(EDGE_OPTIONS)
.setFirefoxOptions(FIREFOX_OPTIONS)

describe.each([Browser.CHROME, Browser.EDGE, Browser.FIREFOX])("%s driver test", (browser) => {
let driver: WebDriver;
beforeAll(() => {
const cap = new Capabilities().setBrowserName(browser)
builder.withCapabilities(cap);
})

beforeEach(async () => {
console.log(browser + ": building...");
driver = await builder.build();
})
console.log(browser + ": built");
}, 20000)

afterEach(async () => {
await driver.quit();
if (driver) {
await driver.quit();
}
})

describe("chrome webdriver installed correctly", () => {
describe("webdriver installed correctly", () => {
it("does google search", async () => {
await driver.get('http://www.google.com');
await driver.findElement(By.name('q')).sendKeys('webdriver', Key.RETURN);
await driver.wait(until.titleIs('webdriver - Google Search'), 1000);
}, 10000);
it("does another google search", async () => {

it.skip("does another google search", async () => {
await driver.get('http://www.google.com');
await driver.findElement(By.name('q')).sendKeys('webdriver', Key.RETURN);
await driver.wait(until.titleIs('webdriver - Google Search'), 1000);
Expand Down Expand Up @@ -52,7 +75,8 @@ describe("chrome browser", () => {
expect(slogan2).toBe("peers");
}, 10000);
})
})
}, 60000)




0 comments on commit 4b50754

Please sign in to comment.