How to use setCerberus_sikuli_typeDelay method of org.cerberus.engine.entity.Session class

Best Cerberus-source code snippet using org.cerberus.engine.entity.Session.setCerberus_sikuli_typeDelay

Source:RobotServerService.java Github

copy

Full Screen

...186 session.setCerberus_selenium_highlightElement_default(cerberus_selenium_highlightElement);187 session.setCerberus_sikuli_highlightElement(cerberus_sikuli_highlightElement);188 session.setCerberus_sikuli_highlightElement_default(cerberus_sikuli_highlightElement);189 // typeDelay parameters190 session.setCerberus_sikuli_typeDelay(cerberus_sikuli_typeDelay);191 session.setCerberus_sikuli_typeDelay_default(cerberus_sikuli_typeDelay);192 193 // auto scroll parameters194 session.setCerberus_selenium_autoscroll(cerberus_selenium_autoscroll);195 session.setCerberus_selenium_autoscroll_vertical_offset(cerberus_selenium_autoscroll_vertical_offset);196 session.setCerberus_selenium_autoscroll_horizontal_offset(cerberus_selenium_autoscroll_horizontal_offset);197 session.setCerberus_selenium_action_click_timeout(cerberus_selenium_action_click_timeout);198 session.setCerberus_appium_action_longpress_wait(cerberus_appium_action_longpress_wait);199 session.setHost(tCExecution.getSeleniumIP());200 session.setPort(tCExecution.getRobotPort());201 session.setHostUser(tCExecution.getSeleniumIPUser());202 session.setHostPassword(tCExecution.getSeleniumIPPassword());203 session.setNodeHost(tCExecution.getSeleniumIP());204 session.setNodePort(tCExecution.getSeleniumPort());205 if (tCExecution.getRobotExecutorObj() != null) {206 LOG.debug("Session node proxy set : {}", tCExecution.getRobotExecutorObj().getNodeProxyPort());207 session.setNodeProxyPort(tCExecution.getRobotExecutorObj().getNodeProxyPort());208 } else {209 session.setNodeProxyPort(0);210 }211 session.setConsoleLogs(new JSONArray());212 tCExecution.setSession(session);213 tCExecution.setRobotProvider(guessRobotProvider(session.getHost()));214 LOG.debug("Session is set.");215 /*216 * Starting Cerberus Executor Proxy if it has been activated at217 * robot level.218 */219 if (tCExecution.getRobotExecutorObj() != null && "Y".equals(tCExecution.getRobotExecutorObj().getExecutorProxyActive())) {220 LOG.debug("Start Remote Proxy");221 executorService.startRemoteProxy(tCExecution);222 LOG.debug("Started Remote Proxy on port: {}", tCExecution.getRemoteProxyPort());223 }224 // SetUp Capabilities225 LOG.debug("Set Capabilities");226 MutableCapabilities caps = this.setCapabilities(tCExecution);227 session.setDesiredCapabilities(caps);228 LOG.debug("Set Capabilities - retrieved");229 // We record Caps list at the execution level.230 try {231 // Init additionalFinalCapabilities and set it from real caps.232 List<RobotCapability> additionalFinalCapabilities = new ArrayList<>();233 for (Map.Entry<String, Object> cap : caps.asMap().entrySet()) {234 additionalFinalCapabilities.add(factoryRobotCapability.create(0, "", cap.getKey(), cap.getValue().toString()));235 }236 // Init inputCapabilities and set it from Robot values.237 List<RobotCapability> inputCapabilities = new ArrayList<>();238 if (tCExecution.getRobotObj() != null) {239 inputCapabilities = tCExecution.getRobotObj().getCapabilities();240 }241 tCExecution.addFileList(recorderService.recordCapabilities(tCExecution, inputCapabilities, additionalFinalCapabilities));242 } catch (Exception ex) {243 LOG.error("Exception Saving Robot Caps {} Exception: {}", tCExecution.getId(), ex.toString(), ex);244 }245 // SetUp Proxy246 String hubUrl = StringUtil.cleanHostURL(RobotServerService.getBaseUrl(StringUtil.formatURLCredential(247 tCExecution.getSession().getHostUser(),248 tCExecution.getSession().getHostPassword(), session.getHost()),249 session.getPort())) + "/wd/hub";250 LOG.debug("Hub URL :{}", hubUrl);251 URL url = new URL(hubUrl);252 HttpCommandExecutor executor = null;253 boolean isProxy = proxyService.useProxy(hubUrl, system);254 Factory factory = new OkHttpClient.Factory();255 // Timeout Management256 int robotTimeout = parameterService.getParameterIntegerByKey("cerberus_robot_timeout", system, 60000);257 Duration rbtTimeOut = Duration.ofMillis(robotTimeout);258 factory.builder().connectionTimeout(rbtTimeOut);259 if (isProxy) {260 // Proxy Management261 String proxyHost = parameterService.getParameterStringByKey("cerberus_proxy_host", system, DEFAULT_PROXY_HOST);262 int proxyPort = parameterService.getParameterIntegerByKey("cerberus_proxy_port", system, DEFAULT_PROXY_PORT);263 java.net.Proxy myproxy = new java.net.Proxy(java.net.Proxy.Type.HTTP, new InetSocketAddress(proxyHost, proxyPort));264 if (parameterService.getParameterBooleanByKey("cerberus_proxyauthentification_active", system, DEFAULT_PROXYAUTHENT_ACTIVATE)) {265 String proxyUser = parameterService.getParameterStringByKey("cerberus_proxyauthentification_user", system, DEFAULT_PROXYAUTHENT_USER);266 String proxyPassword = parameterService.getParameterStringByKey("cerberus_proxyauthentification_password", system, DEFAULT_PROXYAUTHENT_PASSWORD);267 // TODO delete if comment bellow has no impact on the non reg campaign268/*269 Authenticator proxyAuthenticator = new Authenticator() {270 public Request authenticate(Route route, Response response) throws IOException {271 String credential = Credentials.basic(proxyUser, proxyPassword);272 return response.request().newBuilder()273 .header("Proxy-Authorization", credential)274 .build();275 }276 };277*/278 }279 factory.builder().proxy(myproxy);280 } else {281 factory.builder().proxy(java.net.Proxy.NO_PROXY);282 }283 executor = new HttpCommandExecutor(new HashMap<>(), url, factory);284 // SetUp Driver285 LOG.debug("Set Driver");286 WebDriver driver = null;287 AppiumDriver appiumDriver = null;288 switch (tCExecution.getApplicationObj().getType().toUpperCase()) {289 case Application.TYPE_GUI:290 if (caps.getPlatform() != null && caps.getPlatform().is(Platform.ANDROID)) {291 // Appium does not support connection from HTTPCommandExecutor. When connecting from Executor, it stops to work after a couple of instructions.292 appiumDriver = new AndroidDriver(url, caps);293 } else if (caps.getPlatform() != null && (caps.getPlatform().is(Platform.IOS) || caps.getPlatform().is(Platform.MAC))) {294 appiumDriver = new IOSDriver(url, caps);295 }296 driver = appiumDriver == null ? new RemoteWebDriver(executor, caps) : appiumDriver;297 tCExecution.setRobotProviderSessionID(getSession(driver, tCExecution.getRobotProvider()));298 tCExecution.setRobotSessionID(getSession(driver));299 break;300 case Application.TYPE_APK:301 // add a lock on app path this part of code, because we can't install 2 apk with the same name simultaneously302 String appUrl = null;303 if (caps.getCapability("app") != null) {304 appUrl = caps.getCapability("app").toString();305 }306 if (appUrl != null) { // FIX : appium can't install 2 apk simultaneously, so implement a litle latency between execution307 synchronized (this) {308 // with appium 1.7.2, we can't install 2 fresh apk simultaneously. Appium have to prepare the apk (transformation) on the first execution before (see this topic https://discuss.appium.io/t/execute-2-android-test-simultaneously-problem-during-install-apk/22030)309 // provoque a latency if first test is already running and apk don't finish to be prepared310 if (apkAlreadyPrepare.containsKey(appUrl) && Boolean.TRUE.equals(!apkAlreadyPrepare.get(appUrl))) {311 Thread.sleep(10000);312 } else {313 apkAlreadyPrepare.put(appUrl, false);314 }315 }316 }317 appiumDriver = new AndroidDriver(url, caps);318 if (apkAlreadyPrepare.containsKey(appUrl)) {319 apkAlreadyPrepare.put(appUrl, true);320 }321 driver = appiumDriver;322 tCExecution.setRobotProviderSessionID(getSession(driver, tCExecution.getRobotProvider()));323 tCExecution.setRobotSessionID(getSession(driver));324 break;325 case Application.TYPE_IPA:326 appiumDriver = new IOSDriver(url, caps);327 driver = appiumDriver;328 tCExecution.setRobotProviderSessionID(getSession(driver, tCExecution.getRobotProvider()));329 tCExecution.setRobotSessionID(getSession(driver));330 break;331 case Application.TYPE_FAT:332 // Check sikuli extension is reachable333 if (!sikuliService.isSikuliServerReachableOnRobot(session)) {334 MessageGeneral mes = new MessageGeneral(MessageGeneralEnum.VALIDATION_FAILED_SIKULI_COULDNOTCONNECT);335 mes.setDescription(mes.getDescription().replace("%SSIP%", tCExecution.getSession().getHost()));336 mes.setDescription(mes.getDescription().replace("%SSPORT%", tCExecution.getSession().getPort()));337 throw new CerberusException(mes);338 }339 // If CountryEnvParameter IP is set, open the App340 if (!tCExecution.getCountryEnvironmentParameters().getIp().isEmpty()) {341 sikuliService.doSikuliActionOpenApp(session, tCExecution.getCountryEnvironmentParameters().getIp());342 }343 break;344 }345 // We record Server Side Caps.346 if (driver != null) {347 try {348 // Init additionalFinalCapabilities and set it from real caps.349 List<RobotCapability> serverCapabilities = new ArrayList<>();350 for (Map.Entry<String, Object> cap : ((HasCapabilities) driver).getCapabilities().asMap().entrySet()) {351 serverCapabilities.add(factoryRobotCapability.create(0, "", cap.getKey(), cap.getValue().toString()));352 }353 tCExecution.addFileList(recorderService.recordServerCapabilities(tCExecution, serverCapabilities));354 } catch (Exception ex) {355 LOG.error("Exception Saving Server Robot Caps " + tCExecution.getId(), ex);356 }357 }358 /*359 * Defining the timeout at the driver level. Only in case of no360 * Appium Driver (see361 * https://github.com/vertigo17/Cerberus/issues/754)362 */363 if (driver != null && appiumDriver == null) {364 driver.manage().timeouts().pageLoadTimeout(cerberus_selenium_pageLoadTimeout, TimeUnit.MILLISECONDS);365 driver.manage().timeouts().implicitlyWait(cerberus_selenium_implicitlyWait, TimeUnit.MILLISECONDS);366 driver.manage().timeouts().setScriptTimeout(cerberus_selenium_setScriptTimeout, TimeUnit.MILLISECONDS);367 }368 if (appiumDriver != null) {369 appiumDriver.manage().timeouts().implicitlyWait(cerberus_appium_wait_element, TimeUnit.MILLISECONDS);370 }371 tCExecution.getSession().setDriver(driver);372 tCExecution.getSession().setAppiumDriver(appiumDriver);373 /*374 * If Gui application, maximize window Get IP of Node in case of375 * remote Server. Maximize does not work for chrome browser We also376 * get the Real UserAgent from the browser.377 */378 if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_GUI)379 && !caps.getPlatform().equals(Platform.ANDROID) && !caps.getPlatform().equals(Platform.IOS)380 && !caps.getPlatform().equals(Platform.MAC)) {381 // Maximize is not supported on Opera.382 if (!caps.getBrowserName().equals(BrowserType.CHROME) && !tCExecution.getBrowser().equalsIgnoreCase("opera")) {383 driver.manage().window().maximize();384 }385 getIPOfNode(tCExecution);386 // If screenSize is defined, set the size of the screen.387 String targetScreensize = getScreenSizeToUse(tCExecution.getTestCaseObj().getScreenSize(), tCExecution.getScreenSize());388 LOG.debug("Selenium resolution : {}", targetScreensize);389 if (!tCExecution.getBrowser().equalsIgnoreCase(BrowserType.CHROME)) {390 // For chrome the resolution has already been defined at capabilities level.391 if ((!StringUtil.isNullOrEmpty(targetScreensize)) && targetScreensize.contains("*")) {392 Integer screenWidth = Integer.valueOf(targetScreensize.split("\\*")[0]);393 Integer screenLength = Integer.valueOf(targetScreensize.split("\\*")[1]);394 setScreenSize(driver, screenWidth, screenLength);395 LOG.debug("Selenium resolution Activated : {}*{}", screenWidth, screenLength);396 }397 }398 // Getting windows size Not supported on Opera.399 if (!tCExecution.getBrowser().equalsIgnoreCase("opera")) {400 tCExecution.setScreenSize(getScreenSize(driver));401 }402 tCExecution.setRobotDecli(tCExecution.getRobotDecli().replace("%SCREENSIZE%", tCExecution.getScreenSize()));403 String userAgent = (String) ((JavascriptExecutor) driver).executeScript("return navigator.userAgent;");404 tCExecution.setUserAgent(userAgent);405 }406 // unlock device if deviceLockUnlock is active407 if (tCExecution.getRobotExecutorObj() != null && appiumDriver instanceof LocksDevice408 && "Y".equals(tCExecution.getRobotExecutorObj().getDeviceLockUnlock())) {409 ((LocksDevice) appiumDriver).unlockDevice();410 }411 // Check if Sikuli is available on node.412 if (driver != null) {413 tCExecution.getSession().setSikuliAvailable(sikuliService.isSikuliServerReachableOnNode(tCExecution.getSession()));414 }415 tCExecution.getSession().setStarted(true);416 } catch (CerberusException exception) {417 LOG.error(exception.toString(), exception);418 throw new CerberusException(exception.getMessageError(), exception);419 } catch (MalformedURLException exception) {420 LOG.error(exception.toString(), exception);421 MessageGeneral mes = new MessageGeneral(MessageGeneralEnum.VALIDATION_FAILED_URL_MALFORMED);422 mes.setDescription(mes.getDescription().replace("%URL%", tCExecution.getSession().getHost() + ":" + tCExecution.getSession().getPort()));423 throw new CerberusException(mes, exception);424 } catch (UnreachableBrowserException exception) {425 LOG.warn("Could not connect to : {}:{}", tCExecution.getSeleniumIP(), tCExecution.getSeleniumPort());426 MessageGeneral mes = new MessageGeneral(MessageGeneralEnum.VALIDATION_FAILED_SELENIUM_COULDNOTCONNECT);427 mes.setDescription(mes.getDescription().replace("%SSIP%", tCExecution.getSeleniumIP()));428 mes.setDescription(mes.getDescription().replace("%SSPORT%", tCExecution.getSeleniumPort()));429 mes.setDescription(mes.getDescription().replace("%ERROR%", exception.toString()));430 throw new CerberusException(mes, exception);431 } catch (Exception exception) {432 LOG.error(exception.toString(), exception);433 MessageGeneral mes = new MessageGeneral(MessageGeneralEnum.EXECUTION_FA_SELENIUM);434 mes.setDescription(mes.getDescription().replace("%MES%", exception.toString()));435 executorService.stopRemoteProxy(tCExecution);436 throw new CerberusException(mes, exception);437 } finally {438 executionThreadPoolService.executeNextInQueueAsynchroneously(false);439 }440 }441 private String getSession(WebDriver driver, String robotProvider) {442 String session = "";443 switch (robotProvider) {444 case TestCaseExecution.ROBOTPROVIDER_BROWSERSTACK:445 case TestCaseExecution.ROBOTPROVIDER_LAMBDATEST: // For LambdaTest we get the exeid not here but by service call at the end of the execution.446 case TestCaseExecution.ROBOTPROVIDER_NONE:447 session = ((RemoteWebDriver) driver).getSessionId().toString();448 break;449 case TestCaseExecution.ROBOTPROVIDER_KOBITON:450 session = ((HasCapabilities) driver).getCapabilities().getCapability("kobitonSessionId").toString();451 break;452 default:453 }454 return session;455 }456 private String getSession(WebDriver driver) {457 String session = "";458 session = ((RemoteWebDriver) driver).getSessionId().toString();459 return session;460 }461 private String guessRobotProvider(String host) {462 if (host.contains("browserstack")) {463 return TestCaseExecution.ROBOTPROVIDER_BROWSERSTACK;464 }465 if (host.contains("kobiton")) {466 return TestCaseExecution.ROBOTPROVIDER_KOBITON;467 }468 if (host.contains("lambdatest")) {469 return TestCaseExecution.ROBOTPROVIDER_LAMBDATEST;470 }471 return TestCaseExecution.ROBOTPROVIDER_NONE;472 }473 /**474 * Set DesiredCapabilities475 *476 * @param tCExecution477 * @return478 * @throws CerberusException479 */480 private MutableCapabilities setCapabilities(TestCaseExecution tCExecution) throws CerberusException {481 // Instanciate DesiredCapabilities482 MutableCapabilities caps = new MutableCapabilities();483 // In case browser is not defined at that level, we force it to firefox.484 if (StringUtil.isNullOrEmpty(tCExecution.getBrowser())) {485 tCExecution.setBrowser("");486 }487 // Set Browser Capabilities488 caps = this.setCapabilityBrowser(caps, tCExecution.getBrowser(), tCExecution);489 // Loop on RobotCapabilities to feed DesiredCapabilities Capability must be String, Integer or Boolean490 List<RobotCapability> additionalCapabilities = new ArrayList<>();491 if (tCExecution.getRobotObj() != null) {492 additionalCapabilities = tCExecution.getRobotObj().getCapabilitiesDecoded();493 }494 if (additionalCapabilities != null) {495 for (RobotCapability additionalCapability : additionalCapabilities) {496 LOG.debug("RobotCaps on Robot : {} caps: {} Value: {}", additionalCapability.getRobot(), additionalCapability.getCapability(), additionalCapability.getValue());497 if ((caps.getCapability(additionalCapability.getCapability()) == null)498 || ((caps.getCapability(additionalCapability.getCapability()) != null) && (caps.getCapability(additionalCapability.getCapability()).toString().isEmpty()))) { // caps does not already exist so we can set it.499 if (StringUtil.isBoolean(additionalCapability.getValue())) {500 caps.setCapability(additionalCapability.getCapability(), StringUtil.parseBoolean(additionalCapability.getValue()));501 } else if (StringUtil.isInteger(additionalCapability.getValue())) {502 caps.setCapability(additionalCapability.getCapability(), Integer.valueOf(additionalCapability.getValue()));503 } else {504 caps.setCapability(additionalCapability.getCapability(), additionalCapability.getValue());505 }506 }507 }508 } else {509 additionalCapabilities = new ArrayList<>();510 }511 // Feed DesiredCapabilities with values get from Robot512 if (!StringUtil.isNullOrEmpty(tCExecution.getPlatform())513 && ((caps.getCapability("platform") == null)514 || ((caps.getCapability("platform") != null)515 && (caps.getCapability("platform").toString().equals("ANY")516 || caps.getCapability("platform").toString().isEmpty())))) {517 caps.setCapability("platformName", tCExecution.getPlatform());518 }519 if (!StringUtil.isNullOrEmpty(tCExecution.getVersion())520 && ((caps.getCapability("version") == null)521 || ((caps.getCapability("version") != null)522 && (caps.getCapability("version").toString().isEmpty())))) {523 caps.setCapability("version", tCExecution.getVersion());524 }525 if (tCExecution.getRobotExecutorObj() != null) {526 // Setting deviceUdid and device name from executor.527 if (!StringUtil.isNullOrEmpty(tCExecution.getRobotExecutorObj().getDeviceUuid())528 && ((caps.getCapability("udid") == null)529 || ((caps.getCapability("udid") != null)530 && (caps.getCapability("udid").toString().isEmpty())))) {531 caps.setCapability("udid", tCExecution.getRobotExecutorObj().getDeviceUuid());532 }533 if (!StringUtil.isNullOrEmpty(tCExecution.getRobotExecutorObj().getDeviceName())534 && ((caps.getCapability("deviceName") == null)535 || ((caps.getCapability("deviceName") != null)536 && (caps.getCapability("deviceName").toString().isEmpty())))) {537 caps.setCapability("deviceName", tCExecution.getRobotExecutorObj().getDeviceName());538 }539 if (!StringUtil.isNullOrEmpty(tCExecution.getRobotExecutorObj().getDeviceName())) {540 if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_APK)541 && ((caps.getCapability("systemPort") == null)542 || ((caps.getCapability("systemPort") != null)543 && (caps.getCapability("systemPort").toString().isEmpty())))) {544 caps.setCapability("systemPort", tCExecution.getRobotExecutorObj().getDevicePort());545 } else if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_IPA)546 && ((caps.getCapability("wdaLocalPort") == null)547 || ((caps.getCapability("wdaLocalPort") != null)548 && (caps.getCapability("wdaLocalPort").toString().isEmpty())))) {549 caps.setCapability("wdaLocalPort", tCExecution.getRobotExecutorObj().getDevicePort());550 }551 }552 }553 // if application is a mobile one, then set the "app" capability to theapplication binary path554 if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_APK)555 || tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_IPA)) {556 // Set the app capability with the application path557 if (!StringUtil.isNullOrEmpty(tCExecution.getMyHost())558 && (isNotAlreadyDefined(caps, "app"))) {559 caps.setCapability("app", tCExecution.getMyHost());560 } else if (isNotAlreadyDefined(caps, "app")) {561 caps.setCapability("app", tCExecution.getCountryEnvironmentParameters().getIp());562 }563 if (!StringUtil.isNullOrEmpty(tCExecution.getCountryEnvironmentParameters().getMobileActivity())564 && (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_APK)565 && isNotAlreadyDefined(caps, "appWaitActivity"))) {566 caps.setCapability("appWaitActivity", tCExecution.getCountryEnvironmentParameters().getMobileActivity());567 }568 if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_APK)569 && (isNotAlreadyDefined(caps, "automationName"))) {570 caps.setCapability("automationName", "UIAutomator2"); // use UIAutomator2 by default571 }572 }573 // Setting specific capabilities of external cloud providers.574 switch (tCExecution.getRobotProvider()) {575 case TestCaseExecution.ROBOTPROVIDER_BROWSERSTACK:576 if (!StringUtil.isNullOrEmpty(tCExecution.getTag()) && isNotAlreadyDefined(caps, "build")) {577 caps.setCapability("build", tCExecution.getTag());578 }579 if (isNotAlreadyDefined(caps, "project")) {580 caps.setCapability("project", tCExecution.getApplication());581 }582 if (isNotAlreadyDefined(caps, "name")) {583 String externalExeName = parameterService.getParameterStringByKey("cerberus_browserstack_defaultexename", tCExecution.getSystem(), "Exe : %EXEID%");584 externalExeName = externalExeName.replace("%EXEID%", String.valueOf(tCExecution.getId()));585 caps.setCapability("name", externalExeName);586 }587 if (tCExecution.getVerbose() >= 2) {588 if (isNotAlreadyDefined(caps, "browserstack.debug")) {589 caps.setCapability("browserstack.debug", true);590 }591 if (isNotAlreadyDefined(caps, "browserstack.console")) {592 caps.setCapability("browserstack.console", "warnings");593 }594 if (isNotAlreadyDefined(caps, "browserstack.networkLogs")) {595 caps.setCapability("browserstack.networkLogs", true);596 }597 }598 //Create or override these capabilities if proxy required.599 if (StringUtil.parseBoolean(tCExecution.getRobotExecutorObj().getExecutorProxyActive())) {600 caps.setCapability("browserstack.local", true);601 caps.setCapability("browserstack.user", tCExecution.getRobotExecutorObj().getHostUser());602 caps.setCapability("browserstack.key", tCExecution.getRobotExecutorObj().getHostPassword());603 caps.setCapability("browserstack.localIdentifier", tCExecution.getExecutionUUID());604 }605 break;606 case TestCaseExecution.ROBOTPROVIDER_LAMBDATEST:607 if (!StringUtil.isNullOrEmpty(tCExecution.getTag()) && isNotAlreadyDefined(caps, "build")) {608 caps.setCapability("build", tCExecution.getTag());609 }610 if (isNotAlreadyDefined(caps, "name")) {611 String externalExeName = parameterService.getParameterStringByKey("cerberus_lambdatest_defaultexename", tCExecution.getSystem(), "Exe : %EXEID% - %TESTDESCRIPTION%");612 externalExeName = externalExeName.replace("%EXEID%", String.valueOf(tCExecution.getId()));613 externalExeName = externalExeName.replace("%TESTFOLDER%", String.valueOf(tCExecution.getTest()));614 externalExeName = externalExeName.replace("%TESTID%", String.valueOf(tCExecution.getTestCase()));615 externalExeName = externalExeName.replace("%TESTDESCRIPTION%", String.valueOf(tCExecution.getDescription()));616 caps.setCapability("name", externalExeName);617 }618 if (tCExecution.getVerbose() >= 2) {619 if (isNotAlreadyDefined(caps, "video")) {620 caps.setCapability("video", true);621 }622 if (isNotAlreadyDefined(caps, "visual")) {623 caps.setCapability("visual", true);624 }625 if (isNotAlreadyDefined(caps, "network")) {626 caps.setCapability("network", true);627 }628 if (isNotAlreadyDefined(caps, "console")) {629 caps.setCapability("console", true);630 }631 }632 break;633 case TestCaseExecution.ROBOTPROVIDER_KOBITON:634 if (isNotAlreadyDefined(caps, "sessionName")) {635 String externalExeName = parameterService.getParameterStringByKey("cerberus_kobiton_defaultsessionname", tCExecution.getSystem(), "%EXEID% : %TEST% - %TESTCASE%");636 externalExeName = externalExeName.replace("%EXEID%", String.valueOf(tCExecution.getId()));637 externalExeName = externalExeName.replace("%APPLI%", String.valueOf(tCExecution.getApplication()));638 externalExeName = externalExeName.replace("%TAG%", String.valueOf(tCExecution.getTag()));639 externalExeName = externalExeName.replace("%TEST%", String.valueOf(tCExecution.getTest()));640 externalExeName = externalExeName.replace("%TESTCASE%", String.valueOf(tCExecution.getTestCase()));641 externalExeName = externalExeName.replace("%TESTCASEDESC%", String.valueOf(tCExecution.getTestCaseObj().getDescription()));642 caps.setCapability("sessionName", externalExeName);643 }644 if (isNotAlreadyDefined(caps, "sessionDescription")) {645 String externalExeName = parameterService.getParameterStringByKey("cerberus_kobiton_defaultsessiondescription", tCExecution.getSystem(), "%TESTCASEDESC%");646 externalExeName = externalExeName.replace("%EXEID%", String.valueOf(tCExecution.getId()));647 externalExeName = externalExeName.replace("%APPLI%", String.valueOf(tCExecution.getApplication()));648 externalExeName = externalExeName.replace("%TAG%", String.valueOf(tCExecution.getTag()));649 externalExeName = externalExeName.replace("%TEST%", String.valueOf(tCExecution.getTest()));650 externalExeName = externalExeName.replace("%TESTCASE%", String.valueOf(tCExecution.getTestCase()));651 externalExeName = externalExeName.replace("%TESTCASEDESC%", String.valueOf(tCExecution.getTestCaseObj().getDescription()));652 caps.setCapability("sessionDescription", externalExeName);653 }654 if (isNotAlreadyDefined(caps, "deviceGroup")) {655 caps.setCapability("deviceGroup", "KOBITON"); // use UIAutomator2 by default656 }657 break;658 case TestCaseExecution.ROBOTPROVIDER_NONE:659 break;660 default:661 }662 return caps;663 }664 private boolean isNotAlreadyDefined(MutableCapabilities caps, String capability) {665 return ((caps.getCapability(capability) == null)666 || ((caps.getCapability(capability) != null)667 && (caps.getCapability(capability).toString().isEmpty())));668 }669 /**670 * Instantiate DesiredCapabilities regarding the browser671 *672 * @param capabilities673 * @param browser674 * @param tCExecution675 * @return676 * @throws CerberusException677 */678 private MutableCapabilities setCapabilityBrowser(MutableCapabilities capabilities, String browser, TestCaseExecution tCExecution) throws CerberusException {679 try {680 // Get User Agent to use.681 String usedUserAgent;682 usedUserAgent = getUserAgentToUse(tCExecution.getTestCaseObj().getUserAgent(), tCExecution.getUserAgent());683 LoggingPreferences logPrefs = new LoggingPreferences();684 logPrefs.enable(LogType.BROWSER, Level.ALL);685 switch (browser) {686 case "firefox":687 FirefoxOptions optionsFF = new FirefoxOptions();688 FirefoxProfile profile = new FirefoxProfile();689 profile.setPreference("app.update.enabled", false);690 // Language691 try {692 Invariant invariant = invariantService.convert(invariantService.readByKey("COUNTRY", tCExecution.getCountry()));693 if (invariant.getGp2() == null) {694 LOG.warn("Country selected ({}) has no value of GP2 in Invariant table, default language set to English (en)", tCExecution.getCountry());695 profile.setPreference("intl.accept_languages", "en");696 } else {697 profile.setPreference("intl.accept_languages", invariant.getGp2());698 }699 } catch (CerberusException ex) {700 LOG.warn("Country selected ({}) not in Invariant table, default language set to English (en)", tCExecution.getCountry());701 profile.setPreference("intl.accept_languages", "en");702 }703 // Force a specific profile for that session (allows reusing cookies and browser preferences).704 if (tCExecution.getRobotObj() != null && !StringUtil.isNullOrEmpty(tCExecution.getRobotObj().getProfileFolder())) {705 optionsFF.addArguments("--profile");706 optionsFF.addArguments(tCExecution.getRobotObj().getProfileFolder());707 }708 // Set UserAgent if testCaseUserAgent or robotUserAgent is defined709 if (!StringUtil.isNullOrEmpty(usedUserAgent)) {710 profile.setPreference("general.useragent.override", usedUserAgent);711 }712 // Verbose level and Headless713 if (tCExecution.getVerbose() <= 0) {714 optionsFF.setHeadless(true);715 }716 // Add the WebDriver proxy capability.717 if (tCExecution.getRobotExecutorObj() != null && "Y".equals(tCExecution.getRobotExecutorObj().getExecutorProxyActive())) {718 Proxy proxy = new Proxy();719 proxy.setHttpProxy(tCExecution.getRobotExecutorObj().getExecutorProxyHost() + ":" + tCExecution.getRemoteProxyPort());720 proxy.setSslProxy(tCExecution.getRobotExecutorObj().getExecutorProxyHost() + ":" + tCExecution.getRemoteProxyPort());721 proxy.setProxyType(Proxy.ProxyType.MANUAL);722 LOG.debug("Setting Firefox proxy to : {}", proxy);723 optionsFF.setProxy(proxy);724 }725 optionsFF.setProfile(profile);726 // Accept Insecure Certificates.727 optionsFF.setAcceptInsecureCerts(tCExecution.getRobotObj() == null || tCExecution.getRobotObj().isAcceptInsecureCerts());728 // Collect Logs on Selenium side.729 optionsFF.setCapability(CapabilityType.LOGGING_PREFS, logPrefs);730 return optionsFF;731 case "chrome":732 ChromeOptions optionsCH = new ChromeOptions();733 // Maximize windows for chrome browser734 String targetScreensize = getScreenSizeToUse(tCExecution.getTestCaseObj().getScreenSize(), tCExecution.getScreenSize());735 if ((!StringUtil.isNullOrEmpty(targetScreensize)) && targetScreensize.contains("*")) {736 Integer screenWidth = Integer.valueOf(targetScreensize.split("\\*")[0]);737 Integer screenLength = Integer.valueOf(targetScreensize.split("\\*")[1]);738 String sizeOpts = "--window-size=" + screenWidth + "," + screenLength;739 optionsCH.addArguments(sizeOpts);740 LOG.debug("Selenium resolution (for Chrome) Activated : " + screenWidth + "*" + screenLength);741 } else {742 optionsCH.addArguments("start-maximized");743 }744 // Language745 try {746 Invariant invariant = invariantService.convert(invariantService.readByKey("COUNTRY", tCExecution.getCountry()));747 if (invariant.getGp2() == null) {748 LOG.warn("Country selected ({}) has no value of GP2 in Invariant table, default language set to English (en)", tCExecution.getCountry());749 optionsCH.addArguments("--lang=en");750 } else {751 optionsCH.addArguments("--lang=" + invariant.getGp2());752 }753 } catch (CerberusException ex) {754 LOG.warn("Country selected ({}) not in Invariant table, default language set to English (en)", tCExecution.getCountry());755 optionsCH.addArguments("--lang=en");756 }757 // Force a specific profile for that session (allows reusing cookies and browser preferences).758 if (tCExecution.getRobotObj() != null && !StringUtil.isNullOrEmpty(tCExecution.getRobotObj().getProfileFolder())) {759 optionsCH.addArguments("user-data-dir=" + tCExecution.getRobotObj().getProfileFolder());760 }761 // Set UserAgent if necessary762 if (!StringUtil.isNullOrEmpty(usedUserAgent)) {763 optionsCH.addArguments("--user-agent=" + usedUserAgent);764 }765 // Verbose level and Headless766 if (tCExecution.getVerbose() <= 0) {767 optionsCH.addArguments("--headless");768 }769 // Add the WebDriver proxy capability.770 if (tCExecution.getRobotExecutorObj() != null && "Y".equals(tCExecution.getRobotExecutorObj().getExecutorProxyActive())) {771 Proxy proxy = new Proxy();772 proxy.setHttpProxy(tCExecution.getRobotExecutorObj().getExecutorProxyHost() + ":" + tCExecution.getRemoteProxyPort());773 proxy.setSslProxy(tCExecution.getRobotExecutorObj().getExecutorProxyHost() + ":" + tCExecution.getRemoteProxyPort());774 proxy.setNoProxy("");775 proxy.setProxyType(Proxy.ProxyType.MANUAL);776 LOG.debug("Setting Chrome proxy to : {}", proxy);777 optionsCH.setCapability(DEFAULT_PROXY_HOST, proxy);778 }779 // Accept Insecure Certificates.780 if (tCExecution.getRobotObj() != null && !tCExecution.getRobotObj().isAcceptInsecureCerts()) {781 optionsCH.setAcceptInsecureCerts(false);782 } else {783 optionsCH.setAcceptInsecureCerts(true);784 }785 // Extra Browser Parameters.786 if (tCExecution.getRobotObj() != null && !StringUtil.isNullOrEmpty(tCExecution.getRobotObj().getExtraParam())) {787 optionsCH.addArguments(tCExecution.getRobotObj().getExtraParam());788 }789 // Collect Logs on Selenium side.790 optionsCH.setCapability("goog:loggingPrefs", logPrefs);791 return optionsCH;792 case "safari":793 SafariOptions optionsSA = new SafariOptions();794 if (tCExecution.getRobotExecutorObj() != null && "Y".equals(tCExecution.getRobotExecutorObj().getExecutorProxyActive())) {795 Proxy proxy = new Proxy();796 proxy.setHttpProxy(tCExecution.getRobotExecutorObj().getExecutorProxyHost() + ":" + tCExecution.getRemoteProxyPort());797 proxy.setSslProxy(tCExecution.getRobotExecutorObj().getExecutorProxyHost() + ":" + tCExecution.getRemoteProxyPort());798 optionsSA.setProxy(proxy);799 }800 return optionsSA;801 case "IE":802 InternetExplorerOptions optionsIE = new InternetExplorerOptions();803 // Add the WebDriver proxy capability.804 if (tCExecution.getRobotExecutorObj() != null && "Y".equals(tCExecution.getRobotExecutorObj().getExecutorProxyActive())) {805 Proxy proxy = new Proxy();806 proxy.setHttpProxy(tCExecution.getRobotExecutorObj().getExecutorProxyHost() + ":" + tCExecution.getRemoteProxyPort());807 proxy.setSslProxy(tCExecution.getRobotExecutorObj().getExecutorProxyHost() + ":" + tCExecution.getRemoteProxyPort());808 proxy.setProxyType(Proxy.ProxyType.MANUAL);809 LOG.debug("Setting IE proxy to : " + proxy.toString());810 optionsIE.setCapability(DEFAULT_PROXY_HOST, proxy);811 }812 return optionsIE;813 case "edge":814 EdgeOptions optionsED = new EdgeOptions();815 if (tCExecution.getRobotExecutorObj() != null && "Y".equals(tCExecution.getRobotExecutorObj().getExecutorProxyActive())) {816 Proxy proxy = new Proxy();817 proxy.setHttpProxy(tCExecution.getRobotExecutorObj().getExecutorProxyHost() + ":" + tCExecution.getRemoteProxyPort());818 proxy.setSslProxy(tCExecution.getRobotExecutorObj().getExecutorProxyHost() + ":" + tCExecution.getRemoteProxyPort());819 optionsED.setProxy(proxy);820 }821 return optionsED;822 case "opera":823 OperaOptions optionsOP = new OperaOptions();824 if (tCExecution.getRobotExecutorObj() != null && "Y".equals(tCExecution.getRobotExecutorObj().getExecutorProxyActive())) {825 Proxy proxy = new Proxy();826 proxy.setHttpProxy(tCExecution.getRobotExecutorObj().getExecutorProxyHost() + ":" + tCExecution.getRemoteProxyPort());827 proxy.setSslProxy(tCExecution.getRobotExecutorObj().getExecutorProxyHost() + ":" + tCExecution.getRemoteProxyPort());828 optionsOP.setProxy(proxy);829 }830 optionsOP.setCapability("browser", "opera");831 // Forcing a profile in order to force UserAgent. This has been commented because it fail when using BrowserStack that does not allow to create the correcponding profile folder.832// if (!StringUtil.isNullOrEmpty(usedUserAgent)) {833// optionsOP.setCapability("opera.profile", "{profileName: \"foo\",userAgent: \"" + usedUserAgent + "\"}");834// }835 return optionsOP;836 case "android":837 if (tCExecution.getRobotExecutorObj() != null && "Y".equals(tCExecution.getRobotExecutorObj().getExecutorProxyActive())) {838 Proxy proxy = new Proxy();839 proxy.setHttpProxy(tCExecution.getRobotExecutorObj().getExecutorProxyHost() + ":" + tCExecution.getRemoteProxyPort());840 proxy.setSslProxy(tCExecution.getRobotExecutorObj().getExecutorProxyHost() + ":" + tCExecution.getRemoteProxyPort());841 }842 capabilities = DesiredCapabilities.android();843 break;844 case "ipad":845 capabilities = DesiredCapabilities.ipad();846 break;847 case "iphone":848 capabilities = DesiredCapabilities.iphone();849 break;850 case "":851 // We allow to start a Selenium session without any browser defined. This is used to support bundleId capability.852 break;853 // Unfortunatly Yandex is not yet supported on BrowserStack. Once it will be it should look like that:854// case "yandex":855// capabilities = new DesiredCapabilities();856// capabilities.setCapability("browser", "Yandex");857// capabilities.setCapability("browser_version", "14.12");858// break;859 default:860 LOG.warn("Not supported Browser : " + browser);861 MessageGeneral mes = new MessageGeneral(MessageGeneralEnum.EXECUTION_FA_SELENIUM);862 mes.setDescription(mes.getDescription().replace("%MES%", "Browser '" + browser + "' is not supported"));863 mes.setDescription("Not supported Browser : " + browser);864 throw new CerberusException(mes);865 }866 } catch (CerberusException ex) {867 MessageGeneral mes = new MessageGeneral(MessageGeneralEnum.EXECUTION_FA_SELENIUM);868 mes.setDescription(mes.getDescription().replace("%MES%", "Failed to set capability on the browser '" + browser + "' due to " + ex.getMessageError().getDescription()));869 throw new CerberusException(mes);870 }871 return capabilities;872 }873 /**874 * This method determine which user agent to use.875 *876 * @param userAgentTestCase877 * @param userAgentRobot878 * @return String containing the userAgent to use879 */880 private String getUserAgentToUse(String userAgentTestCase, String userAgentRobot) {881 if (StringUtil.isNullOrEmpty(userAgentRobot) && StringUtil.isNullOrEmpty(userAgentTestCase)) {882 return "";883 } else {884 return StringUtil.isNullOrEmpty(userAgentTestCase) ? userAgentRobot : userAgentTestCase;885 }886 }887 /**888 * This method determine which screenSize to use.889 *890 * @param screenSizeTestCase891 * @param screenSizeRobot892 * @return String containing the screensize to use893 */894 private String getScreenSizeToUse(String screenSizeTestCase, String screenSizeRobot) {895 if (StringUtil.isNullOrEmpty(screenSizeRobot) && StringUtil.isNullOrEmpty(screenSizeTestCase)) {896 return "";897 } else {898 return StringUtil.isNullOrEmpty(screenSizeTestCase) ? screenSizeRobot : screenSizeTestCase;899 }900 }901 @Override902 public boolean stopServer(TestCaseExecution tce) {903 Session session = tce.getSession();904 if (session != null && session.isStarted()) {905 try {906 // Wait 2 sec till HAR is exported907 Thread.sleep(2000);908 } catch (InterruptedException ex) {909 LOG.error(ex.toString(), ex);910 }911 // We remove manually the package if it is defined.912 if (session.getAppiumDriver() != null && tce.getCountryEnvironmentParameters() != null913 && !StringUtil.isNullOrEmpty(tce.getCountryEnvironmentParameters().getMobilePackage())) {914 session.getAppiumDriver().removeApp(tce.getCountryEnvironmentParameters().getMobilePackage());915 }916 // We lock device if deviceLockUnlock is active.917 if (tce.getRobotExecutorObj() != null && session.getAppiumDriver() != null && session.getAppiumDriver() instanceof LocksDevice918 && "Y".equals(tce.getRobotExecutorObj().getDeviceLockUnlock())) {919 ((LocksDevice) session.getAppiumDriver()).lockDevice();920 }921 // We record Selenium log at the end of the execution.922 switch (tce.getRobotProvider()) {923 case TestCaseExecution.ROBOTPROVIDER_BROWSERSTACK:924 case TestCaseExecution.ROBOTPROVIDER_NONE:925 try {926 tce.addFileList(recorderService.recordSeleniumLog(tce));927 } catch (Exception ex) {928 LOG.error("Exception Getting Selenium Logs {}", tce.getId(), ex);929 }930 break;931 default:932 }933 // We record Console log at the end of the execution.934 switch (tce.getRobotProvider()) {935 case TestCaseExecution.ROBOTPROVIDER_BROWSERSTACK:936 case TestCaseExecution.ROBOTPROVIDER_NONE:937 try {938 tce.addFileList(recorderService.recordConsoleLog(tce));939 } catch (Exception ex) {940 LOG.error("Exception Getting Console Logs " + tce.getId(), ex);941 }942 break;943 default:944 }945 // We record Har log at the end of the execution.946 switch (tce.getRobotProvider()) {947 case TestCaseExecution.ROBOTPROVIDER_BROWSERSTACK:948// try {949// String url = "http://api.bs.com/getHar?uuid=" + tce.getRobotSessionID();950// tce.addFileList(recorderService.recordBrowserstackHarLog(tce, url));951// } catch (Exception ex) {952// LOG.error("Exception Getting Browserstack HAR File " + tce.getId(), ex);953// }954 break;955 case TestCaseExecution.ROBOTPROVIDER_NONE:956 break;957 default:958 }959 try {960 // Get Har File when Cerberus Executor is activated.961 // If proxy started and parameter verbose >= 1 activated962 if ("Y".equals(tce.getRobotExecutorObj().getExecutorProxyActive())963 && tce.getVerbose() >= 1 && (parameterService.getParameterBooleanByKey("cerberus_networkstatsave_active", tce.getSystem(), false))) {964 // Before collecting the stats, we wait the network idles for few minutes965 executorService.waitForIdleNetwork(tce.getRobotExecutorObj().getExecutorExtensionHost(), tce.getRobotExecutorObj().getExecutorExtensionPort(), tce.getRemoteProxyUUID(), tce.getSystem());966 // We now get the har data.967 JSONObject har = executorService.getHar(null, false, tce.getRobotExecutorObj().getExecutorExtensionHost(), tce.getRobotExecutorObj().getExecutorExtensionPort(), tce.getRemoteProxyUUID(), tce.getSystem(), 0);968 // and enrich it with stat entry.969 har = harService.enrichWithStats(har, tce.getCountryEnvironmentParameters().getDomain(), tce.getSystem(), tce.getNetworkTrafficIndexList());970 // We convert the har to database record HttpStat and save it to database.971 try {972 AnswerItem<TestCaseExecutionHttpStat> answHttpStat = testCaseExecutionHttpStatService.convertFromHarWithStat(tce, har);973 tce.setHttpStat(answHttpStat.getItem());974 testCaseExecutionHttpStatService.create(answHttpStat.getItem());975 } catch (Exception ex) {976 LOG.warn("Exception collecting and saving stats for execution {} Exception : {}", tce.getId(), ex.toString());977 }978 }979 } catch (Exception ex) {980 LOG.error("Exception Getting Har File from Cerberus Executor {}", tce.getId(), ex);981 }982 // We Stop the Robot Session (Selenium or Appium).983 LOG.info("Stop execution robot session");984 if (tce.getRobotProvider().equals(TestCaseExecution.ROBOTPROVIDER_KOBITON)) {985 // For Kobiton, we should first close Appium session.986 if (session.getAppiumDriver() != null) {987 session.getAppiumDriver().close();988 }989 if (session.getDriver() != null) {990 session.getDriver().quit();991 }992 } else {993 session.quit();994 }995 return true;996 }997 return false;998 }999 private static void getIPOfNode(TestCaseExecution tCExecution) {1000 try {1001 Session session = tCExecution.getSession();1002 HttpCommandExecutor ce = (HttpCommandExecutor) ((RemoteWebDriver) session.getDriver()).getCommandExecutor();1003 SessionId sessionId = ((RemoteWebDriver) session.getDriver()).getSessionId();1004 String hostName = ce.getAddressOfRemoteServer().getHost();1005 int port = ce.getAddressOfRemoteServer().getPort();1006 HttpHost host = new HttpHost(hostName, port);1007 HttpClient client = HttpClientBuilder.create().setRedirectStrategy(new LaxRedirectStrategy()).build();1008 URL sessionURL = new URL(RobotServerService.getBaseUrl(session.getHost(), session.getPort()) + "/grid/api/testsession?session=" + sessionId);1009 BasicHttpEntityEnclosingRequest r = new BasicHttpEntityEnclosingRequest("GET", sessionURL.toExternalForm());1010 LOG.debug("Calling Hub to get the node information. {}", sessionURL);1011 HttpResponse response = client.execute(host, r);1012 if (!response.getStatusLine().toString().contains("403")1013 && !response.getEntity().getContentType().getValue().contains("text/html")) {1014 InputStream contents = response.getEntity().getContent();1015 StringWriter writer = new StringWriter();1016 IOUtils.copy(contents, writer, "UTF8");1017 JSONObject object = new JSONObject(writer.toString());1018 if (object.has("proxyId")) {1019 URL myURL = new URL(object.getString("proxyId"));1020 if ((myURL.getHost() != null) && (myURL.getPort() != -1)) {1021 LOG.debug("Get remote node information : {} - {}", myURL.getHost(), myURL.getPort());1022 tCExecution.setRobotHost(myURL.getHost());1023 tCExecution.setRobotPort(String.valueOf(myURL.getPort()));1024 // Node information at session level is now overwrite with real values.1025 tCExecution.getSession().setNodeHost(myURL.getHost());1026 tCExecution.getSession().setNodePort(String.valueOf(myURL.getPort()));1027 }1028 } else {1029 LOG.debug("'proxyId' json data not available from remote Selenium Server request : {}", writer);1030 }1031 }1032 } catch (IOException | JSONException ex) {1033 LOG.error(ex.toString(), ex);1034 }1035 }1036 @Override1037 public Capabilities getUsedCapabilities(Session session) {1038 return ((HasCapabilities) session.getDriver()).getCapabilities();1039 }1040 private void setScreenSize(WebDriver driver, Integer width, Integer length) {1041 driver.manage().window().setPosition(new Point(0, 0));1042 driver.manage().window().setSize(new Dimension(width, length));1043 }1044 private String getScreenSize(WebDriver driver) {1045 return driver.manage().window().getSize().width + "*" + driver.manage().window().getSize().height;1046 }1047 private static String getBaseUrl(String host, String port) {1048 String baseurl = "";1049 if (!StringUtil.isNullOrEmpty(host) && (host.contains("https://") || host.contains("http://"))) {1050 baseurl = host;1051 } else {1052 baseurl = "http://" + host;1053 }1054 if (!StringUtil.isNullOrEmpty(port) && Integer.valueOf(port) > 0) {1055 baseurl += ":" + port;1056 }1057 return baseurl;1058 }1059 @Override1060 public HashMap<String, String> getMapFromOptions(JSONArray options) {1061 HashMap<String, String> result = new HashMap<>();1062 if (options.length() > 0) {1063 LOG.debug("Converting {} To Map.", options);1064 for (int i = 0; i < options.length(); i++) {1065 try {1066 JSONObject option = options.getJSONObject(i);1067 if (option.getBoolean("act")) {1068 result.put(option.getString("option"), option.getString("value"));1069 }1070 } catch (JSONException ex) {1071 LOG.error(ex, ex);1072 return result;1073 }1074 }1075 }1076 return result;1077 }1078 @Override1079 public void setOptionsTimeout(Session session, Integer timeout) {1080 if (session != null) {1081 LOG.debug("Setting Robot Options timeout to : {}", timeout);1082 session.setCerberus_selenium_wait_element(timeout);1083 session.setCerberus_appium_wait_element(timeout);1084 session.setCerberus_sikuli_wait_element(timeout);1085 }1086 }1087 @Override1088 public void setOptionsHighlightElement(Session session, Integer highlightElement) {1089 if (session != null) {1090 LOG.debug("Setting Robot Option highlightElement to : {}", highlightElement);1091 session.setCerberus_selenium_highlightElement(highlightElement);1092 session.setCerberus_sikuli_highlightElement(highlightElement);1093 }1094 }1095 @Override1096 public void setOptionsMinSimilarity(Session session, String minSimilarity) {1097 if (session != null) {1098 LOG.debug("Setting Robot Option minSimilarity to : {}", minSimilarity);1099 session.setCerberus_sikuli_minSimilarity(minSimilarity);1100 }1101 }1102 @Override1103 public void setOptionsTypeDelay(Session session, String typeDelay) {1104 if (session != null) {1105 LOG.debug("Setting Robot Option typeDelay to : {}", typeDelay);1106 session.setCerberus_sikuli_typeDelay(typeDelay);1107 }1108 }1109 @Override1110 public void setOptionsToDefault(Session session) {1111 if (session != null) {1112 LOG.debug("Setting Robot Timeout back to default values : Selenium {} Appium {} Sikuli {}",1113 session.getCerberus_selenium_wait_element_default(),1114 session.getCerberus_appium_wait_element_default(),1115 session.getCerberus_sikuli_wait_element_default());1116 session.setCerberus_selenium_wait_element(session.getCerberus_selenium_wait_element_default());1117 session.setCerberus_appium_wait_element(session.getCerberus_appium_wait_element_default());1118 session.setCerberus_sikuli_wait_element(session.getCerberus_sikuli_wait_element_default());1119 LOG.debug("Setting Robot highlightElement back to default values : Selenium {} Sikuli {}",1120 session.getCerberus_selenium_highlightElement_default(),1121 session.getCerberus_sikuli_highlightElement_default());1122 session.setCerberus_selenium_highlightElement(session.getCerberus_selenium_highlightElement_default());1123 session.setCerberus_sikuli_highlightElement(session.getCerberus_sikuli_highlightElement_default());1124 LOG.debug("Setting Robot minSimilarity back to default values : {}", session.getCerberus_sikuli_minSimilarity_default());1125 session.setCerberus_sikuli_minSimilarity(session.getCerberus_sikuli_minSimilarity_default());1126 LOG.debug("Setting Robot typeDelay back to default values : {}", session.getCerberus_sikuli_typeDelay_default());1127 session.setCerberus_sikuli_typeDelay(session.getCerberus_sikuli_typeDelay_default());1128 }1129 }1130}...

