Skip to content

Commit

Permalink
[Refactoring]
Browse files Browse the repository at this point in the history
  • Loading branch information
da-oleg-ignatiev committed Jun 4, 2024
1 parent 5962393 commit 915af16
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 27 deletions.
42 changes: 24 additions & 18 deletions pages/login-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,40 @@ import { expect, Page, Locator } from '@playwright/test';

export class LoginPage {
page;
getStartedLink;
//getStartedLink;
gettingStartedHeader;
pomLink
tocList;
//pomLink
//tocList;
username;
password;
signInButton;


constructor(page) {
this.page = page;
this.getStartedLink = page.locator('div', { hasText: 'Sign In' });
this.gettingStartedHeader = page.locator('div', { hasText: 'Sign In' });
this.pomLink = page.locator('li', {
hasText: 'Guides',
}).locator('a', {
hasText: 'Page Object Model',
});
this.tocList = page.locator('article div.markdown ul > li > a');
//this.getStartedLink = page.locator('div', { hasText: 'Sign In' });
//this.pomLink = page.locator('li', {hasText: 'Guides',}).locator('a', {hasText: 'Page Object Model',});
//this.tocList = page.locator('article div.markdown ul > li > a'); // toc is a common abbreviation for "Table of Contents"

this.username = page.getByTitle('Please enter your username.');
this.password = page.getByTitle('Please enter your password.');
this.signInButton = page.locator("css=[class='login-page-main-sign-in-button']");
this.gettingStartedHeader = this.signInButton;
}

async goto() {
await this.page.goto('https://ss-spa-qa1.ottest.net/Authentication');
}

async getStarted() {
await this.getStartedLink.first().click();
await expect(this.gettingStartedHeader).toBeVisible();
}

async pageObjectModel() {
await this.getStarted();
await this.pomLink.click();
async login() {
await expect(this.username.fill('anneotestcsid@dataart.com')).resolves.toBeUndefined();
await expect(this.password.fill('password1')).resolves.toBeUndefined();
await this.signInButton.click();
}

// async getStarted() {
// await this.getStartedLink.first().click();
// await expect(this.gettingStartedHeader).toBeVisible();
// }
}
21 changes: 21 additions & 0 deletions pages/portal-page.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { Page } from 'playwright';

export class PortalPage {
private page: Page;

constructor(page: Page) {
this.page = page;
}

// Add your methods and actions for the portal page here

async navigateToPortal() {
// Implement the logic to navigate to the portal page
}

async performSomeAction() {
// Implement the logic to perform some action on the portal page
}

// Add more methods as needed
}
10 changes: 1 addition & 9 deletions tests/oleg.test.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,5 @@ import { LoginPage } from '../pages/login-page.js';
test('ScoreSense', async ({ page }) => {
const loginPage = new LoginPage(page);
await loginPage.goto();

// move to LoginPage class
await expect(page.getByTitle('Please enter your username.').fill('anneotestcsid@dataart.com')).resolves.toBeUndefined();

// move to LoginPage class
await expect(page.getByTitle('Please enter your password.').fill('password1')).resolves.toBeUndefined();

// move to LoginPage class
await page.locator("css=[class='login-page-main-sign-in-button']").click();
await loginPage.login();
});

0 comments on commit 915af16

Please sign in to comment.