【发布时间】:2011-10-11 07:56:01
【问题描述】:
我正在为我们的生产站点自动执行基于“添加员工”表单的测试。当输入已经存在的 id 或 email 或 name 时,会弹出一个服务错误,显示该员工无法注册。即使出现了这个框,测试也通过了:(。我尝试在我的代码中使用 driver.switchTo().alert() 函数。这就是发生的事情:
Alert alert=driver.switchTo().alert();
String text=alert.getText();
System.out.println(text);
使用 Firefox 7 + Selenium WebDriver 2.8.0:
org.openqa.selenium.NoAlertPresentException: No alert is present (WARNING: The server did not provide any stacktrace information); duration or timeout: 2.11 seconds
Build info: version: '2.8.0', revision: '14056', time: '2011-10-06 12:41:48'
System info: os.name: 'Linux', os.arch: 'amd64', os.version: '2.6.37.6-0.7-desktop', java.version: '1.6.0_26'
Driver info: driver.version: RemoteWebDriver
使用 Chrome + Web 驱动程序:
[1011/131949:ERROR:automation_json_requests.cc(59)] JSON request failed: GetAppModalDialogMessage
with error: No modal dialog is showing
错误快照:
问题:
如果我没有得到对话框的文本,那很好。这是唯一会出现的警报。所以,只要知道警报出现就可以解决我的问题。但是,这两件事都说不存在警报/模式对话框:(
谢谢。
编辑:我也试过这个:
Selenium selenium=new WebDriverBackedSelenium(driver,baseUrl);
System.out.println(selenium.isAlertPresent());
这给出了错误。不是警告框吗?它也不是模态对话框吗?如果不是这些东西,我如何在页面上找到它的存在?
【问题讨论】: