Skip to content

Commit

Permalink
asd add browsers
Browse files Browse the repository at this point in the history
  • Loading branch information
chiaryan committed Nov 12, 2024
1 parent b0b9fb5 commit 9663688
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 8 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,14 @@ 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: |
Expand Down
33 changes: 25 additions & 8 deletions apps/frontend/__tests__/browser-tests/browser.test.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,30 @@
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()
.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 () => {
driver = await builder.build();
Expand All @@ -18,13 +34,14 @@ describe("chrome browser", () => {
await driver.quit();
})

describe("chrome webdriver installed correctly", () => {
describe.skip("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

0 comments on commit 9663688

Please sign in to comment.