Skip to content

Instantly share code, notes, and snippets.

Avatar
🏖️
Just living the good life

Nikolay Advolodkin nadvolod

🏖️
Just living the good life
View GitHub Profile
@nadvolod
nadvolod / Solution1.java
Created March 19, 2023 15:54
JUnit 4 Exercise Solutions
View Solution1.java
// Solution to 1
import org.junit.Test;
import static org.junit.Assert.assertEquals;
public class AdditionTest {
@Test
public void testSum() {
int sum = 3 + 4;
int expectedSum = 7;
@nadvolod
nadvolod / .gitpod.Dockerfile
Created February 19, 2023 23:58
How to run Selenium tests in GitPod
View .gitpod.Dockerfile
FROM gitpod/workspace-full-vnc:latest
USER gitpod
RUN bash -c ". /home/gitpod/.sdkman/bin/sdkman-init.sh && \
sdk install java 17.0.3-ms && \
sdk default java 17.0.3-ms"
# Install dependencies.
RUN sudo apt-get update \
@nadvolod
nadvolod / loginPage.ts
Last active February 3, 2023 19:00
Is this a good page object using playwright and typescript?
View loginPage.ts
export class LoginPage {
readonly page: Page;
readonly userNameTextbox: Locator
readonly passwordTextbox: Locator
readonly loginBtn: Locator
// Clarity over duplication removal
// Don't start with the abstraction
constructor(page: Page) {
this.page = page;
@nadvolod
nadvolod / playwright.spec.ts
Last active February 1, 2023 19:44
Flawed automated playwright tests
View playwright.spec.ts
test('Dashboard page should not have any WCAG A violations', async ({ page }) => {
const authentication = new Authentication(page);
const loginPage = new LoginPage(page);
const dashboardPage = new DashboardPage(page);
await loginPage.login(user)
// Wait until the logo is visible - default 30000
await dashboardPage.waitForLogo()
await page.getByRole('button', { name: 'Log In' }).click();
await authentication.loginWith2FA(user)
View loginPage.ts
import { expect, Locator, Page } from '@playwright/test';
const userNameFieldLoc = '[id="user-name"]'
const passwordFieldLoc = '[id="password"]'
const loginButtonLoc = '[id="login-button"]'
const errorloc = '[data-test="error"]'
const headerLoc = '[class="title"]'
const burgerMenue = '[id="react-burger-menu-btn"]'
const aboutButtonLoc = '[id="about_sidebar_link"]'
export default class LoginPage{
View example.ts
const page = await context.newPage();
await page.goto('/');
const loginPage = new LoginPage(page)
//option 1
await loginPage.login(data)
//option 2
await loginPage.userNameFill(userData.standart)
await loginPage.userPasswordFill(userData.correctPassword)
await loginPage.loginButtonClick()
await loginPage.burgerMenuClick()
View spm.spec.ts
test('User can create GPW record', async ({page}) => {
await dashboardPage.createNewModule(dataModule)
// What if instead of comments, our code was self readable?
// Verify that module has name: [newModule] is created
const expectedMessage = `SuccessModule "${content}" was created.Close`
expect(dashboardPage.isModuleCreated(newModule).toEqual(expectedMessage)
await dashboardPage.isModuleCreated(newModule)
// Remove the new module to avoid spam
await dashboardPage.goToHomePage()
@nadvolod
nadvolod / playwright-azure.yml
Last active November 24, 2022 18:19
Playwright test running in Azure DevOps
View playwright-azure.yml
trigger:
- main
pool:
vmImage: ubuntu-latest
steps:
- task: NodeTool@0
inputs:
versionSpec: '14.x'
@nadvolod
nadvolod / happo.spec.ts
Created November 18, 2022 15:15
An example of a working Happo.io test using Playwright
View happo.spec.ts
// @ts-check
import { test } from '@playwright/test';
const happoPlaywright = require('happo-playwright');
test.describe('Sitefinity CMS', () => {
test.beforeEach(async ({ page }) => {
await happoPlaywright.init(page);
await page.goto('https://afro.who.int/countries');
await page.waitForLoadState('networkidle');
await page.isVisible('[alt=Countries]');
@nadvolod
nadvolod / happo.js
Created October 9, 2022 14:52
Working happo test
View happo.js
import { Page, test } from '@playwright/test';
const happoPlaywright = require('happo-playwright');
let page: Page;
test.beforeAll(async ({ browser }) => {
page = await browser.newPage();
await happoPlaywright.init(page);
});