我的测试脚本是使用带有Selenium Web驱动程序api的Java开发的。有一种特殊的情况,我需要点击一个按钮,但我无法做到。以下是针对特定问题的测试步骤和屏幕截图。
-启动OWA(Outlook Web应用程序)-在日历中创建定期事件-转到日历并单击事件-弹出窗口显示2个按钮(屏幕截图)
-我需要点击这些按钮
按钮屏幕截图
我尝试过一些解决方案,如切换框架、处理警报框等,但都无济于事。
如何处理这样的对话框。
我在outlook应用程序中进行了测试。它执行得很好。
请找到编码,
public class testngchecktwo {
static WebDriver driver = new FirefoxDriver();
@Test
public void testa() throws InterruptedException {
driver.get("https://company.com/owa");
driver.manage().window().maximize();
driver.findElement(By.id("username")).sendKeys("me@company.com");
driver.findElement(By.id("password")).sendKeys("pass");
driver.findElement(By.xpath("//input[@value='Sign in']")).click();
Thread.sleep(5000);
//click clanedar icon
driver.findElement(By.xpath("//a[@id='lnkQlCal']/img")).click();
Thread.sleep(5000);
//switch to frame where events listed
driver.switchTo().frame("bLgAAAAA/GWQ3xtO0SIOqswLk6uH4AQDVKQ5oRivJSZbc9pQXHu/BAAAAbHJJAAAC");
//Click Enter to bring up that small popup instead double click in mouse
driver.findElement(By.xpath("//div[@id='divVisualTextContainer']")).sendKeys(Keys.ENTER);
//get hack to orginal window
driver.switchTo().defaultContent();
//click this occurance button
driver.findElement(By.xpath("//button[@id='btn0']")).click();
}
}