【发布时间】:2022-09-27 17:33:50
【问题描述】:
Testcafe 脚本在 Firefox 浏览器上运行良好,但在 chrome 浏览器上运行失败。我们确定的原因是 \'当应用程序在 Firefox 浏览器上打开时,testcafe 本身会向下滚动到该元素并对该元素执行操作。但是在 chrome testcafe 本身不能向下滚动并抛出错误“指定的选择器与 DOM 树中的任何元素都不匹配”。我们甚至试图强制向下滚动直到元素,但它没有工作。
我们尝试过的以下 testcafe 功能如下所述:-
- 滚动
- ScrollIntoView
- 滚动
- 关键事件
- 悬停
- 鼠标按下事件
我们尝试的代码片段如下所述:
1. const scrollBy = ClientFunction((x, y) => { window.scrollBy(x, y); }); const targetElementPosition = Selector(\'#id\'); await scrollBy(0, targetElementPosition); 2.const target = Selector(\'#id\'); await t.scrollIntoView(target); 3. await t.scrollBy(0, #id); 4. await t.scrollIntoView(#id) 5. await t.pressKey(\'pagedown\') 6. await t.hover(\'#id\') 7. const target =Selector(\'#id\'); await t.scrollIntoView(target); 8. var el = Selector(document.getElementById(id)); el.scrollIntoView(true); 9. const target = Selector(\'#target\'); await t .dispatchEvent(target, \'mousedown\') .wait(5000)请为此问题提出解决方案。任何帮助,将不胜感激。先感谢您!!
标签: javascript testing automated-tests scrollbar testcafe