How to use isNull method of com.qaprosoft.carina.core.foundation.utils.Configuration class

Best Carina code snippet using com.qaprosoft.carina.core.foundation.utils.Configuration.isNull

Source:AbstractTest.java Github

copy

Full Screen

...143 LOGGER.debug("Default data_provider_thread_count="144 + context.getCurrentXmlTest().getSuite().getDataProviderThreadCount());145 LOGGER.debug("Updated data_provider_thread_count="146 + context.getCurrentXmlTest().getSuite().getDataProviderThreadCount());147 if (!Configuration.isNull(Parameter.URL)) {148 if (!Configuration.get(Parameter.URL).isEmpty()) {149 RestAssured.baseURI = Configuration.get(Parameter.URL);150 }151 }152 try {153 L10N.init();154 } catch (Exception e) {155 LOGGER.error("L10N bundle is not initialized successfully!", e);156 }157 try {158 I18N.init();159 } catch (Exception e) {160 LOGGER.error("I18N bundle is not initialized successfully!", e);161 }162 try {163 L10Nparser.init();164 } catch (Exception e) {165 LOGGER.error("L10Nparser bundle is not initialized successfully!", e);166 }167 try {168 TestRail.updateBeforeSuite(context, this.getClass().getName(), getTitle(context));169 } catch (Exception e) {170 LOGGER.error("TestRail is not initialized successfully!", e);171 }172 try {173 if (!Configuration.get(Parameter.ACCESS_KEY_ID).isEmpty()) {174 LOGGER.info("Initializing AWS S3 client...");175 AmazonS3Manager.getInstance().initS3client(Configuration.get(Parameter.ACCESS_KEY_ID),176 Configuration.get(Parameter.SECRET_KEY));177 updateS3AppPath();178 }179 } catch (Exception e) {180 LOGGER.error("AWS S3 client is not initialized successfully!", e);181 }182 183 // moved from UITest->executeBeforeTestSuite184 String customCapabilities = Configuration.get(Parameter.CUSTOM_CAPABILITIES);185 if (!customCapabilities.isEmpty()) {186 //redefine core properties using custom capabilities file187 Map<String, String> properties = Configuration.loadCoreProperties(customCapabilities);188 //reregister device if mobile core properties are redefined 189 DevicePool.addDevice(properties);190 }191 }192 193 @BeforeClass(alwaysRun = true)194 public void executeBeforeTestClass(ITestContext context) throws Throwable {195 // do nothing for now196 }197 @AfterClass(alwaysRun = true)198 public void executeAfterTestClass(ITestContext context) throws Throwable {199 if (Configuration.getDriverMode() == DriverMode.CLASS_MODE) {200 LOGGER.debug("Deinitialize driver(s) in UITest->AfterClass.");201 quitDrivers();202 }203 }204 @BeforeMethod(alwaysRun = true)205 public void executeBeforeTestMethod(XmlTest xmlTest, Method testMethod,206 ITestContext context) throws Throwable {207 // do nothing for now208 Spira.registerStepsFromAnnotation(testMethod);209 210 apiMethodBuilder = new APIMethodBuilder();211 }212 213 214 @AfterMethod(alwaysRun = true)215 public void executeAfterTestMethod(ITestResult result) {216 try {217 DriverMode driverMode = Configuration.getDriverMode();218 if (driverMode == DriverMode.METHOD_MODE) {219 LOGGER.debug("Deinitialize driver(s) in @AfterMethod.");220 quitDrivers();221 }222 // TODO: improve later removing duplicates with AbstractTestListener223 //handle Zafira already passed exception for re-run and do nothing. maybe return should be enough224 if (result.getThrowable() != null && result.getThrowable().getMessage() != null225 && result.getThrowable().getMessage().startsWith(SpecialKeywords.ALREADY_PASSED)) {226 // [VD] it is prohibited to release TestInfoByThread in this place.!227 return;228 }229 //handle AbstractTest->SkipExecution230 if (result.getThrowable() != null && result.getThrowable().getMessage() != null231 && result.getThrowable().getMessage().startsWith(SpecialKeywords.SKIP_EXECUTION)) {232 // [VD] it is prohibited to release TestInfoByThread in this place.!233 return;234 }235 String test = TestNamingUtil.getCanonicalTestName(result);236 List<String> tickets = Jira.getTickets(result);237 result.setAttribute(SpecialKeywords.JIRA_TICKET, tickets);238 Jira.updateAfterTest(result);239 // Populate Spira Steps240 Spira.updateAfterTest(result, (String) result.getTestContext().getAttribute(SpecialKeywords.TEST_FAILURE_MESSAGE), tickets);241 Spira.clear();242 // Populate TestRail Cases243 if (!R.ZAFIRA.getBoolean("zafira_enabled")){244 result.setAttribute(SpecialKeywords.TESTRAIL_CASES_ID, TestRail.getCases(result));245 TestRail.updateAfterTest(result, (String) result.getTestContext().getAttribute(SpecialKeywords.TEST_FAILURE_MESSAGE));246 TestRail.clearCases();247 }248 //we shouldn't deregister info here as all retries will not work249 //TestNamingUtil.releaseZafiraTest();250 // clear jira tickets to be sure that next test is not affected.251 Jira.clearTickets();252 Artifacts.clearArtifacts();253 try {254 ThreadLogAppender tla = (ThreadLogAppender) Logger.getRootLogger().getAppender("ThreadLogAppender");255 if (tla != null) {256 tla.closeResource(test);257 }258 } catch (NoSuchMethodError e) {259 LOGGER.error("Unable to redefine logger level due to the conflicts between log4j and slf4j!");260 }261 } catch (Exception e) {262 LOGGER.error("Exception in AbstractTest->executeAfterTestMethod: " + e.getMessage());263 e.printStackTrace();264 }265 }266 @AfterSuite(alwaysRun = true)267 public void executeAfterTestSuite(ITestContext context) {268 try {269 if (Configuration.getDriverMode() == DriverMode.SUITE_MODE) {270 LOGGER.debug("Deinitialize driver(s) in UITest->AfterSuite.");271 quitDrivers(); 272 }273 ReportContext.removeTempDir(); //clean temp artifacts directory274 HtmlReportGenerator.generate(ReportContext.getBaseDir().getAbsolutePath());275 String browser = getBrowser();276 String deviceName = getDeviceName();277 String suiteName = getSuiteName(context);278 String title = getTitle(context);279 TestResultType testResult = EmailReportGenerator.getSuiteResult(EmailReportItemCollector.getTestResults());280 String status = testResult.getName();281 title = status + ": " + title;282 String env = "";283 if (!Configuration.isNull(Parameter.ENV)) {284 env = Configuration.get(Parameter.ENV);285 }286 if (!Configuration.get(Parameter.URL).isEmpty()) {287 env += " - <a href='" + Configuration.get(Parameter.URL) + "'>" + Configuration.get(Parameter.URL) + "</a>";288 }289 ReportContext.getTempDir().delete();290 // Update JIRA291 Jira.updateAfterSuite(context, EmailReportItemCollector.getTestResults());292 // Update Spira293 Spira.updateAfterSuite(this.getClass().getName(), testResult, title + "; " + getCIJobReference(), suiteName, startDate);294 //generate and send email report by Zafira to test group of people295 String emailList = Configuration.get(Parameter.EMAIL_LIST);296 String failureEmailList = Configuration.get(Parameter.FAILURE_EMAIL_LIST);297 String senderEmail = Configuration.get(Parameter.SENDER_EMAIL);298 String senderPassword = Configuration.get(Parameter.SENDER_PASSWORD);299 // Generate and send email report using regular method300 EmailReportGenerator report = new EmailReportGenerator(title, env,301 Configuration.get(Parameter.APP_VERSION), deviceName,302 browser, DateUtils.now(), DateUtils.timeDiff(startDate), getCIJobReference(),303 EmailReportItemCollector.getTestResults(),304 EmailReportItemCollector.getCreatedItems());305 String emailContent = report.getEmailBody();306 307 if (!R.ZAFIRA.getBoolean("zafira_enabled")) {308 //Do not send email if run is running with enabled Zafira309 EmailManager.send(title, emailContent,310 emailList,311 senderEmail,312 senderPassword);313 314 if (testResult.equals(TestResultType.FAIL) && !failureEmailList.isEmpty()) {315 EmailManager.send(title, emailContent,316 failureEmailList,317 senderEmail,318 senderPassword);319 }320 }321 // Store emailable report under emailable-report.html322 ReportContext.generateHtmlReport(emailContent);323 printExecutionSummary(EmailReportItemCollector.getTestResults());324 TestResultType suiteResult = EmailReportGenerator.getSuiteResult(EmailReportItemCollector.getTestResults());325 switch (suiteResult) {326 case SKIP_ALL:327 Assert.fail("All tests were skipped! Analyze logs to determine possible configuration issues.");328 break;329 case SKIP_ALL_ALREADY_PASSED:330 LOGGER.info("Nothing was executed in rerun mode because all tests already passed and registered in Zafira Repoting Service!");331 break;332 default:333 //do nothing334 }335 336 } catch (Exception e) {337 LOGGER.error("Exception in AbstractTest->executeAfterSuite: " + e.getMessage());338 e.printStackTrace();339 }340 }341 private String getDeviceName() {342 String deviceName = "Desktop";343 if (Configuration.get(Parameter.DRIVER_TYPE).toLowerCase().contains(SpecialKeywords.MOBILE)) {344 //Samsung - Android 4.4.2; iPhone - iOS 7345 String deviceTemplate = "%s - %s %s";346 deviceName = String.format(deviceTemplate, Configuration.get(Parameter.MOBILE_DEVICE_NAME), Configuration.get(Parameter.MOBILE_PLATFORM_NAME), Configuration.get(Parameter.MOBILE_PLATFORM_VERSION));347 }348 return deviceName;349 }350 protected String getBrowser() {351 String browser = "";352 if (!Configuration.get(Parameter.BROWSER).isEmpty()) {353 browser = Configuration.get(Parameter.BROWSER);354 }355 if (!browserVersion.isEmpty()) {356 browser = browser + " " + browserVersion;357 }358 return browser;359 }360 protected String getTitle(ITestContext context) {361 String browser = getBrowser();362 if (!browser.isEmpty()) {363 browser = " " + browser; //insert the space before364 }365 String device = getDeviceName();366 String env = !Configuration.isNull(Parameter.ENV) ? Configuration.get(Parameter.ENV) : Configuration.get(Parameter.URL);367 String title = "";368 String app_version = "";369 if (!Configuration.get(Parameter.APP_VERSION).isEmpty()) {370 // if nothing is specified then title will contain nothing371 app_version = Configuration.get(Parameter.APP_VERSION) + " - ";372 }373 String suiteName = getSuiteName(context);374 String xmlFile = getSuiteFileName(context);375 title = String.format(SUITE_TITLE, app_version, suiteName, String.format(XML_SUITE_NAME, xmlFile), env, device, browser);376 return title;377 }378 private String getSuiteFileName(ITestContext context) {379 String fileName = context.getSuite().getXmlSuite().getFileName();380 LOGGER.debug("Full suite file name: " + fileName);381 if (fileName.contains("\\")) {382 fileName = fileName.replaceAll("\\\\", "/");383 }384 fileName = StringUtils.substringAfterLast(fileName, "/");385 LOGGER.debug("Short suite file name: " + fileName);386 return fileName;387 }388 protected String getSuiteName(ITestContext context) {389 String suiteName = "";390 if (context.getSuite().getXmlSuite() != null && !"Default suite".equals(context.getSuite().getXmlSuite().getName())) {391 suiteName = Configuration.get(Parameter.SUITE_NAME).isEmpty() ? context.getSuite().getXmlSuite().getName()392 : Configuration.get(Parameter.SUITE_NAME);393 } else {394 suiteName = Configuration.get(Parameter.SUITE_NAME).isEmpty() ? R.EMAIL.get("title") : Configuration.get(Parameter.SUITE_NAME);395 }396 String appender = getSuiteNameAppender();397 if (appender != null && !appender.isEmpty()) {398 suiteName = suiteName + " - " + appender;399 }400 return suiteName;401 }402 protected void setSuiteNameAppender(String appender) {403 suiteNameAppender.set(appender);404 }405 protected String getSuiteNameAppender() {406 return suiteNameAppender.get();407 }408 private void printExecutionSummary(List<TestResultItem> tris) {409 Messager.INROMATION410 .info("**************** Test execution summary ****************");411 int num = 1;412 for (TestResultItem tri : tris) {413 String failReason = tri.getFailReason();414 if (failReason == null) {415 failReason = "";416 }417 if (!tri.isConfig() && !failReason.contains(SpecialKeywords.ALREADY_PASSED)418 && !failReason.contains(SpecialKeywords.SKIP_EXECUTION)) {419 String reportLinks = !StringUtils.isEmpty(tri.getLinkToScreenshots())420 ? "screenshots=" + tri.getLinkToScreenshots() + " | " : "";421 reportLinks += !StringUtils.isEmpty(tri.getLinkToLog()) ? "log=" + tri.getLinkToLog() : "";422 Messager.TEST_RESULT.info(String.valueOf(num++), tri.getTest(), tri.getResult().toString(),423 reportLinks);424 }425 }426 }427 private String getCIJobReference() {428 String ciTestJob = null;429 if (!Configuration.isNull(Parameter.CI_URL)430 && !Configuration.isNull(Parameter.CI_BUILD)) {431 ciTestJob = Configuration.get(Parameter.CI_URL)432 + Configuration.get(Parameter.CI_BUILD);433 }434 return ciTestJob;435 }436 /**437 * Redefine Jira tickets from test.438 *439 * @param tickets to set440 */441 @Deprecated442 protected void setJiraTicket(String... tickets) {443 List<String> jiraTickets = new ArrayList<String>();444 for (String ticket : tickets) {...

Full Screen

Full Screen

Source:Device.java Github

copy

Full Screen

...142 }143 throw new RuntimeException("Incorrect driver type. Please, check config file.");144 }145 146 public boolean isNull() {147 if (name == null || seleniumServer == null) {148 return true;149 }150 return name.isEmpty() || seleniumServer.isEmpty();151 }152 public int startRecording(String pathToFile) {153 if (!Configuration.getBoolean(Parameter.VIDEO_RECORDING)) {154 return -1;155 }156 157 if (this.isNull())158 return -1;159 160 dropFile(pathToFile);161 String[] cmd = CmdLine.insertCommandsAfter(executor.getDefaultCmd(), "-s", getUdid(), "shell", "screenrecord", "--bit-rate", "1000000", "--verbose", pathToFile);162 try {163 ProcessBuilderExecutor pb = new ProcessBuilderExecutor(cmd);164 pb.start();165 return pb.getPID();166 } catch (ExecutorException e) {167 e.printStackTrace();168 return -1;169 }170 }171 172 public void stopRecording(Integer pid) {173 if (isNull())174 return;175 176 if (pid != null && pid != -1) {177 Platform.killProcesses(Arrays.asList(pid));178 }179 }180 181 public void dropFile(String pathToFile) {182 if (this.isNull())183 return;184 String[] cmd = CmdLine.insertCommandsAfter(executor.getDefaultCmd(), "-s", getUdid(), "shell", "rm", pathToFile);185 executor.execute(cmd);186 }187 188 public String getFullPackageByName(final String name) {189 String deviceUdid = getUdid();190 LOGGER.info("Device udid: ".concat(deviceUdid));191 String[] cmd = CmdLine.createPlatformDependentCommandLine("adb", "-s", deviceUdid, "shell", "pm", "list",192 "packages");193 LOGGER.info("Following cmd will be executed: " + Arrays.toString(cmd));194 List<String> packagesList = executor.execute(cmd);195 LOGGER.info("Found packages: ".concat(packagesList.toString()));196 String resultPackage = null;197 for (String packageStr : packagesList) {198 if (packageStr.matches(String.format(".*%s.*", name))) {199 LOGGER.info("Package was found: ".concat(packageStr));200 resultPackage = packageStr;201 break;202 }203 }204 if (null == resultPackage) {205 LOGGER.info("Package wasn't found using following name: "206 .concat(name));207 resultPackage = "not found";208 }209 return resultPackage;210 }211 212 public void pullFile(String pathFrom, String pathTo) {213 if (isNull())214 return;215 String[] cmd = CmdLine.insertCommandsAfter(executor.getDefaultCmd(), "-s", getUdid(), "pull", pathFrom, pathTo);216 executor.execute(cmd);217 }218 219 220 221 private Boolean getScreenState() {222 // determine current screen status223 // adb -s <udid> shell dumpsys input_method | find "mScreenOn"224 String[] cmd = CmdLine.insertCommandsAfter(executor.getDefaultCmd(), "-s", getUdid(), "shell", "dumpsys",225 "input_method");226 List<String> output = executor.execute(cmd);227 Boolean screenState = null;228 String line;229 Iterator<String> itr = output.iterator();230 while (itr.hasNext()) {231 // mScreenOn - default value for the most of Android devices232 // mInteractive - for Nexuses233 line = itr.next();234 if (line.contains("mScreenOn=true") || line.contains("mInteractive=true")) {235 screenState = true;236 break;237 }238 if (line.contains("mScreenOn=false") || line.contains("mInteractive=false")) {239 screenState = false;240 break;241 }242 }243 if (screenState == null) {244 LOGGER.error(udid245 + ": Unable to determine existing device screen state!");246 return screenState; //no actions required if state is not recognized.247 }248 if (screenState) {249 LOGGER.info(udid + ": screen is ON");250 }251 if (!screenState) {252 LOGGER.info(udid + ": screen is OFF");253 }254 return screenState;255 }256 public void screenOff() {257 if (!Configuration.get(Parameter.MOBILE_PLATFORM_NAME).equalsIgnoreCase(SpecialKeywords.ANDROID)) {258 return;259 }260 if (!Configuration.getBoolean(Parameter.MOBILE_SCREEN_SWITCHER)) {261 return;262 }263 264 if (isNull())265 return;266 Boolean screenState = getScreenState();267 if (screenState == null) {268 return;269 }270 if (screenState) {271 String[] cmd = CmdLine.insertCommandsAfter(executor.getDefaultCmd(), "-s", getUdid(), "shell", "input",272 "keyevent", "26");273 executor.execute(cmd);274 pause(5);275 screenState = getScreenState();276 if (screenState) {277 LOGGER.error(udid + ": screen is still ON!");278 }279 if (!screenState) {280 LOGGER.info(udid + ": screen turned off.");281 }282 }283 }284 public void screenOn() {285 if (!Configuration.get(Parameter.MOBILE_PLATFORM_NAME).equalsIgnoreCase(SpecialKeywords.ANDROID)) {286 return;287 }288 if (!Configuration.getBoolean(Parameter.MOBILE_SCREEN_SWITCHER)) {289 return;290 }291 if (isNull())292 return;293 294 Boolean screenState = getScreenState();295 if (screenState == null) {296 return;297 }298 if (!screenState) {299 String[] cmd = CmdLine.insertCommandsAfter(executor.getDefaultCmd(), "-s", getUdid(), "shell",300 "input", "keyevent", "26");301 executor.execute(cmd);302 pause(5);303 // verify that screen is Off now304 screenState = getScreenState();305 if (!screenState) {306 LOGGER.error(udid + ": screen is still OFF!");307 }308 if (screenState) {309 LOGGER.info(udid + ": screen turned on.");310 }311 }312 }313 314 public void pressKey(int key) {315 if (isNull())316 return;317 String[] cmd = CmdLine.insertCommandsAfter(executor.getDefaultCmd(), "-s", getUdid(), "shell", "input",318 "keyevent", String.valueOf(key));319 executor.execute(cmd);320 }321 322 public void pause(long timeout) {323 try {324 Thread.sleep(timeout * 1000);325 } catch (InterruptedException e) {326 e.printStackTrace();327 }328 }329 330 public void clearAppData() {331 clearAppData(Configuration.get(Parameter.MOBILE_APP));332 }333 334 public void clearAppData(String app) {335 if (!Configuration.get(Parameter.MOBILE_PLATFORM_NAME).equalsIgnoreCase(SpecialKeywords.ANDROID)) {336 return;337 }338 339 if (!Configuration.getBoolean(Parameter.MOBILE_APP_CLEAR_CACHE))340 return;341 if (isNull())342 return;343 //adb -s UDID shell pm clear com.myfitnesspal.android344 String packageName = getApkPackageName(app);345 String[] cmd = CmdLine.insertCommandsAfter(executor.getDefaultCmd(), "-s", getUdid(), "shell", "pm", "clear", packageName);346 executor.execute(cmd);347 }348 349 public String getApkPackageName(String apkFile) {350 // aapt dump badging <apk_file> | grep versionCode351 // aapt dump badging <apk_file> | grep versionName352 // output:353 // package: name='com.myfitnesspal.android' versionCode='9025' versionName='develop-QA' platformBuildVersionName='6.0-2704002'354 String[] cmd = CmdLine.insertCommandsAfter("aapt dump badging".split(" "), apkFile);355 List<String> output = executor.execute(cmd);356 // parse output command and get appropriate data357 String packageName = "";358 for (String line : output) {359 if (line.contains("versionCode") && line.contains("versionName")) {360 LOGGER.debug(line);361 String[] outputs = line.split("'");362 packageName = outputs[1]; //package363 }364 }365 return packageName;366 }367 368 public void uninstallApp(String packageName) {369 if (isNull())370 return;371 //adb -s UDID uninstall com.myfitnesspal.android372 String[] cmd = CmdLine.insertCommandsAfter(executor.getDefaultCmd(), "-s", getUdid(), "uninstall", packageName);373 executor.execute(cmd);374 }375 public void installApp(String packageName) {376 if (isNull())377 return;378 //adb -s UDID install com.myfitnesspal.android379 String[] cmd = CmdLine.insertCommandsAfter(executor.getDefaultCmd(), "-s", getUdid(), "install", "-r", packageName);380 executor.execute(cmd);381 }382 public synchronized void installAppSync(String packageName) {383 if (isNull())384 return;385 //adb -s UDID install com.myfitnesspal.android386 String[] cmd = CmdLine.insertCommandsAfter(executor.getDefaultCmd(), "-s", getUdid(), "install", "-r", packageName);387 executor.execute(cmd);388 }389 390 public void reinstallApp() {391 if (!Configuration.get(Parameter.MOBILE_PLATFORM_NAME).equalsIgnoreCase(SpecialKeywords.ANDROID)) {392 return;393 }394 if (isNull())395 return;396 397 String mobileApp = Configuration.get(Parameter.MOBILE_APP);398 String oldMobileApp = Configuration.get(Parameter.MOBILE_APP_PREUPGRADE);399 400 if (!oldMobileApp.isEmpty()) {401 //redefine strategy to do upgrade scenario402 R.CONFIG.put(Parameter.MOBILE_APP_UNINSTALL.getKey(), "true");403 R.CONFIG.put(Parameter.MOBILE_APP_INSTALL.getKey(), "true");404 }405 if (Configuration.getBoolean(Parameter.MOBILE_APP_UNINSTALL)) {406 // explicit reinstall the apk407 String[] apkVersions = getApkVersion(mobileApp); // Configuration.get(Parameter.MOBILE_APP)408 if (apkVersions != null) {409 String appPackage = apkVersions[0];410 String[] apkInstalledVersions = getInstalledApkVersion(appPackage);411 LOGGER.info("installed app: " + apkInstalledVersions[2] + "-" + apkInstalledVersions[1]);412 LOGGER.info("new app: " + apkVersions[2] + "-" + apkVersions[1]);413 if (apkVersions[1].equals(apkInstalledVersions[1]) && apkVersions[2].equals(apkInstalledVersions[2]) && oldMobileApp.isEmpty()) {414 LOGGER.info(415 "Skip application uninstall and cache cleanup as exactly the same version is already installed.");416 } else {417 uninstallApp(appPackage);418 clearAppData(appPackage);419 420 if (!oldMobileApp.isEmpty()) {421 LOGGER.info("Starting sync install operation for preupgrade app: " + oldMobileApp);422 installAppSync(oldMobileApp);423 }424 425 if (Configuration.getBoolean(Parameter.MOBILE_APP_INSTALL)) {426 // install application in single thread to fix issue with gray Google maps427 LOGGER.info("Starting sync install operation for app: " + mobileApp);428 installAppSync(mobileApp);429 }430 }431 }432 }433 }434 435 public String[] getInstalledApkVersion(String packageName) {436 //adb -s UDID shell dumpsys package PACKAGE | grep versionCode437 if (isNull())438 return null;439 String[] res = new String[3];440 res[0] = packageName;441 String[] cmd = CmdLine.insertCommandsAfter(executor.getDefaultCmd(), "-s", getUdid(), "shell", "dumpsys", "package", packageName);442 List<String> output = executor.execute(cmd);443 for (String line : output) {444 LOGGER.debug(line);445 if (line.contains("versionCode")) {446 // versionCode=17040000 targetSdk=25447 LOGGER.info("Line for parsing installed app: " + line);448 String[] outputs = line.split("=");449 String tmp = outputs[1]; //everything after '=' sign450 res[1] = tmp.split(" ")[0];451 }452 if (line.contains("versionName")) {453 // versionName=8.5.0454 LOGGER.info("Line for parsing installed app: " + line);455 String[] outputs = line.split("=");456 res[2] = outputs[1];457 }458 }459 if (res[0] == null && res[1] == null && res[2] == null) {460 return null;461 }462 return res;463 }464 465 public String[] getApkVersion(String apkFile) {466 // aapt dump badging <apk_file> | grep versionCode467 // aapt dump badging <apk_file> | grep versionName468 // output:469 // package: name='com.myfitnesspal.android' versionCode='9025' versionName='develop-QA' platformBuildVersionName='6.0-2704002'470 String[] cmd = CmdLine.insertCommandsAfter("aapt dump badging".split(" "), apkFile);471 List<String> output = executor.execute(cmd);472 // parse output command and get appropriate data473 String[] res = new String[3];474 for (String line : output) {475 if (line.contains("versionCode") && line.contains("versionName")) {476 LOGGER.debug(line);477 String[] outputs = line.split("'");478 res[0] = outputs[1]; //package479 res[1] = outputs[3]; //versionCode480 res[2] = outputs[5]; //versionName481 }482 }483 return res;484 }485 486 public void restartAppium() {487 if (!Configuration.getBoolean(Parameter.MOBILE_APPIUM_RESTART))488 return;489 490 if (isNull())491 return;492 stopAppium();493 startAppium();494 }495 // TODO: think about moving shutdown/startup scripts into external property and make it cross platform 496 public void stopAppium() {497 if (!Configuration.getBoolean(Parameter.MOBILE_APPIUM_RESTART))498 return;499 500 if (isNull())501 return;502 LOGGER.info("Stopping appium...");503 String cmdLine = Configuration.get(Parameter.MOBILE_TOOLS_HOME) + "/stopNodeAppium.sh";504 String[] cmd = CmdLine.insertCommandsAfter(cmdLine.split(" "), getUdid());505 List<String> output = executor.execute(cmd);506 for (String line : output) {507 LOGGER.debug(line);508 }509 }510 public void startAppium() {511 if (!Configuration.getBoolean(Parameter.MOBILE_APPIUM_RESTART))512 return;513 514 if (isNull())515 return;516 LOGGER.info("Starting appium...");517 String cmdLine = Configuration.get(Parameter.MOBILE_TOOLS_HOME) + "/startNodeAppium.sh";518 String[] cmd = CmdLine.insertCommandsAfter(cmdLine.split(" "), getUdid(), "&");519 List<String> output = executor.execute(cmd);520 for (String line : output) {521 LOGGER.debug(line);522 }523 AppiumStatus.waitStartup(getSeleniumServer(), 30);524 }525 526 public List<String> execute(String[] cmd) {527 return executor.execute(cmd);528 }...

Full Screen

Full Screen

Source:CustomJiraUpdater.java Github

copy

Full Screen

...110 111 private String getCIJobReference()112 {113 String ciTestJob = null;114 if(!Configuration.isNull(Parameter.JENKINS_URL) && !Configuration.isNull(Parameter.JENKINS_JOB))115 {116 JenkinsClient jc = new JenkinsClient(Configuration.get(Parameter.JENKINS_URL));117 ciTestJob = jc.getCurrentJobURL(Configuration.get(Parameter.JENKINS_JOB));118 if(StringUtils.isEmpty(ciTestJob))119 LOG.info("Could not connect to Jenkins!");120 } else121 LOG.info("Specify 'jenkins_url' and 'jenkins_job' in CONFIG to have reference to test job!");122 return ciTestJob;123 }124 private void commentIssue(final JiraClient jira, final String id, final String status, final String comment)125 {126 Issue issue;127 try {128 issue = jira.getIssue(id);...

Full Screen

Full Screen

isNull

Using AI Code Generation

copy

Full Screen

1import com.qaprosoft.carina.core.foundation.utils.Configuration;2public class 1 {3 public static void main(String[] args) {4 if (Configuration.isNull("null")) {5 System.out.println("null");6 } else {7 System.out.println("not null");8 }9 }10}11import com.qaprosoft.carina.core.foundation.utils.Configuration;12public class 2 {13 public static void main(String[] args) {14 if (Configuration.isNotNull("null")) {15 System.out.println("not null");16 } else {17 System.out.println("null");18 }19 }20}21import com.qaprosoft.carina.core.foundation.utils.Configuration;22public class 3 {23 public static void main(String[] args) {24 if (Configuration.isNull("not null")) {25 System.out.println("null");26 } else {27 System.out.println("not null");28 }29 }30}31import com.qaprosoft.carina.core.foundation.utils.Configuration;32public class 4 {33 public static void main(String[] args) {34 if (Configuration.isNotNull("not null")) {35 System.out.println("not null");36 } else {37 System.out.println("null");38 }39 }40}41import com.qaprosoft.carina.core.foundation.utils.Configuration;42public class 5 {43 public static void main(String[] args) {44 if (Configuration.isNull("empty")) {45 System.out.println("null");46 } else {47 System.out.println("not null");48 }49 }50}51import com.qaprosoft.carina.core.foundation.utils.Configuration;52public class 6 {53 public static void main(String[] args) {54 if (Configuration

Full Screen

Full Screen

isNull

Using AI Code Generation

copy

Full Screen

1import com.qaprosoft.carina.core.foundation.utils.Configuration;2import org.testng.Assert;3import org.testng.annotations.Test;4public class Test1 {5 public void test1(){6 Assert.assertTrue(Configuration.isNull("browser"));7 }8}9import com.qaprosoft.carina.core.foundation.utils.Configuration;10import org.testng.Assert;11import org.testng.annotations.Test;12public class Test2 {13 public void test2(){14 Assert.assertFalse(Configuration.isNull("browser"));15 }16}

Full Screen

Full Screen

isNull

Using AI Code Generation

copy

Full Screen

1package com.qaprosoft.carina.demo;2import org.testng.Assert;3import org.testng.annotations.Test;4import com.qaprosoft.carina.core.foundation.utils.Configuration;5public class Test2 {6 public void test1() {7 System.out.println("Test1");8 Assert.assertTrue(Configuration.isNull("test"));9 }10}11package com.qaprosoft.carina.demo;12import org.testng.Assert;13import org.testng.annotations.Test;14import com.qaprosoft.carina.core.foundation.utils.Configuration;15public class Test2 {16 public void test2() {17 System.out.println("Test2");18 Assert.assertFalse(Configuration.isNull("test"));19 }20}21package com.qaprosoft.carina.demo;22import org.testng.Assert;23import org.testng.annotations.Test;24import com.qaprosoft.carina.core.foundation.utils.Configuration;25public class Test2 {26 public void test3() {27 System.out.println("Test3");28 Assert.assertTrue(Configuration.isNull("test"));29 }30}31package com.qaprosoft.carina.demo;32import org.testng.Assert;33import org.testng.annotations.Test;34import com.qaprosoft.carina.core.foundation.utils.Configuration;35public class Test2 {36 public void test4() {37 System.out.println("Test4");38 Assert.assertFalse(Configuration.isNull("test"));39 }40}41package com.qaprosoft.carina.demo;42import org.testng.Assert;43import org.testng.annotations.Test;44import com.qaprosoft.carina.core.foundation.utils.Configuration;45public class Test2 {46 public void test5() {47 System.out.println("Test5");48 Assert.assertTrue(Configuration.isNull("test"));49 }50}

Full Screen

Full Screen

isNull

Using AI Code Generation

copy

Full Screen

1import com.qaprosoft.carina.core.foundation.utils.Configuration;2public class 1 {3 public static void main(String[] args) {4 System.out.println(Configuration.isNull("null"));5 }6}7import com.qaprosoft.carina.core.foundation.utils.Configuration;8public class 2 {9 public static void main(String[] args) {10 System.out.println(Configuration.isNull("null"));11 }12}13import com.qaprosoft.carina.core.foundation.utils.Configuration;14public class 3 {15 public static void main(String[] args) {16 System.out.println(Configuration.isNull("null"));17 }18}19import com.qaprosoft.carina.core.foundation.utils.Configuration;20public class 4 {21 public static void main(String[] args) {22 System.out.println(Configuration.isNull("null"));23 }24}25import com.qaprosoft.carina.core.foundation.utils.Configuration;26public class 5 {27 public static void main(String[] args) {28 System.out.println(Configuration.isNull("null"));29 }30}31import com.qaprosoft.carina.core.foundation.utils.Configuration;32public class 6 {33 public static void main(String[] args) {34 System.out.println(Configuration.isNull("null"));35 }36}37import com.qaprosoft.carina.core.foundation.utils.Configuration;38public class 7 {39 public static void main(String[] args) {40 System.out.println(Configuration.isNull("null"));41 }42}

Full Screen

Full Screen

isNull

Using AI Code Generation

copy

Full Screen

1package com.qaprosoft.carina.core.foundation.utils;2import org.testng.Assert;3import org.testng.annotations.Test;4public class ConfigurationTest {5public void isNullTest() {6Configuration configuration = Configuration.get(Configuration.Parameter.CARINA_WEBDRIVER);7Assert.assertTrue(configuration.isNull());8}9}10package com.qaprosoft.carina.core.foundation.utils;11import org.testng.Assert;12import org.testng.annotations.Test;13public class ConfigurationTest {14public void isNullTest() {15Configuration configuration = Configuration.get(Configuration.Parameter.CARINA_WEBDRIVER);16Assert.assertTrue(configuration.isNull());17}18}19package com.qaprosoft.carina.core.foundation.utils;20import org.testng.Assert;21import org.testng.annotations.Test;22public class ConfigurationTest {23public void isNullTest() {24Configuration configuration = Configuration.get(Configuration.Parameter.CARINA_WEBDRIVER);25Assert.assertTrue(configuration.isNull());26}27}28package com.qaprosoft.carina.core.foundation.utils;29import org.testng.Assert;30import org.testng.annotations.Test;31public class ConfigurationTest {32public void isNullTest() {33Configuration configuration = Configuration.get(Configuration.Parameter.CARINA_WEBDRIVER);34Assert.assertTrue(configuration.isNull());35}36}37package com.qaprosoft.carina.core.foundation.utils;38import org.testng.Assert;39import org.testng.annotations.Test;40public class ConfigurationTest {41public void isNullTest() {42Configuration configuration = Configuration.get(Configuration.Parameter.CARINA_WEBDRIVER);43Assert.assertTrue(configuration.isNull());44}45}46package com.qaprosoft.carina.core.foundation.utils;47import org.testng.Assert;48import org.testng.annotations.Test;49public class ConfigurationTest {50public void isNullTest() {51Configuration configuration = Configuration.get(Configuration.Parameter.CARINA_WEBDRIVER);52Assert.assertTrue(configuration.isNull());53}54}

Full Screen

Full Screen

isNull

Using AI Code Generation

copy

Full Screen

1package com.qaprosoft.carina.demo;2import org.testng.Assert;3import org.testng.annotations.Test;4import com.qaprosoft.carina.core.foundation.utils.Configuration;5import com.qaprosoft.carina.core.foundation.utils.Configuration.Parameter;6public class isNull {7public void isNullMethod() {8boolean isPresent=Configuration.isNull(Parameter.CAPABILITIES);9System.out.println("isPresent: "+isPresent);10Assert.assertFalse(isPresent);11}12}13package com.qaprosoft.carina.demo;14import org.testng.Assert;15import org.testng.annotations.Test;16import com.qaprosoft.carina.core.foundation.utils.Configuration;17import com.qaprosoft.carina.core.foundation.utils.Configuration.Parameter;18public class isNull {19public void isNullMethod() {20boolean isPresent=Configuration.isNull(Parameter.CAPABILITIES);21System.out.println("isPresent: "+isPresent);22Assert.assertFalse(isPresent);23}24}25package com.qaprosoft.carina.demo;26import org.testng.Assert;27import org.testng.annotations.Test;28import com.qaprosoft.carina.core.foundation.utils.Configuration;29import com.qaprosoft.carina.core.foundation.utils.Configuration.Parameter;30public class isNull {31public void isNullMethod() {

Full Screen

Full Screen

isNull

Using AI Code Generation

copy

Full Screen

1import java.util.Properties;2import java.io.FileInputStream;3import java.io.IOException;4import java.io.InputStream;5import java.io.File;6import com.qaprosoft.carina.core.foundation.utils.Configuration;7{8 public static void main(String[] args)9 {10 {11 Properties prop = new Properties();12 InputStream input = null;13 input = new FileInputStream("src/main/resources/configuration.properties");14 prop.load(input);15 String prop1 = prop.getProperty("prop1");16 String prop2 = prop.getProperty("prop2");17 String prop3 = prop.getProperty("prop3");18 String prop4 = prop.getProperty("prop4");19 String prop5 = prop.getProperty("prop5");20 String prop6 = prop.getProperty("prop6");21 String prop7 = prop.getProperty("prop7");22 String prop8 = prop.getProperty("prop8");23 String prop9 = prop.getProperty("prop9");24 String prop10 = prop.getProperty("prop10");25 String prop11 = prop.getProperty("prop11");26 String prop12 = prop.getProperty("prop12");27 String prop13 = prop.getProperty("prop13");28 String prop14 = prop.getProperty("prop14");29 String prop15 = prop.getProperty("prop15");30 String prop16 = prop.getProperty("prop16");31 String prop17 = prop.getProperty("prop17");32 String prop18 = prop.getProperty("prop18");33 String prop19 = prop.getProperty("prop19");34 String prop20 = prop.getProperty("prop20");35 String prop21 = prop.getProperty("prop21");36 String prop22 = prop.getProperty("prop22");37 String prop23 = prop.getProperty("prop23");38 String prop24 = prop.getProperty("prop24");39 String prop25 = prop.getProperty("prop25");40 String prop26 = prop.getProperty("prop26");

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful