1 package vid.automation.test.sections;
3 import org.junit.Assert;
4 import org.onap.sdc.ci.tests.utilities.GeneralUIUtils;
5 import org.openqa.selenium.ElementClickInterceptedException;
6 import org.openqa.selenium.UnhandledAlertException;
7 import org.slf4j.Logger;
8 import org.slf4j.LoggerFactory;
9 import vid.automation.test.Constants;
11 public class SideMenu {
12 static final Logger logger = LoggerFactory.getLogger(SideMenu.class);
14 public static void navigateToBrowseASDCPage() {
15 navigateToPage(Constants.SideMenu.BROWSE_ASDC_SERVICE_MODELS);
18 public static void navigateToSearchExistingPage() {
19 navigateToPage(Constants.SideMenu.SEARCH_EXISTING_SERVICE);
22 public static void navigateToCreateNewServicePage() {
23 navigateToPage(Constants.SideMenu.CREATE_NEW_SERVICE);
26 public static void navigateToTestEnvironmentsPage() {
27 navigateToPage(Constants.SideMenu.TEST_ENVIRONMENTS);
30 public static void navigateToMacroInstantiationStatus() {
31 navigateToPage("Instantiation Status");
32 new VidBasePage().goToIframe();
35 private static void navigateToPage(String PageName) {
37 boolean findAndWaitByText = GeneralUIUtils.findAndWaitByText(PageName, 30);
39 if (!findAndWaitByText) {
40 doEvenIfAlertIsShown(SideMenu::navigateToWelcomePage);
41 findAndWaitByText = GeneralUIUtils.findAndWaitByText(PageName, 10);
44 Assert.assertTrue(findAndWaitByText);
45 doEvenIfAlertIsShown(() -> {
47 GeneralUIUtils.clickOnElementByText(PageName, 50);
48 } catch (ElementClickInterceptedException e) {
49 navigateToWelcomePage();
50 GeneralUIUtils.clickOnElementByText(PageName, 100);
53 GeneralUIUtils.ultimateWait();
54 logger.info("navigated to {}", PageName);
57 public static void navigateToWelcomePage() {
58 doEvenIfAlertIsShown(() -> {
59 VidBasePage base = new VidBasePage();
60 base.navigateTo("welcome.htm");
64 private static void doEvenIfAlertIsShown(Runnable runnable) {
67 } catch (UnhandledAlertException e) {
68 // an alert popup was shown; dismiss it if it's still there
70 GeneralUIUtils.getDriver().switchTo().alert().dismiss();
71 } catch (org.openqa.selenium.NoAlertPresentException e2) {