英文:
How to handle Firefox browser confirmation messages in Test Automation?
问题
我目前正在进行selenium+java的测试自动化项目。
我遇到了一个问题,就是在testng.xml中一起运行许多测试类时,火狐浏览器会显示确认重新提交的弹窗。但是当我只运行单个类时,不会弹出此消息。这个确认弹窗出现在最后一组类开始运行时。我该如何解决这个问题?
英文:
I am currently working on the selenium+java test automation project.
I have encountered a problem that while running many test classes together in testng.xml, firefox display
confirm resubmission popup. when I am running a single class this message does not popup. This confirmation popup comes when the last set of classes begins to run. How can I resolve this problem?
答案1
得分: 0
也许,你可以尝试模拟按下回车键或空格键,看看是否起作用。
import java.awt.Robot;
import java.awt.event.KeyEvent;
public void pressEsc(WebDriver driver) {
try {
Robot robot = new Robot();
robot.keyPress(KeyEvent.VK_ENTER);
robot.keyRelease(KeyEvent.VK_ENTER);
} catch (Exception e) {
e.printStackTrace();
}
}
英文:
May be, you can try to simulate pressing Enter key or Spacebar and see if that works.
import java.awt.Robot;
import java.awt.event.KeyEvent;
public void pressEsc(WebDriver driver) {
try {
Robot robot = new Robot();
robot.keyPress(KeyEvent.VK_ENTER);
robot.keyRelease(KeyEvent.VK_ENTER);
} catch (Exception e) {
e.printStackTrace(); }
}
专注分享java语言的经验与见解,让所有开发者获益!
评论