Full Screen

Full Screen

Source:Session.java Github

copy

Full Screen

...117 }118 public String getCerberus_sikuli_typeDelay() {119 return cerberus_sikuli_typeDelay;120 }121 public void setCerberus_sikuli_typeDelay(String cerberus_sikuli_typeDelay) {122 this.cerberus_sikuli_typeDelay = cerberus_sikuli_typeDelay;123 }124 public String getCerberus_sikuli_typeDelay_default() {125 return cerberus_sikuli_typeDelay_default;126 }127 public void setCerberus_sikuli_typeDelay_default(String cerberus_sikuli_typeDelay_default) {128 this.cerberus_sikuli_typeDelay_default = cerberus_sikuli_typeDelay_default;129 }130 public String getNodeHost() {131 return nodeHost;132 }133 public void setNodeHost(String nodeHost) {134 this.nodeHost = nodeHost;135 }136 public String getNodePort() {137 return nodePort;138 }139 public void setNodePort(String nodePort) {140 this.nodePort = nodePort;141 }...

Full Screen

Full Screen

setCerberus_sikuli_typeDelay

Using AI Code Generation

copy

Full Screen

1import org.cerberus.engine.entity.Session;2public class 3 {3 public static void main(String[] args) {4 Session.setCerberus_sikuli_typeDelay(1);5 }6}7import org.cerberus.engine.entity.Session;8public class 4 {9 public static void main(String[] args) {10 System.out.println(Session.getCerberus_sikuli_typeDelay());11 }12}13import org.cerberus.engine.entity.Session;14public class 5 {15 public static void main(String[] args) {16 Session.setCerberus_sikuli_waitAfterClick(1);17 }18}19import org.cerberus.engine.entity.Session;20public class 6 {21 public static void main(String[] args) {22 System.out.println(Session.getCerberus_sikuli_waitAfterClick());23 }24}25import org.cerberus.engine.entity.Session;26public class 7 {27 public static void main(String[] args) {28 Session.setCerberus_sikuli_waitAfterDoubleClick(1);29 }30}31import org.cerberus.engine.entity.Session;32public class 8 {33 public static void main(String[] args) {34 System.out.println(Session.getCerberus_sikuli_waitAfterDoubleClick());35 }36}37import org.cerberus.engine.entity.Session;38public class 9 {39 public static void main(String[] args) {

Full Screen

Full Screen

setCerberus_sikuli_typeDelay

Using AI Code Generation

copy

Full Screen

1import org.cerberus.engine.entity.Session;2import org.cerberus.engine.entity.SessionFactory;3import org.cerberus.engine.entity.CerberusSession;4import org.cerberus.engine.entity.CerberusSessionFactory;5import org.cerberus.engine.entity.CerberusSessionException;6import org.cerberus.engine.entity.CerberusSessionTimeoutException;7import org.cerberus.engine.entity.CerberusSessionConfigurationException;8import org.cerberus.engine.entity.CerberusSessionConnectionException;9import org.cerberus.engine.entity.CerberusSessionExecutionException;10import org.cerberus.engine.entity.CerberusSessionExecutionTimeoutException;11import org.cerberus.engine.entity.CerberusSessionExecutionInterruptedException;12import org.cerberus.engine.entity.CerberusSessionExecutionUnexpectedException;

Full Screen

Full Screen

setCerberus_sikuli_typeDelay

Using AI Code Generation

copy

Full Screen

1Session.setCerberus_sikuli_typeDelay(0.5);2type("Hello World");3Session.setCerberus_sikuli_typeDelay(1);4type("Hello World");5Session.setCerberus_sikuli_typeDelay(2);6type("Hello World");7Session.setCerberus_sikuli_typeDelay(3);8type("Hello World");9Session.setCerberus_sikuli_typeDelay(4);10type("Hello World");11Session.setCerberus_sikuli_typeDelay(5);12type("Hello World");13Session.setCerberus_sikuli_typeDelay(6);14type("Hello World");15Session.setCerberus_sikuli_typeDelay(7);16type("Hello World");17Session.setCerberus_sikuli_typeDelay(8);18type("Hello World");19Session.setCerberus_sikuli_typeDelay(9);20type("Hello World");21Session.setCerberus_sikuli_typeDelay(10);22type("Hello World");23Session.setCerberus_sikuli_typeDelay(11);24type("Hello World");25Session.setCerberus_sikuli_typeDelay(12);26type("Hello World");27Session.setCerberus_sikuli_typeDelay(13);28type("Hello World");

Full Screen

Full Screen

setCerberus_sikuli_typeDelay

Using AI Code Generation

copy

Full Screen

1import org.cerberus.engine.entity.Session;2import org.sikuli.script.*;3public class 3 {4 public static void main(String[] args) throws Exception {5 Screen s = new Screen();6 Session.setCerberus_sikuli_typeDelay(0);7 s.type("a", Key.CTRL);8 }9}10import org.cerberus.engine.entity.Session;11import org.sikuli.script.*;12public class 4 {13 public static void main(String[] args) throws Exception {14 Screen s = new Screen();15 Session.setCerberus_sikuli_waitScanRate(200);16 s.type("a", Key.CTRL);17 }18}

Full Screen

Full Screen

setCerberus_sikuli_typeDelay

Using AI Code Generation

copy

Full Screen

1import org.cerberus.engine.entity.Session;2Session session = new Session();3session.setCerberus_sikuli_typeDelay(0.5);4type("Hello world");5type("Hello world", Key.ENTER);6type("Hello world", Key.ENTER, 3);7type("Hello world", Key.ENTER, 3, 3);8type("Hello world", Key.ENTER, 3, 3, 1);9type("Hello world", Key.ENTER, 3, 3, 1, "US");10type("Hello world", Key.ENTER, 3, 3, 1, "US", "DEFAULT");

Full Screen

Full Screen

setCerberus_sikuli_typeDelay

Using AI Code Generation

copy

Full Screen

1import org.cerberus.engine.entity.Session;2import org.cerberus.engine.entity.CerberusTest;3import org.cerberus.engine.entity.CerberusAction;4public class 3 extends CerberusTest {5 public void test() {6 Session.setCerberus_sikuli_typeDelay(1000);7 CerberusAction action = new CerberusAction();8 action.setCerberus_action("type");9 action.setCerberus_identifier("txtUsername");10 action.setCerberus_value("admin");11 action.execute();12 }13}14import org.cerberus.engine.entity.Session;15import org.cerberus.engine.entity.CerberusTest;16import org.cerberus.engine.entity.CerberusAction;17public class 4 extends CerberusTest {18 public void test() {19 Session.setCerberus_sikuli_waitAfterClick(1000);20 CerberusAction action = new CerberusAction();21 action.setCerberus_action("click");22 action.setCerberus_identifier("btnLogin");23 action.execute();24 }25}26import org.cerberus

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.

Run Cerberus-source automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Most used method in Session

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful