@Test( dataProvider = "testData", groups = {"Android"}) public void testChatWithFrontDesk( String email, String password, String chatName, String chatAdminEmail, String chatAdminPassword, String FirstMsg, String description) throws Throwable { Calendar cal = Calendar.getInstance(); String chatUrl = xlsChatFrontDesk.getCellValue("chatURL", "Value"); boolean res = false; try { TestEngine.testDescription.put(HtmlReportSupport.tc_name, description); String testMessage = "Test message " + cal.getTime(); System.out.println("Test message " + testMessage); handleRateAppPopUp(); navigateToMyAccount(); handleRateAppPopUp(); click(AccountPageLocators.logInButton, "logInButton"); login(email, password); handleRateAppPopUp(); navigateToHome(); handleRateAppPopUp(); // handelWelcomeDashboardDialog(); waitForElementPresent(HomePageLocators.chatWithFrontDeskButton, "chatWithFrontDeskButton"); click(HomePageLocators.chatWithFrontDeskButton, "chatWithFrontDeskButton"); if (isElementDisplayed(InHousePhoneLocators.textAreaForChat2)) { click(InHousePhoneLocators.textAreaForChat2, "textAreaForChat2"); type(InHousePhoneLocators.textAreaForChat2, testMessage, "textAreaForChat2"); waitForElementPresent(InHousePhoneLocators.sendButtonForChat2, "sendButtonForChat2"); click(InHousePhoneLocators.sendButtonForChat2, "sendButtonForChat2"); } else { waitForElementPresent(InHousePhoneLocators.textAreaForChat, "textAreaForChat"); click(InHousePhoneLocators.textAreaForChat, "textInputField"); type(InHousePhoneLocators.textAreaForChat, testMessage, "textInputField"); waitForElementPresent(InHousePhoneLocators.textAreaForChat, "textAreaForChat"); // click(InHousePhoneLocators.ChatNameInput, "ChatNameInput"); // type(InHousePhoneLocators.ChatNameInput, chatName, "ChatNameInput"); click(InHousePhoneLocators.sendButtonForChat, "sendButtonForChat"); } String replyMsg = GeneralHelper.FrontDeskChat( chatUrl, chatAdminEmail, chatAdminPassword, testMessage, FirstMsg); if (replyMsg != null) { if (isElementDisplayed(HomePageLocators.chatWithFrontDeskButton)) { click(HomePageLocators.chatWithFrontDeskButton, "chatWithFrontDeskButton"); } res = AndroidDriver2.getPageSource().contains(replyMsg); } System.out.println("resutl " + res); if (res) { Reporter.SuccessReport(description, " Successful"); System.out.println("successfully calling Front Desk "); } else { Reporter.failureReport(description, " Failed"); } } catch (Exception e) { e.printStackTrace(); Reporter.failureReport("LogIn", "Failed"); } }
@BeforeSuite(alwaysRun = true) public static void setupSuite(ITestContext ctx) throws Throwable { System.out.println("In Before sutie"); itc = ctx; groupNames = ctx.getCurrentXmlTest().getIncludedGroups().toString(); System.out.println("+++++" + groupNames); ReportStampSupport.calculateSuiteStartTime(); try { if (groupNames.contains("chrome")) { logger.info("chrome_browser : " + xlsrdr.getCellValue("chrome_browser", "value")); browser = xlsrdr.getCellValue("chrome_browser", "value"); System.out.println("browser " + browser); } else if (groupNames.contains("firefox")) { logger.info("firefox_browser : " + xlsrdr.getCellValue("firefox_browser", "value")); browser = xlsrdr.getCellValue("firefox_browser", "value"); } else if (groupNames.contains("ie")) { logger.info("ie_browser : " + xlsrdr.getCellValue("ie_browser", "value")); browser = xlsrdr.getCellValue("ie_browser", "value"); } else if (groupNames.contains("Android")) { logger.info("Android"); browser = "android"; } else if (groupNames.contains("Mobile")) { logger.info("iPhone"); browser = "iphone"; } else { logger.info("Starting browser : " + configProps.getProperty("browserType")); browser = configProps.getProperty("browserType"); } } catch (Exception e1) { e1.printStackTrace(); System.out.println(e1); } try { if (groupNames.toString().contains("afiliate")) { System.out.println("afiliate URL : " + xlsrdr.getCellValue("afiliate", "value")); url = (xlsrdr.getCellValue("afiliate", "value")); } else if (groupNames.contains("booking")) { System.out.println("booking URL : " + xlsrdr.getCellValue("booking", "value")); url = (xlsrdr.getCellValue("booking", "value")); } else if (groupNames.contains("referred")) { System.out.println("referred URL : " + xlsrdr.getCellValue("referred", "value")); url = (xlsrdr.getCellValue("referred", "value")); } else { url = (configProps.getProperty("URL")); } Reporter.reportCreater(); HtmlReportSupport.currentSuit = ctx.getCurrentXmlTest().getSuite().getName(); } catch (Exception e1) { e1.printStackTrace(); } if (browser.equalsIgnoreCase("iphone")) { try { // --------------------------------------------------- // System.out.println(System.getProperty("user.home")+"/Log/RPMob_" + timeStamp + ".log"); String logFile = System.getProperty("user.dir") + "/Logs/RPMob_" + System.currentTimeMillis() + ".log"; System.out.println("In iphone block"); /*while (true) { if (RedPlanetUtils.startAppiumForiOS(logFile)) { break; } } if ((new File(logFile).exists())) { System.out.println("Log File Created by Appium at path : " + System.getProperty("user.dir") + "/Log/RPMob_" + timeStamp + ".log"); } Thread.sleep(10000);*/ // ----------------------------------------------------- DeviceName = configProps.getProperty("iOSDeviceName"); String device = configProps.getProperty("Device"); String appPath = configProps.getProperty("appPath"); String ipaPath = configProps.getProperty("ipaPath"); String temp = System.getProperty("user.dir") + ipaPath; String temp2 = System.getProperty("user.dir") + appPath; File ipa = new File(temp); File app = new File(temp2); String platformVer = configProps.getProperty("platformVersion"); String udid = configProps.getProperty("UDID"); bundleID = configProps.getProperty("BundleID"); DesiredCapabilities capabilitiesForAppium = new DesiredCapabilities(); // System.out.println("DeviceName is : " + DeviceName); capabilitiesForAppium.setCapability("deviceName", device); capabilitiesForAppium.setCapability("platformName", "iOS"); capabilitiesForAppium.setCapability("platformVersion", platformVer); capabilitiesForAppium.setCapability("deviceName", device); capabilitiesForAppium.setCapability("bundleId", bundleID); capabilitiesForAppium.setCapability("newCommandTimeout", "8000"); capabilitiesForAppium.setCapability("takesScreenshot", true); capabilitiesForAppium.setCapability("autoWebviewTimeout", "8000"); capabilitiesForAppium.setCapability("locationServicesAuthorized", true); // capabilitiesForAppium.setCapability("autoLaunch", true); // capabilitiesForAppium.setCapability("fullReset", false); // capabilitiesForAppium.setCapability("noReset", true); capabilitiesForAppium.setCapability( "waitForAppScript", "target.elements().length > 0; $.delay(30000); $.acceptAlert();"); if ((DeviceName.contains("Simulator")) || ((udid.length() == 0))) { System.out.println("using simulator"); System.out.println("app Path " + app.getCanonicalPath()); capabilitiesForAppium.setCapability("app", app.getCanonicalPath()); } else { System.out.println("+++++using real device " + groupNames + "+++++"); capabilitiesForAppium.setCapability("udid", udid); System.out.println("ipa Path " + ipa.getCanonicalPath()); capabilitiesForAppium.setCapability("app", ipa); } Iosdriver = new IOSDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilitiesForAppium); driver = Iosdriver; driver.manage().timeouts().implicitlyWait(90, TimeUnit.SECONDS); } catch (Exception e) { e.printStackTrace(); } } else if (browser.equalsIgnoreCase("Android")) { try { String AppPackage = configProps.getProperty("appPackage"); String AppActivity = configProps.getProperty("appActivity"); String OSVersion = configProps.getProperty("OSVersion"); String ipkPath = configProps.getProperty("apkPath"); String tempIPK = System.getProperty("user.dir") + ipkPath; File ipk = new File(tempIPK); // --------------------------------------------------- // ----------------------------------------------------- DesiredCapabilities capabilitiesForAppium = new DesiredCapabilities(); System.out.println("DeviceName is : " + DeviceName); capabilitiesForAppium.setCapability("deviceName", DeviceName); capabilitiesForAppium.setCapability("platformVersion", OSVersion); capabilitiesForAppium.setCapability("platformName", "Android"); capabilitiesForAppium.setCapability("newCommandTimeout", "120000"); // capabilitiesForAppium.setCapability("autoWebview", "true"); capabilitiesForAppium.setCapability("autoWebviewTimeout", "1000"); // capabilitiesForAppium.setCapability("fullReset", true); capabilitiesForAppium.setCapability("appPackage", AppPackage); capabilitiesForAppium.setCapability("appActivity", AppActivity); System.out.println(ipk.getCanonicalPath()); capabilitiesForAppium.setCapability("app", ipk.getCanonicalPath()); AndroidDriver2 = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilitiesForAppium); driver = (AndroidDriver2); driver.manage().timeouts().implicitlyWait(70, TimeUnit.SECONDS); } catch (Exception e) { e.printStackTrace(); } } }