【发布时间】:2015-02-09 02:09:13
【问题描述】:
我需要使用 Selenium 在新窗口中打开一个链接。我找到了以下 2 个(假设我们是 WebElement 并且我已经找到了它并且 myWait 只执行了 x 毫秒的等待):
1)
Actions act = new Actions(driver);
act.contextClick(we).perform();
myWait(1000); // allow the menu to come up
act.sendKeys(which).perform();
2)
we.sendKeys(Keys.CONTROL + "t");
在#1 中,我看到菜单出现了,但是sendKeys 不起作用(哦,顺便说一下,sendKeys 中的“which”是“t”)。在 #2 中它只是忽略它。
#1 中的菜单是否已经出现在新窗口中?我必须driver.switchTo()吗?如果不是,我做错了什么?
另外,还有其他方法吗? we 是 <a href=blah> 形式的元素,并且可以正常点击打开。
【问题讨论】: