Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions tests/DragAndDrop.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import {test, expect} from "@playwright/test";

test("Handle Drag and Drop option", async({page})=>{
await page.goto("https://www.htmlgoodies.com/scripts/drag-and-drop-custom/demo-drag-and-drop-3.html");

const srcRome = await page.locator("#box6");
const targetItaly = await page.locator("#box106");

//Approach 1
await srcRome.hover();
await page.mouse.down();

await targetItaly.hover();
await page.mouse.up();

await page.waitForTimeout(5000);

//Approach 2
await srcRome.dragTo(targetItaly);


await page.waitForTimeout(5000);
})
25 changes: 25 additions & 0 deletions tests/Keyboard.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import {test, expect} from "@playwright/test";

test("Keyboard Actions", async({page})=>{
await page.goto("https://gotranscript.com/text-compare");

await page.locator("//textarea[@name='text1']").fill("Hello My name is Kunj Maheshwari");

//Ctrl + A
await page.keyboard.press("Meta+A");
//using the press method, we can press 2 keys at the same time
//for windows it should be Control+A
//for mac it is Meta+A

//Ctrl + C
await page.keyboard.press("Meta+C");

//Tab Key
await page.keyboard.press("Tab");

//Ctrl + V
await page.keyboard.press("Meta+V");


await page.waitForTimeout(5000);
})
18 changes: 18 additions & 0 deletions tests/MouseDoubleClick.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import {test, expect} from "@playwright/test";

test("Mouse Double Click", async({page})=>{
await page.goto("https://testautomationpractice.blogspot.com/");

const firstInputBoxText = await page.locator("//input[@id='field1']").inputValue();
console.log(firstInputBoxText);

//double click
const doubleClickBtn = await page.locator("//button[text()='Copy Text']");

await doubleClickBtn.dblclick();

expect(await page.locator("//input[@id='field2']")).toHaveValue(firstInputBoxText);


await page.waitForTimeout(5000);
})
14 changes: 14 additions & 0 deletions tests/MouseHover.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { test, expect } from "@playwright/test";

test("Mouse Hover", async ({ page }) => {
await page.goto("https://demo.opencart.com/");

const desktopOption = await page.locator("//a[text()='Desktops']");
const macOption = await page.locator("//a[text()='Mac (1)']");

//mouse hover
await desktopOption.hover();
await macOption.hover();

await page.waitForTimeout(5000);
})
13 changes: 13 additions & 0 deletions tests/MouseRightClick.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import {test, expect} from '@playwright/test';

test("Mouse Right Click Action", async({page})=>{
await page.goto("https://swisnl.github.io/jQuery-contextMenu/demo.html");

const button = await page.locator("//span[text()='right click me']");

//right click

await button.click({button: 'right'});

await page.waitForTimeout(5000);
})
41 changes: 41 additions & 0 deletions tests/UploadFiles.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import {test, expect} from "@playwright/test";

test("Single Upload Files", async({page})=>{
await page.goto("https://www.foundit.in");

await page.waitForSelector(".mqfihd-upload");
await page.locator(".mqfihd-upload").click();

//for uploading the single file
page.locator("#file-upload").setInputFiles("tests/uploadFiles/file1path");

await page.waitForTimeout(5000);
})

test("Multiple Upload Files", async({page})=>{
await page.goto("https://www.foundit.com");

await page.locator("#filesUpload").click();

//for uploading the multiple files
await page.locator("#filesUpload").setInputFiles([
'tests/uploadFiles/testfile1.pdf',
'tests/uploadFiles/testfile2.pdf'
])

await page.waitForTimeout(5000);

//verifying whether the files are uploaded or not
expect(await page.locator("#fileList li:nth-child(1)")).toHaveText('testfile1.pdf');
expect(await page.locator("#fileList li:nth-child(1)")).toHaveText('testfile2.pdf');

await page.waitForTimeout(5000);

//removing the files
await page.locator("#filesUpload").setInputFiles([]);

await page.waitForTimeout(3000);

//verifying the files are removed or not
expect(await page.locator("#fileList li:nth-child(1)")).toHaveText("No Files Selected");
})
Loading