Skip to content

Commit

Permalink
try selenium test
Browse files Browse the repository at this point in the history
  • Loading branch information
chiaryan committed Nov 10, 2024
1 parent 9656dec commit ab4cc47
Show file tree
Hide file tree
Showing 8 changed files with 610 additions and 2 deletions.
34 changes: 33 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,42 @@ jobs:
- name: Run tests
run: |
cd ./apps/frontend
pnpm test
pnpm test -- __tests__/unit-tests
browser-test:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '22'

- name: Install pnpm
run: npm i -g pnpm

- name: Install dependencies
run: |
cd ./apps/frontend
pnpm i
- name: Run tests
run: |
cd ./apps/frontend
node .\__tests__\browser-tests\wtf.test.js
test-docker-compose:
runs-on: ubuntu-latest
- name: Checkout code
uses: actions/checkout@v4

- name: Install Chrome Driver
run: |
steps:
- name: Checkout code
Expand Down
44 changes: 44 additions & 0 deletions apps/frontend/__tests__/browser-tests/browser.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { Browser, Builder, By, Key, until } from "selenium-webdriver"

import { path } from "chromedriver"
import { getBinaryPaths } from "selenium-webdriver/common/driverFinder"
import Chrome from "selenium-webdriver/chrome"
describe("base selenium test", () => {
it.skip("works", async () => {
// referenced: https://www.npmjs.com/package/selenium-webdriver
console.log(path)

let options = new Chrome.Options();
options.setBrowserVersion("stable")

let paths = getBinaryPaths(options)
let driverPath = paths.driverPath;
let browserPath = paths.browserPath;
console.log(paths);

options.setChromeBinaryPath(browserPath)

let service = new Chrome.ServiceBuilder().setPath(driverPath);

let driver = await new Builder().forBrowser(Browser.CHROME)
.setChromeOptions(options)
.setChromeService(service)
.build();

console.log("got here");

try {
await driver.get('https://www.google.com/ncr')
console.log("got here");
await driver.findElement(By.name('q')).sendKeys('webdriver', Key.RETURN)
console.log("got here");
await driver.wait(until.titleIs('webdriver - Google Search'), 1000)
console.log("got here");
} finally {
await driver.quit()
}
}, 60000)
})



16 changes: 16 additions & 0 deletions apps/frontend/__tests__/browser-tests/works.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// require('chromedriver');
const { Builder, By, Key, until } = require('selenium-webdriver');
(async function test() {
const builder = new Builder().forBrowser('chrome');
console.log(builder.getChromeOptions());

let driver = await builder.build();

try {
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);
} finally {
await driver.quit();
}
})();
File renamed without changes.
File renamed without changes.
6 changes: 5 additions & 1 deletion apps/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,23 @@
"yjs": "^13.6.20"
},
"devDependencies": {
"@types/codemirror": "^5.60.15",
"@testing-library/dom": "^10.4.0",
"@testing-library/jest-dom": "^6.6.3",
"@testing-library/react": "^16.0.1",
"@types/chromedriver": "^81.0.5",
"@types/codemirror": "^5.60.15",
"@types/jest": "^29.5.14",
"@types/node": "^20",
"@types/peerjs": "^1.1.0",
"@types/react": "^18.3.8",
"@types/react-dom": "^18.3.0",
"@types/selenium-webdriver": "^4.1.27",
"chromedriver": "^130.0.4",
"eslint": "^8",
"eslint-config-next": "14.2.13",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"selenium-webdriver": "^4.26.0",
"ts-node": "^10.9.2",
"typescript": "^5"
},
Expand Down
Loading

0 comments on commit ab4cc47

Please sign in to comment.