Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/395.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何在selenium中拖放弹出窗口?_Javascript_Java_Selenium_Selenium Webdriver_Popupwindow - Fatal编程技术网

Javascript 如何在selenium中拖放弹出窗口?

Javascript 如何在selenium中拖放弹出窗口?,javascript,java,selenium,selenium-webdriver,popupwindow,Javascript,Java,Selenium,Selenium Webdriver,Popupwindow,我有一个弹出窗口,双击一个对象就会打开,我需要将弹出窗口拖放到另一个位置,以便查看隐藏在弹出窗口后面的内容。我已尝试使用以下代码: WebElement notesWindow= getNotesWindow(); JavascriptExecutor executor = (JavascriptExecutor) driver; executor.executeScript("arguments[0].setAttribute('style', 'left: 227px; top: 334px

我有一个弹出窗口,双击一个对象就会打开,我需要将弹出窗口拖放到另一个位置,以便查看隐藏在弹出窗口后面的内容。我已尝试使用以下代码:

WebElement notesWindow= getNotesWindow();
JavascriptExecutor executor = (JavascriptExecutor) driver;
executor.executeScript("arguments[0].setAttribute('style', 'left: 227px; top: 334px; width: 561px; height: 392px; z-index: 801637');", notesWindow);
这会移动窗口的外部边界,但无法按原样移动整个窗口

我也试过了

Actions action = new Actions(driver);
action.dragAndDrop(notesWindow, getOverrideButton());
在这里,
getOverrideButton()
将元素返回到目标元素。
这根本不起作用。有人能建议一下如何使它工作吗?

哦,你不能拖放窗口本身-只有HTML元素。您应该告诉Selenium使用WebDriver上的
switchTo()
方法切换窗口以切换到另一个窗口或iframe。

您可以共享站点URL吗?到目前为止,我在Selenium中没有找到解决方案。所以我想你是对的!这就是我们在公司里的做法。适用于多个窗口。Selenium只能访问当前窗口的DOM。是否有另一个窗口覆盖活动窗口并不重要。