admin管理员组文章数量:1406943
I am currently trying to run automation testing on a sample SAPUI5 application using Playwright(Similar to Puppeteer). I am trying to scroll to the bottom of the page. However, the function works on other websites except SAPUI5 applications.
My code is displayed below:
const playwright = require('playwright');
(async () => {
for (const browserType of ['chromium']) {
const browser = await playwright[browserType].launch({
headless: false
});
const context = await browser.newContext();
const page = await context.newPage();
await page.goto(".html?sap-ui-theme=sap_fiori_3");
await page.setViewport({
width: 1200,
height: 500
});
await page.waitFor(5000);
await page.waitForSelector("#__item0-__clone9-content");
await scrollOnElement(page,"#__item0-__clone9-content",0,300);
}
})();
async function scrollOnElement(page,selector,x,y) {
await page.evaluate(([selector, x, y]) => {
const element = document.querySelector(selector);
console.log(element);
element.scroll(x, y);
}, [selector, x, y]);
}
Is this because SAP provides it's own scroll instead of utilising the browser window's scroll? If so, is there any way that I can disable it?
I am currently trying to run automation testing on a sample SAPUI5 application using Playwright(Similar to Puppeteer). I am trying to scroll to the bottom of the page. However, the function works on other websites except SAPUI5 applications.
My code is displayed below:
const playwright = require('playwright');
(async () => {
for (const browserType of ['chromium']) {
const browser = await playwright[browserType].launch({
headless: false
});
const context = await browser.newContext();
const page = await context.newPage();
await page.goto("https://sapui5.hana.ondemand./test-resources/sap/m/demokit/orderbrowser/webapp/test/mockServer.html?sap-ui-theme=sap_fiori_3");
await page.setViewport({
width: 1200,
height: 500
});
await page.waitFor(5000);
await page.waitForSelector("#__item0-__clone9-content");
await scrollOnElement(page,"#__item0-__clone9-content",0,300);
}
})();
async function scrollOnElement(page,selector,x,y) {
await page.evaluate(([selector, x, y]) => {
const element = document.querySelector(selector);
console.log(element);
element.scroll(x, y);
}, [selector, x, y]);
}
Is this because SAP provides it's own scroll instead of utilising the browser window's scroll? If so, is there any way that I can disable it?
Share Improve this question edited Jun 19, 2020 at 11:35 Boghyon Hoffmann 18.1k14 gold badges93 silver badges205 bronze badges asked Jun 19, 2020 at 9:35 SWarrSWarr 1591 gold badge3 silver badges9 bronze badges 01 Answer
Reset to default 4Element.scroll()
somehow does also not work in the Chrome DevTools. Does Element.scrollIntoView()
also work for your use case?
Then it would end up in something like this:
// @ts-check
const playwright = require('playwright');
(async () => {
const browser = await playwright.chromium.launch();
const context = await browser.newContext({
viewport: {
width: 1200,
height: 500
}
});
const page = await context.newPage();
await page.goto("https://sapui5.hana.ondemand./test-resources/sap/m/demokit/orderbrowser/webapp/test/mockServer.html?sap-ui-theme=sap_fiori_3#");
await page.waitForSelector("#__item0-__clone9-content");
await scrollOnElement(page, "#__item0-__clone9-content");
await page.screenshot({ path: "screenshot.png" })
})();
async function scrollOnElement(page, selector) {
await page.$eval(selector, (element) => {
element.scrollIntoView();
});
}
Interactive: https://try.playwright.tech/?s=jp8ng
本文标签: javascriptScrolling with PuppeteerPlaywright not working for SAPUI5 appStack Overflow
版权声明:本文标题:javascript - Scrolling with PuppeteerPlaywright not working for SAPUI5 app - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744964611a2634866.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论