screenshot/test_1
This commit is contained in:
97
tests/Visuvalization.spec.js
Normal file
97
tests/Visuvalization.spec.js
Normal file
@@ -0,0 +1,97 @@
|
||||
import { test, expect } from '@playwright/test';
|
||||
|
||||
test('Visualization-Drag&Drop Page', async ({ page }) => {
|
||||
test.setTimeout(60000); // Increase timeout if needed
|
||||
|
||||
// Widget locators
|
||||
const BarChart = page.locator("//div[@class='chart chart-1']");
|
||||
const DotGraph = page.locator("//div[@class='chart chart-2']");
|
||||
const PieChart = page.locator("//div[@class='chart chart-3']");
|
||||
const DoughnutChart = page.locator("//div[@class='chart chart-4']");
|
||||
const SpieChart = page.locator("//div[@class='chart chart-5']");
|
||||
|
||||
// Use nth() to resolve ambiguity for duplicate text elements
|
||||
const ProgressBar1 = page.getByText("Widget 7").nth(0);
|
||||
const ProgressBar2 = page.getByText("Widget 8").nth(0);
|
||||
|
||||
// Panel locators
|
||||
const LeftPanel = page.locator("//div[@class='panel left-panel absolute false']");
|
||||
const BottomPanel = page.locator("//div[@class='panel bottom-panel absolute false']");
|
||||
const TopPanel = page.locator("//div[@class='panel top-panel absolute false']");
|
||||
const RightPanel = page.locator("//div[@class='panel right-panel absolute false']");
|
||||
|
||||
// Navigate to the application and log in
|
||||
await page.goto('http://185.100.212.76:8200');
|
||||
await page.getByPlaceholder('Email').fill('nalvazhuthi@hexrfactory.com');
|
||||
await page.getByPlaceholder('Password').fill('123456');
|
||||
await page.waitForSelector('button:has-text("Continue")', { timeout: 10000 });
|
||||
await page.getByRole('button', { name: 'Continue', exact: true }).click();
|
||||
await page.getByText('Visualization').click();
|
||||
await page.getByText('Zone 1').click();
|
||||
|
||||
// Activate the left panel
|
||||
await page.getByTitle('Activate left panel').click();
|
||||
|
||||
// Maximize the browser window to full screen
|
||||
await page.setViewportSize({ width: 1920, height: 1080 }); // Full HD resolution
|
||||
|
||||
// Debugging: Take a screenshot before drag-and-drop
|
||||
await page.screenshot({ path: 'before-drag.png' });
|
||||
|
||||
// Perform drag-and-drop operations
|
||||
try {
|
||||
// Drag widgets to the left panel
|
||||
await BarChart.waitFor({ state: 'visible' });
|
||||
await LeftPanel.waitFor({ state: 'visible' });
|
||||
await BarChart.dragTo(LeftPanel);
|
||||
await DotGraph.dragTo(LeftPanel);
|
||||
await PieChart.dragTo(LeftPanel);
|
||||
await DoughnutChart.dragTo(LeftPanel);
|
||||
|
||||
// Activate the right panel and drag widgets
|
||||
await page.getByTitle('Activate right panel').click();
|
||||
await RightPanel.waitFor({ state: 'visible' });
|
||||
await DoughnutChart.dragTo(RightPanel);
|
||||
await SpieChart.dragTo(RightPanel);
|
||||
await ProgressBar1.dragTo(RightPanel);
|
||||
await ProgressBar2.dragTo(RightPanel);
|
||||
|
||||
// Activate the bottom panel and drag widgets
|
||||
await page.getByTitle('Activate bottom panel').click();
|
||||
await BottomPanel.waitFor({ state: 'visible' });
|
||||
await ProgressBar2.dragTo(BottomPanel);
|
||||
await PieChart.dragTo(BottomPanel);
|
||||
await DotGraph.dragTo(BottomPanel);
|
||||
await BarChart.dragTo(BottomPanel);
|
||||
|
||||
// Activate the top panel and drag widgets
|
||||
await page.getByTitle('Activate top panel').click();
|
||||
await TopPanel.waitFor({ state: 'visible' });
|
||||
await DoughnutChart.dragTo(TopPanel);
|
||||
await SpieChart.dragTo(TopPanel);
|
||||
await ProgressBar1.dragTo(TopPanel);
|
||||
await ProgressBar2.dragTo(TopPanel);
|
||||
} catch (error) {
|
||||
console.error('Drag-and-drop operation failed:', error.message);
|
||||
throw error; // Rethrow the error to fail the test
|
||||
}
|
||||
|
||||
// Wait for panels to update dynamically
|
||||
await page.waitForFunction(() => {
|
||||
const leftPanel = document.querySelector('.left-panel');
|
||||
const rightPanel = document.querySelector('.right-panel');
|
||||
const bottomPanel = document.querySelector('.bottom-panel');
|
||||
const topPanel = document.querySelector('.top-panel');
|
||||
return (
|
||||
leftPanel.children.length > 0 &&
|
||||
rightPanel.children.length > 0 &&
|
||||
bottomPanel.children.length > 0 &&
|
||||
topPanel.children.length > 0
|
||||
);
|
||||
});
|
||||
|
||||
// Debugging: Take a screenshot after drag-and-drop
|
||||
await page.screenshot({ path: 'after-drag.png' });
|
||||
|
||||
console.log('Drag-and-drop completed successfully.');
|
||||
});
|
||||
13
tests/login.spec.js
Normal file
13
tests/login.spec.js
Normal file
@@ -0,0 +1,13 @@
|
||||
import { test, expect } from '@playwright/test';
|
||||
|
||||
test('Login page', async ({ page }) => {
|
||||
// Navigate to the login page
|
||||
await page.goto('http://185.100.212.76:8200');
|
||||
|
||||
await page.getByPlaceholder('Email').fill('nalvazhuthi@hexrfactory.com');
|
||||
await page.getByPlaceholder('Password').fill('123456');
|
||||
await page.waitForTimeout(3000);
|
||||
await page.getByRole('button', { name: 'Continue', exact: true }).click();
|
||||
await page.waitForTimeout(3000);
|
||||
|
||||
});
|
||||
126
tests/screenshot.spec.js
Normal file
126
tests/screenshot.spec.js
Normal file
@@ -0,0 +1,126 @@
|
||||
const { test, expect } = require('@playwright/test');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
// Function to take screenshots at different viewport sizes for a given URL
|
||||
async function takeScreenshotsAtViewports(page, folderName, screenshotPrefix) {
|
||||
const viewports = [
|
||||
{ width: 1230, height: 629, name: 'moniter-spec' },
|
||||
{ width: 1280, height: 800, name: 'lap-spec' },
|
||||
{ width: 1920, height: 1080, name: 'TV-spec' },
|
||||
];
|
||||
|
||||
// Create the folder if it doesn't exist (Node.js context)
|
||||
const folderPath = path.join(__dirname, '..', 'test-results', folderName);
|
||||
if (!fs.existsSync(folderPath)) {
|
||||
fs.mkdirSync(folderPath, { recursive: true });
|
||||
}
|
||||
|
||||
for (const { width, height, name } of viewports) {
|
||||
await page.setViewportSize({ width, height });
|
||||
await page.waitForTimeout(500); // Allow time for the viewport to adjust
|
||||
const screenshotPath = path.join(folderPath, `${screenshotPrefix}-${name}.png`);
|
||||
await page.screenshot({
|
||||
path: screenshotPath,
|
||||
fullPage: true,
|
||||
});
|
||||
console.log(`Screenshot taken for ${name} resolution in folder ${folderName}`);
|
||||
}
|
||||
}
|
||||
|
||||
// test('Login Page Screenshots', async ({ page }) => {
|
||||
// test.setTimeout(60000); // Increase timeout to 60 seconds
|
||||
// const url = 'http://185.100.212.76:8200';
|
||||
// const folderName = 'login-screenshots';
|
||||
|
||||
// try {
|
||||
// console.log('Navigating to the login page...');
|
||||
// await page.goto(url, { waitUntil: 'networkidle' });
|
||||
// await page.waitForSelector('[placeholder="Email"]', { timeout: 10000 });
|
||||
// await takeScreenshotsAtViewports(page, `${folderName}/login-page-loaded`, 'login-page-loaded');
|
||||
|
||||
// console.log('Filling Email and Password fields...');
|
||||
// await page.getByPlaceholder('Email').click();
|
||||
// await page.getByPlaceholder('Email').fill('nalvazhuthi@hexrfactory.com');
|
||||
// await page.getByPlaceholder('Password').click();
|
||||
// await page.getByPlaceholder('Password').fill('123456');
|
||||
// await takeScreenshotsAtViewports(page, `${folderName}/fields-filled`, 'fields-filled');
|
||||
|
||||
// console.log('Clicking the Continue button...');
|
||||
// await page.waitForSelector('button:has-text("Continue")', { timeout: 10000 });
|
||||
// await page.getByRole('button', { name: 'Continue', exact: true }).click();
|
||||
// await page.waitForLoadState('networkidle'); // Wait for navigation or animations to complete
|
||||
// await takeScreenshotsAtViewports(page, `${folderName}/after-login`, 'after-login');
|
||||
// } catch (error) {
|
||||
// console.error('An error occurred during the test:', error.message);
|
||||
// throw error; // Re-throw the error to fail the test
|
||||
// }
|
||||
// });
|
||||
|
||||
// test('simulation Page Screenshots', async ({ page }) => {{
|
||||
|
||||
// const folderName = 'simulation-screenshots';
|
||||
|
||||
// await page.goto('http://185.100.212.76:8200');
|
||||
// await page.getByPlaceholder('Email').fill('nalvazhuthi@hexrfactory.com');
|
||||
// await page.getByPlaceholder('Password').fill('123456');
|
||||
// await page.waitForSelector('button:has-text("Continue")', { timeout: 10000 });
|
||||
// await page.getByRole('button', { name: 'Continue', exact: true }).click();
|
||||
// await page.getByText('Simulation').click();
|
||||
// await page.waitForTimeout(4000);
|
||||
// await takeScreenshotsAtViewports(page, `${folderName}/simulation-page-loaded`, 'simulation-page-loaded');
|
||||
|
||||
// }
|
||||
// });
|
||||
|
||||
// test('Visualization Page Screenshots', async ({ page }) => {
|
||||
// const folderName = 'Visualization-screenshots';
|
||||
|
||||
// // Navigate to the login page and log in
|
||||
// await page.goto('http://185.100.212.76:8200');
|
||||
// await page.getByPlaceholder('Email').fill('nalvazhuthi@hexrfactory.com');
|
||||
// await page.getByPlaceholder('Password').fill('123456');
|
||||
// await page.waitForSelector('button:has-text("Continue")', { timeout: 10000 });
|
||||
// await page.getByRole('button', { name: 'Continue', exact: true }).click();
|
||||
|
||||
// // Navigate to the Visualization page
|
||||
// await page.getByText('Visualization').click();
|
||||
// await page.waitForTimeout(4000); // Wait for the page to load
|
||||
// await takeScreenshotsAtViewports(page, `${folderName}/Visualization-page1-loaded`, 'Visualization1-page-loaded');
|
||||
|
||||
// // Navigate to Templates and Design pages
|
||||
// await page.locator('.toggle-header-item:has-text("Templates")').click(); // Use a more specific selector
|
||||
// await page.getByText('Design').click(); // Ensure this is unique
|
||||
// await takeScreenshotsAtViewports(page, `${folderName}/Visualization-page2-loaded`, 'Visualization2-page-loaded');
|
||||
// });
|
||||
|
||||
// test('Market-Place Page Screenshots', async ({ page }) => {{
|
||||
|
||||
// const folderName = 'simulation-screenshots';
|
||||
|
||||
// await page.goto('http://185.100.212.76:8200');
|
||||
// await page.getByPlaceholder('Email').fill('nalvazhuthi@hexrfactory.com');
|
||||
// await page.getByPlaceholder('Password').fill('123456');
|
||||
// await page.waitForSelector('button:has-text("Continue")', { timeout: 10000 });
|
||||
// await page.getByRole('button', { name: 'Continue', exact: true }).click();
|
||||
// await page.getByText('Market Place').click();
|
||||
// await page.waitForTimeout(4000);
|
||||
// await takeScreenshotsAtViewports(page, `${folderName}/Market-Place-page-loaded`, 'Market-Place-page-loaded');
|
||||
|
||||
// }
|
||||
// });
|
||||
|
||||
test('Visualization-Drag&Drop Page Screenshots', async ({ page }) => {
|
||||
const folderName = 'Visualization-screenshots';
|
||||
|
||||
// Navigate to the login page and log in
|
||||
await page.goto('http://185.100.212.76:8200');
|
||||
await page.getByPlaceholder('Email').fill('nalvazhuthi@hexrfactory.com');
|
||||
await page.getByPlaceholder('Password').fill('123456');
|
||||
await page.waitForSelector('button:has-text("Continue")', { timeout: 10000 });
|
||||
await page.getByRole('button', { name: 'Continue', exact: true }).click();
|
||||
await page.getByText('Visualization').click();
|
||||
// await page.waitForTimeout(4000);
|
||||
await page.getByTitle('Activate left panel').click();
|
||||
await page.waitForTimeout(4000);
|
||||
});
|
||||
Reference in New Issue
Block a user