-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
81af671
commit 38bf08a
Showing
2 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { Page , Locator} from '@playwright/test'; | ||
|
||
class BlogPage{ | ||
page: Page; | ||
blogHeading: Locator; | ||
blogLinksList: Locator; | ||
constructor(page: Page){ | ||
this.page=page; | ||
this.blogHeading = page.locator('//h2[normalize-space()="Recent Posts"]'); | ||
this.blogLinksList = page.locator('//section[@id="recent-posts-3"]//ul//li'); | ||
|
||
} | ||
|
||
} | ||
|
||
export default BlogPage; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { test, expect } from '@playwright/test'; | ||
import HomePage from '../pages/home.page'; | ||
import BlogPage from '../pages/blog.page'; | ||
|
||
test.describe('Blog page', () => { | ||
let homePage:HomePage; | ||
let blogPage:BlogPage; | ||
|
||
test('Verify the number of links present in the blogs page', async ({ page }) => { | ||
homePage = new HomePage(page); | ||
blogPage = new BlogPage(page); | ||
|
||
//Open Url | ||
await homePage.navigate(); | ||
page.pause(); | ||
//Click on Blog | ||
await homePage.blogMenu.click(); | ||
|
||
//Verify url has blog | ||
await expect(page).toHaveURL(/.*blog/); | ||
|
||
|
||
await blogPage.blogHeading.hover(); | ||
const relatedLinks = blogPage.blogLinksList; | ||
const len = await relatedLinks.count(); | ||
console.log ("Total number of links present in Recent Posts is "+ len); | ||
|
||
// Verify the number of related links present in blogs is 5 | ||
expect(len).toEqual(5); | ||
|
||
const mylist = blogPage.blogLinksList.allTextContents(); | ||
const myList = await mylist; // Assuming mylist is an asynchronous operation that returns a list | ||
|
||
for (let i = 0; i < myList.length; i++) { | ||
console.log("Length of " + myList[i].trim() + " is " + myList[i].trim().length); | ||
} | ||
|
||
}) | ||
} | ||
|
||
); |