Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[200~Implement script injection and assertion functions with error ha… #162

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { Page, expect } from '@playwright/test';

/**
* Injects and executes script logic, stores the return value in single div element.
* @param page Playwright page context
* @param script logic to be executed
* @returns {Promise}
*/
export async function injectScript(page: Page, script: string) {
return await page.setContent(`
<script>
async function main() {
const amount = ${script};
document.querySelector('div').textContent = amount;
}
main()
</script>
<div data-testid="main"></div>
`);
}

/**
* Asserts expected value from the content received in div element
* @param page Playwright page context
* @param expected value to be asserted from received value
* @returns {Promise}
*/
export async function assertScriptText(page: Page, expected: string) {
return await expect(page.getByTestId('main')).toHaveText(expected);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { Page, expect } from '@playwright/test';

/**
* Injects and executes script logic, stores the return value in single div element.
* @param page Playwright page context
* @param script logic to be executed
* @returns {Promise}
*/
export async function injectScript(page: Page, script: string) {
let
return await page.setContent(`
<script>
async function main() {
const amount = ${script};
document.querySelector('div').textContent = amount;
}
main()
</script>
<div data-testid="main"></div>
`);
}

/**
* Asserts expected value from the content received in div element
* @param page Playwright page context
* @param expected value to be asserted from received value
* @returns {Promise}
*/
export async function assertScriptText(page: Page, expected: string) {
return await expect(page.getByTestId('main')).toHaveText(expected);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { Page, expect } from '@playwright/test';

/**
* Injects and executes script logic, stores the return value in single div element.
* @param page Playwright page context
* @param script logic to be executed
* @returns {Promise}
*/
export async function injectScript(page: Page, script: string) {
let s
return await page.setContent(`
<script>
async function main() {
const amount = ${script};
document.querySelector('div').textContent = amount;
}
main()
</script>
<div data-testid="main"></div>
`);
}

/**
* Asserts expected value from the content received in div element
* @param page Playwright page context
* @param expected value to be asserted from received value
* @returns {Promise}
*/
export async function assertScriptText(page: Page, expected: string) {
return await expect(page.getByTestId('main')).toHaveText(expected);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { Page, expect } from '@playwright/test';

/**
* Injects and executes script logic, stores the return value in single div element.
* @param page Playwright page context
* @param script logic to be executed
* @returns {Promise}
*/
export async function injectScript(page: Page, script: string) {
let
return await page.setContent(`
<script>
async function main() {
const amount = ${script};
document.querySelector('div').textContent = amount;
}
main()
</script>
<div data-testid="main"></div>
`);
}

/**
* Asserts expected value from the content received in div element
* @param page Playwright page context
* @param expected value to be asserted from received value
* @returns {Promise}
*/
export async function assertScriptText(page: Page, expected: string) {
return await expect(page.getByTestId('main')).toHaveText(expected);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { Page, expect } from '@playwright/test';

/**
* Injects and executes script logic, stores the return value in single div element.
* @param page Playwright page context
* @param script logic to be executed
* @returns {Promise}
*/
export async function injectScript(page: Page, script: string) {
let safeScript = script.replace()
return await page.setContent(`
<script>
async function main() {
const amount = ${script};
document.querySelector('div').textContent = amount;
}
main()
</script>
<div data-testid="main"></div>
`);
}

/**
* Asserts expected value from the content received in div element
* @param page Playwright page context
* @param expected value to be asserted from received value
* @returns {Promise}
*/
export async function assertScriptText(page: Page, expected: string) {
return await expect(page.getByTestId('main')).toHaveText(expected);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { Page, expect } from '@playwright/test';

/**
* Injects and executes script logic, stores the return value in single div element.
* @param page Playwright page context
* @param script logic to be executed
* @returns {Promise}
*/
export async function injectScript(page: Page, script: string) {
let safeScript = script.replace(/<\/script>/g, '<\\/script>')
return await page.setContent(`
<script>
async function main() {
const amount = ${script};
document.querySelector('div').textContent = amount;
}
main()
</script>
<div data-testid="main"></div>
`);
}

/**
* Asserts expected value from the content received in div element
* @param page Playwright page context
* @param expected value to be asserted from received value
* @returns {Promise}
*/
export async function assertScriptText(page: Page, expected: string) {
return await expect(page.getByTestId('main')).toHaveText(expected);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { Page, expect } from '@playwright/test';

/**
* Injects and executes script logic, stores the return value in single div element.
* @param page Playwright page context
* @param script logic to be executed
* @returns {Promise}
*/
export async function injectScript(page: Page, script: string) {
let safeScript = script.replace(/<\/script>/g, '<\\/script>');
return await page.setContent(`
<script>
async function main() {
const amount = ${script};
document.querySelector('div').textContent = amount;
}
main()
</script>
<div data-testid="main"></div>
`);
}

/**
* Asserts expected value from the content received in div element
* @param page Playwright page context
* @param expected value to be asserted from received value
* @returns {Promise}
*/
export async function assertScriptText(page: Page, expected: string) {
return await expect(page.getByTestId('main')).toHaveText(expected);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { Page, expect } from '@playwright/test';

/**
* Injects and executes script logic, stores the return value in single div element.
* @param page Playwright page context
* @param script logic to be executed
* @returns {Promise}
*/
export async function injectScript(page: Page, script: string) {
let safeScript = script.replace(/<\/script>/g, '<\\/script>');
return await page.setContent(`
<script>
async function main() {
const amount = ${safeScript};
document.querySelector('div').textContent = amount;
}
main()
</script>
<div data-testid="main"></div>
`);
}

/**
* Asserts expected value from the content received in div element
* @param page Playwright page context
* @param expected value to be asserted from received value
* @returns {Promise}
*/
export async function assertScriptText(page: Page, expected: string) {
return await expect(page.getByTestId('main')).toHaveText(expected);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { Page, expect } from '@playwright/test';

/**
* Injects and executes script logic, stores the return value in single div element.
* @param page Playwright page context
* @param script logic to be executed
* @returns {Promise}
*/
export async function injectScript(page: Page, script: string) {
let safeScript = script.replace(/<\/script>/g, '<\\/script>');
return await page.setContent(`
<script>
async function main() {

const amount = ${safeScript};
document.querySelector('div').textContent = amount;
}
main()
</script>
<div data-testid="main"></div>
`);
}

/**
* Asserts expected value from the content received in div element
* @param page Playwright page context
* @param expected value to be asserted from received value
* @returns {Promise}
*/
export async function assertScriptText(page: Page, expected: string) {
return await expect(page.getByTestId('main')).toHaveText(expected);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { Page, expect } from '@playwright/test';

/**
* Injects and executes script logic, stores the return value in single div element.
* @param page Playwright page context
* @param script logic to be executed
* @returns {Promise}
*/
export async function injectScript(page: Page, script: string) {
let safeScript = script.replace(/<\/script>/g, '<\\/script>');
return await page.setContent(`
<script>
async function main() {
try{}
const amount = ${safeScript};
document.querySelector('div').textContent = amount;
}
main()
</script>
<div data-testid="main"></div>
`);
}

/**
* Asserts expected value from the content received in div element
* @param page Playwright page context
* @param expected value to be asserted from received value
* @returns {Promise}
*/
export async function assertScriptText(page: Page, expected: string) {
return await expect(page.getByTestId('main')).toHaveText(expected);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { Page, expect } from '@playwright/test';

/**
* Injects and executes script logic, stores the return value in single div element.
* @param page Playwright page context
* @param script logic to be executed
* @returns {Promise}
*/
export async function injectScript(page: Page, script: string) {
let safeScript = script.replace(/<\/script>/g, '<\\/script>');
return await page.setContent(`
<script>
async function main() {
try{
const amount = ${safeScript};
document.querySelector('div').textContent = amount;
}
main()
</script>
<div data-testid="main"></div>
`);
}

/**
* Asserts expected value from the content received in div element
* @param page Playwright page context
* @param expected value to be asserted from received value
* @returns {Promise}
*/
export async function assertScriptText(page: Page, expected: string) {
return await expect(page.getByTestId('main')).toHaveText(expected);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { Page, expect } from '@playwright/test';

/**
* Injects and executes script logic, stores the return value in single div element.
* @param page Playwright page context
* @param script logic to be executed
* @returns {Promise}
*/
export async function injectScript(page: Page, script: string) {
let safeScript = script.replace(/<\/script>/g, '<\\/script>');
return await page.setContent(`
<script>
async function main() {
try{
const amount = ${safeScript};
document.querySelector('div').textContent = amount;
}

main()
</script>
<div data-testid="main"></div>
`);
}

/**
* Asserts expected value from the content received in div element
* @param page Playwright page context
* @param expected value to be asserted from received value
* @returns {Promise}
*/
export async function assertScriptText(page: Page, expected: string) {
return await expect(page.getByTestId('main')).toHaveText(expected);
}
Loading