Source:
public void registerConnectInstance() throws InterruptedException { if (Locator.hasElementWithTimeout(By.id("intercom-container"), 3000)) { Locator.findElement(By.className("intercom-post-close")).click(); } WizardPage connectWizardPage = asPage(WizardPage.class); if (!Locator.hasElementWithTimeout(By.linkText("Register Your Instance"), 200)) { connectWizardPage.next(); return; } String mainWindowsHandle = driver.getWindowHandle(); ConnectWizardPage connectPage1 = connectWizardPage.getConnectPage(); assertNotNull(connectPage1); assertEquals(CONNECT_FORM_TITLE, connectPage1.getTitle()); ConnectWizardPage connectPage2 = connectPage1.submitWithError(); assertNotNull(connectPage2); assertTrue(connectPage2.getErrorMessage().startsWith("There were some errors in your form:")); ConnectRegistrationPage connectSignIn = connectPage1.openLink("click here") .asPage(ConnectRegistrationPage.class); AbstractTest.switchToPopup("sso"); driver.findElement(By.id("username")).sendKeys(CONNECT_LOGIN); driver.findElement(By.id("password")).sendKeys(getTestPassword()); String windowHandle = driver.getWindowHandle(); Locator.findElementWithTimeoutAndClick(By.cssSelector(".btn-submit")); try { Locator.waitUntilWindowClosed(windowHandle); } catch (TimeoutException e) { log.info("Unable to close SSO form once; try again"); Locator.findElementWithTimeoutAndClick(By.cssSelector(".btn-submit")); Locator.waitUntilWindowClosed(windowHandle); } switchToPopup("site/connect/wizardInstanceRegistration"); connectSignIn.selectOption("project", CONNECT_PROJECT_SELECTOR_UUID); connectSignIn.submit(); driver.switchTo().window(mainWindowsHandle); Thread.sleep(1000); String currentUrl = driver.getCurrentUrl(); if (!currentUrl.contains("PackagesSelection")) { Locator.waitUntilURLDifferentFrom(currentUrl); } }

Target:
public void registerConnectInstance() throws InterruptedException { WizardPage connectWizardPage = asPage(WizardPage.class); if (!Locator.hasElementWithTimeout(By.linkText("Register Your Instance"), 200)) { connectWizardPage.next(); return; } String mainWindowsHandle = driver.getWindowHandle(); ConnectWizardPage connectPage1 = connectWizardPage.getConnectPage(); assertNotNull(connectPage1); assertEquals(CONNECT_FORM_TITLE, connectPage1.getTitle()); ConnectWizardPage connectPage2 = connectPage1.submitWithError(); assertNotNull(connectPage2); assertTrue(connectPage2.getErrorMessage().startsWith("There were some errors in your form:")); ConnectRegistrationPage connectSignIn = connectPage1.openLink("click here") .asPage(ConnectRegistrationPage.class); AbstractTest.switchToPopup("sso"); driver.findElement(By.id("username")).sendKeys(CONNECT_LOGIN); driver.findElement(By.id("password")).sendKeys(getTestPassword()); String windowHandle = driver.getWindowHandle(); Locator.findElementWithTimeoutAndClick(By.cssSelector(".btn-submit")); try { Locator.waitUntilWindowClosed(windowHandle); } catch (TimeoutException e) { log.info("Unable to close SSO form once; try again"); Locator.findElementWithTimeoutAndClick(By.cssSelector(".btn-submit")); Locator.waitUntilWindowClosed(windowHandle); } switchToPopup("site/connect/wizardInstanceRegistration"); connectSignIn.selectOption("project", CONNECT_PROJECT_SELECTOR_UUID); connectSignIn.submit(); driver.switchTo().window(mainWindowsHandle); Thread.sleep(1000); String currentUrl = driver.getCurrentUrl(); if (!currentUrl.contains("PackagesSelection")) { Locator.waitUntilURLDifferentFrom(currentUrl); } }