这是一个CRM应用程序,我想关闭两个弹出窗口,一旦用户登录就会显示。我为每个弹出窗口创建了一个方法,我等待其框架检测并单击“关闭”图标以关闭弹出窗口。
以下是代码:
package base;
import java.awt.AWTException;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.testng.annotations.Test;
public class TC02_VerificationOfCustomerSearchPage extends TC01_LoginToRClaimsCRM{
@Test(priority = 0)
public void PendingEmailPopUPClose() throws InterruptedException, AWTException{
WebDriverWait wait = new WebDriverWait(driver, 30);
wait.until(ExpectedConditions.frameToBeAvailableAndSwitchToIt(By.xpath("//iframe[@name='InlineDialog1_Iframe']")));
//Close Pending Email pop-up.
driver.findElement(By.xpath("html/body/div[1]/div[2]/div[2]/button")).click();
Thread.sleep(1000);
driver.switchTo().frame("InlineDialog1_Iframe");
}
@Test(priority = 1)
public void MSCRMPopUPClose() throws InterruptedException, AWTException {
WebDriverWait wait = new WebDriverWait(driver, 30);
wait.until(ExpectedConditions.frameToBeAvailableAndSwitchToIt(By.xpath("//iframe[@id='InlineDialog_Iframe']")));
//Close MSCRM pop-up.
driver.findElement(By.xpath(".//*[@id='buttonClose']/div/img")).click();
Thread.sleep(1000);
driver.switchTo().defaultContent();
}