我有一个双击对象时打开的弹出窗口,我需要将弹出窗口拖放到另一个位置,以便将内容隐藏在弹出窗口后面。我尝试使用以下代码:
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()
将元素返回到目标元素。
这根本不起作用。有人可以建议可以做些什么让它起作用?
答案 0 :(得分:0)
Imho,你不能拖放窗口本身 - 只有HTML元素。您应该告诉Selenium使用WebDriver上的switchTo()
方法切换窗口以切换到另一个窗口或iframe。