我有这样的页面源代码:
<header style="position: fixed;">
当我在java上使用脚本时,我无法执行单击操作,因为我的元素位于标题下方。我有一个错误:
Element is not clickable at point (482, 10.116668701171875). Other element would receive the click...
我需要将页面的源代码更改为下一个 View :
<header style="position: absolute;">
最佳答案
要在第一个 header 标记上设置样式属性:
((JavascriptExecutor)driver).executeScript(
"document.getElementsByTagName('header')[0].style='position: absolute;'");
但更好的解决方案是将元素滚动到顶部或底部:
((JavascriptExecutor)driver).executeScript(
"arguments[0].scrollIntoView(true);", element);
关于java - 如何更改页面源代码?使用 Selenium 和java,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36286102/