How to use implicitlyWait method of org.openqa.selenium.Interface WebDriver.Timeouts class

Best Selenium code snippet using org.openqa.selenium.Interface WebDriver.Timeouts.implicitlyWait

Source:ThucydidesSystemProperty.java Github

copy

Full Screen

1package net.thucydides.core;2import net.serenitybdd.core.environment.EnvironmentSpecificConfiguration;3import net.thucydides.core.util.EnvironmentVariables;4import org.apache.commons.lang3.StringUtils;5import org.slf4j.Logger;6import org.slf4j.LoggerFactory;7import java.util.ArrayList;8import java.util.List;9import java.util.Optional;10/**11 * Properties that can be passed to a web driver test to customize its behaviour.12 * The properties can be passed as system properties or placed in the 'thucydides.properties' file using a lower-case,13 * period-separated format. For example, WEBDRIVER_DRIVER is passed as -Dwebdriver.driver=firefox14 *15 * @author johnsmart16 */17public enum ThucydidesSystemProperty {18 /**19 * The WebDriver driver - firefox, chrome, iexplorer, safari.20 */21 WEBDRIVER_DRIVER,22 /**23 * A shortcut for 'webdriver.driver'.24 */25 DRIVER,26 /**27 * If using a provided driver, what type is it.28 * The implementation class needs to be defined in the webdriver.provided.{type} system property.29 */30 WEBDRIVER_PROVIDED_TYPE,31 /**32 * The default starting URL for the application, and base URL for relative paths.33 */34 WEBDRIVER_BASE_URL,35 /**36 * The URL to be used for remote drivers (including a selenium grid hub)37 */38 WEBDRIVER_REMOTE_URL,39 /**40 * What port to run PhantomJS on (used in conjunction with webdriver.remote.url to41 * register with a Selenium hub, e.g. -Dphantomjs.webdriver=5555 -Dwebdriver.remote.url=http://localhost:444442 */43 // PHANTOMJS_WEBDRIVER_PORT,44 /**45 * Sets a number of common chrome options useful for automated testing.46 * In particular, this includes: --enable-automation --test-type47 * Set to false by default48 */49 USE_CHROME_AUTOMATION_OPTIONS,50 /**51 * If the automatic webdriver download should happen.52 */53 WEBDRIVER_AUTODOWNLOAD,54 /**55 * If set to true, PageObject find methods will retry after a short pause when a stale element exception occurs.56 */57 WEBDRIVER_RETRY_ON_STALE_ELEMENT_EXCEPTION,58 /**59 * The driver to be used for remote drivers60 */61 WEBDRIVER_REMOTE_DRIVER,62 WEBDRIVER_REMOTE_BROWSER_VERSION,63 WEBDRIVER_REMOTE_OS,64 /**65 * The minimum time to wait between screenshots.66 * Trying to take screenshots too often can slow down the tests.67 */68 WEBDRIVER_MIN_SCREENSHOT_INTERVAL,69 /**70 * Path to the Internet Explorer driver, if it is not on the system path.71 */72 WEBDRIVER_IE_DRIVER,73 /**74 * Path to the Edge driver, if it is not on the system path.75 */76 WEBDRIVER_EDGE_DRIVER,77 /**78 * Path to the Chrome driver, if it is not on the system path.79 */80 WEBDRIVER_CHROME_DRIVER,81 /**82 * Old property for chrome.binary83 */84 WEBDRIVER_CHROME_BINARY,85 /**86 * Path to the Chrome binary, if it is not on the system path.87 */88 CHROME_BINARY,89 @Deprecated90 THUCYDIDES_PROJECT_KEY,91 /**92 * A unique identifier for the project under test, used to record test statistics.93 */94 SERENITY_PROJECT_KEY,95 @Deprecated96 THUCYDIDES_PROJECT_NAME,97 /**98 * What name should appear on the reports99 */100 SERENITY_PROJECT_NAME,101 /**102 * What name should appear on the email summary report103 */104 SERENITY_SUMMARY_REPORT_TITLE,105 /**106 * What file name should be used for the email summary report (defaults to serenity-summary.html)107 */108 SERENITY_SUMMARY_REPORT_FILENAME,109 /**110 * A subtitle to appear in the Serenity HTML reports.111 * This can be useful to describe a qualified or filtered report.112 */113 REPORT_SUBTITLE,114 REPORT_TIMEOUT_THREADDUMPS,115 /**116 * Link to the generated Serenity report to embed in the emailable summary report.117 */118 SERENITY_REPORT_URL,119 @Deprecated120 THUCYDIDES_HOME,121 /**122 * The home directory for Thucydides output and data files - by default, $USER_HOME/.thucydides123 */124 SERENITY_HOME,125 @Deprecated126 THUCYDIDES_REPORT_RESOURCES,127 /**128 * Indicates a directory from which the resources for the HTML reports should be copied.129 * This directory currently needs to be provided in a JAR file.130 */131 SERENITY_REPORT_RESOURCES,132 /**133 * Encoding for reports output134 */135 @Deprecated136 THUCYDIDES_REPORT_ENCODING,137 /**138 * Encoding for reports output139 */140 SERENITY_REPORT_ENCODING,141 REMOTE_PLATFORM,142 @Deprecated143 THUCYDIDES_OUTPUT_DIRECTORY("thucydides.outputDirectory"),144 /**145 * Where should reports be generated (use the system property 'serenity.outputDirectory').146 */147 SERENITY_OUTPUT_DIRECTORY("serenity.outputDirectory"),148 /**149 * Default name of report with configurations. It will contains some values that was used during generation of reports150 */151 @Deprecated152 THUCYDIDES_CONFIGURATION_REPORT("thucydides.configuration.json"),153 /**154 * Default name of report with configurations. It will contains some values that was used during generation of reports155 */156 SERENITY_CONFIGURATION_REPORT("serenity.configuration.json"),157 @Deprecated158 THUCYDIDES_FLOW_REPORTS_DIR("flow"),159 /**160 * Default name of folder, with reports about test flow and aggregation report generation161 */162 SERENITY_FLOW_REPORTS_DIR("flow"),163 /**164 * Should Thucydides only store screenshots for failing steps?165 * This can save disk space and speed up the tests somewhat. Useful for data-driven testing.166 *167 * @deprecated This property is still supported, but thucydides.take.screenshots provides more fine-grained control.168 */169 @Deprecated170 THUCYDIDES_ONLY_SAVE_FAILING_SCREENSHOTS,171 @Deprecated172 THUCYDIDES_DRIVER_CAPABILITIES,173 /**174 * A set of user-defined capabilities to be used to configure the WebDriver driver.175 * Capabilities should be passed in as a space or semi-colon-separated list of key:value pairs, e.g.176 * "build:build-1234; max-duration:300; single-window:true; tags:[tag1,tag2,tag3]"177 */178 SERENITY_DRIVER_CAPABILITIES,179 /**180 * Should Thucydides take screenshots for every clicked button and every selected link?181 * By default, a screenshot will be stored at the start and end of each step.182 * If this option is set to true, Thucydides will record screenshots for any action performed183 * on a WebElementFacade, i.e. any time you use an expression like element(...).click(),184 * findBy(...).click() and so on.185 * This will be overridden if the THUCYDIDES_ONLY_SAVE_FAILING_SCREENSHOTS option is set to true.186 *187 * @deprecated This property is still supported, but thucydides.take.screenshots provides more fine-grained control.188 */189 @Deprecated190 THUCYDIDES_VERBOSE_SCREENSHOTS,191 @Deprecated192 THUCYDIDES_VERBOSE_STEPS,193 /**194 * If set to true, WebElementFacade events and other step actions will be logged to the console.195 */196 SERENITY_VERBOSE_STEPS,197 VERBOSE_REPORTING,198 /**199 * Words that will be recognised as pronouns by Serenity Screenplay in Cucumber and used to refer to the200 * actor in the spotlight, rather than as an actor name. Defaults to "he" and "she"201 */202 SCREENPLAY_PRONOUNS,203 @Deprecated204 THUCYDIDES_TAKE_SCREENSHOTS,205 /**206 * Fine-grained control over when screenshots are to be taken.207 * This property accepts the following values:208 * <ul>209 * <li>FOR_EACH_ACTION</li>210 * <li>BEFORE_AND_AFTER_EACH_STEP</li>211 * <li>AFTER_EACH_STEP</li>212 * <li>FOR_FAILURES</li>213 * </ul>214 */215 SERENITY_TAKE_SCREENSHOTS,216 @Deprecated217 THUCYDIDES_REPORTS_SHOW_STEP_DETAILS,218 /**219 * Should Thucydides display detailed information in the test result tables.220 * If this is set to true, test result tables will display a breakdown of the steps by result.221 * This is false by default.222 */223 SERENITY_REPORTS_SHOW_STEP_DETAILS,224 @Deprecated225 THUCYDIDES_REPORT_SHOW_MANUAL_TESTS,226 /**227 * Show statistics for manual tests in the test reports.228 */229 SERENITY_REPORT_SHOW_MANUAL_TESTS,230 /**231 * A comma-separated list of tags which should not be included the reports.232 * This can be helpful for technical tags which are not relevant to documentation,233 * and can reduce the size and time taken to produce the reports.234 */235 SERENITY_REPORT_EXCLUDE_TAGS,236 /**237 * Legacy form of "serenity.report.exclude.tags"238 */239 HIDDEN_TAGS,240 @Deprecated241 THUCYDIDES_REPORT_SHOW_RELEASES,242 /**243 * Report on releases244 */245 SERENITY_REPORT_SHOW_RELEASES,246 /**247 * Use patterns as well as colors for the graphs and charts.248 */249 SERENITY_REPORT_ACCESSIBILITY,250 /**251 *252 */253 SERENITY_REPORT_DURATIONS,254 @Deprecated255 THUCYDIDES_REPORT_SHOW_PROGRESS,256 SERENITY_REPORT_SHOW_PROGRESS,257 @Deprecated258 THUCYDIDES_REPORT_SHOW_HISTORY,259 SERENITY_REPORT_SHOW_HISTORY,260 @Deprecated261 THUCYDIDES_REPORT_SHOW_TAG_MENUS,262 SERENITY_REPORT_SHOW_TAG_MENUS,263 @Deprecated264 THUCYDIDES_REPORT_TAG_MENUS,265 SERENITY_REPORT_TAG_MENUS,266 @Deprecated267 THUCYDIDES_EXCLUDE_UNRELATED_REQUIREMENTS_OF_TYPE,268 @Deprecated269 SERENITY_EXCLUDE_UNRELATED_REQUIREMENTS_OF_TYPE,270 @Deprecated271 THUCYDIDES_RESTART_BROWSER_FREQUENCY,272 /**273 * Set to true to only display requirements that contain test outcomes.274 * Useful when running a test suite with a filter.275 */276 SERENITY_REPORT_HIDE_EMPTY_REQUIREMENTS,277 /**278 * Restart the browser every so often during data-driven tests.279 */280 SERENITY_RESTART_BROWSER_FREQUENCY,281 @Deprecated282 THUCYDIDES_RESTART_BROWSER_FOR_EACH,283 /**284 * Indicate when a browser should be restarted during a test run.285 * Can be one of: example, scenario, story, feature, never286 */287 SERENITY_RESTART_BROWSER_FOR_EACH,288 @Deprecated289 THUCYDIDES_DIFFERENT_BROWSER_FOR_EACH_ACTOR,290 /**291 * When multiple actors are used with the Screenplay pattern, a separate browser is configured for each actor.292 * Set this property to false if you want actors use a common browser.293 * This can be useful if actors are used to illustrate the intent of a test, but no tests use more than one actor simultaneously294 */295 SERENITY_DIFFERENT_BROWSER_FOR_EACH_ACTOR,296 @Deprecated297 THUCYDIDES_STEP_DELAY,298 /**299 * Pause (in ms) between each test step.300 */301 SERENITY_STEP_DELAY,302 @Deprecated303 THUCYDIDES_TIMEOUT,304 /**305 * How long should the driver wait for elements not immediately visible, in seconds.306 *307 * @deprecated Use WEBDRIVER_TIMEOUTS_IMPLICITLYWAIT instead.308 */309 SERENITY_TIMEOUT,310 /**311 * Don't accept sites using untrusted certificates.312 * By default, Thucydides accepts untrusted certificates - use this to change this behaviour.313 */314 REFUSE_UNTRUSTED_CERTIFICATES,315 /**316 * Use the same browser for all tests (the "Highlander" rule)317 * Deprecated: Use THUCYDIDES_RESTART_BROWSER_FOR_EACH instead.318 */319 @Deprecated320 THUCYDIDES_USE_UNIQUE_BROWSER,321 @Deprecated322 THUCYDIDES_ESTIMATED_AVERAGE_STEP_COUNT,323 /**324 * The estimated number of steps in a pending scenario.325 * This is used for stories where no scenarios have been defined.326 */327 SERENITY_ESTIMATED_AVERAGE_STEP_COUNT,328 @Deprecated329 THUCYDIDES_ESTIMATED_TESTS_PER_REQUIREMENT,330 /**331 * The estimated number of tests in a typical story.332 * Used to estimate functional coverage in the requirements reports.333 */334 SERENITY_ESTIMATED_TESTS_PER_REQUIREMENT,335 @Deprecated336 THUCYDIDES_ISSUE_TRACKER_URL,337 /**338 * Base URL for the issue tracking system to be referred to in the reports.339 * If defined, any issues quoted in the form #1234 will be linked to the relevant340 * issue in the issue tracking system. Works with JIRA, Trac etc.341 */342 SERENITY_ISSUE_TRACKER_URL,343 @Deprecated344 THUCYDIDES_NATIVE_EVENTS,345 /**346 * Activate native events in Firefox.347 * This is true by default, but can cause issues with some versions of linux.348 */349 SERENITY_NATIVE_EVENTS,350 /**351 * If the base JIRA URL is defined, Thucydides will build the issue tracker url using the standard JIRA form.352 */353 JIRA_URL,354 /**355 * If defined, the JIRA project id will be prepended to issue numbers.356 */357 JIRA_PROJECT,358 /**359 * If defined, the JIRA username required to connect to JIRA.360 */361 JIRA_USERNAME,362 /**363 * If defined, the JIRA password required to connect to JIRA.364 */365 JIRA_PASSWORD,366 /**367 * The JIRA workflow is defined in this file.368 */369 SERENITY_JIRA_WORKFLOW,370 /**371 * If set to true, JIRA Workflow is active.372 */373 SERENITY_JIRA_WORKFLOW_ACTIVE,374 @Deprecated375 THUCYDIDES_HISTORY,376 /**377 * Base directory in which history files are stored.378 */379 SERENITY_HISTORY,380 @Deprecated381 THUCYDIDES_BROWSER_HEIGHT,382 /**383 * Redimension the browser to enable larger screenshots.384 */385 SERENITY_BROWSER_HEIGHT,386 @Deprecated387 THUCYDIDES_BROWSER_WIDTH,388 /**389 * Redimension the browser to enable larger screenshots.390 */391 SERENITY_BROWSER_WIDTH,392 @Deprecated393 THUCYDIDES_BROWSER_MAXIMIZED,394 /**395 * Set to true to get WebDriver to maximise the Browser window before the tests are executed.396 */397 SERENITY_BROWSER_MAXIMIZED,398 /**399 * Set the browser o full screen mode before tests are executed400 */401 SERENITY_BROWSER_FULL_SCREEN,402 @Deprecated403 THUCYDIDES_RESIZED_IMAGE_WIDTH,404 /**405 * Set to false if you don't want Serenity to resize the browser page at the start of a test406 * (Can be useful for custom Appium drivers)407 */408 SERENITY_BROWSER_RESIZING,409 /**410 * If set, resize screenshots to this size to save space.411 */412 SERENITY_RESIZED_IMAGE_WIDTH,413 @Deprecated414 THUCYDIDES_PUBLIC_URL,415 /**416 * Public URL where the Thucydides reports will be displayed.417 * This is mainly for use by plugins.418 */419 SERENITY_PUBLIC_URL,420 @Deprecated421 THUCYDIDES_ACTIVATE_FIREBUGS,422 /**423 * Activate the Firebugs plugin for firefox.424 * Useful for debugging, but not very when running the tests on a build server.425 * It is not activated by default.426 */427 SERENITY_ACTIVATE_FIREBUGS,428 /**429 * Enable applets in Firefox.430 * Use the system property 'security.enable_java'.431 * Applets slow down webdriver, so are disabled by default.432 */433 SECURITY_ENABLE_JAVA("security.enable_java"),434 @Deprecated435 THUCYDIDES_ACTIVATE_HIGHLIGHTING,436 SERENITY_ACTIVATE_HIGHLIGHTING,437 @Deprecated438 THUCYDIDES_BATCH_STRATEGY,439 /**440 * Batch strategy to use for parallel batches.441 * Allowed values - DIVIDE_EQUALLY (default) and DIVIDE_BY_TEST_COUNT442 */443 SERENITY_BATCH_STRATEGY,444 @Deprecated445 THUCYDIDES_BATCH_COUNT,446 /**447 * A deprecated property that is synonymous with thucydides.batch.size448 */449 SERENITY_BATCH_COUNT,450 @Deprecated451 THUCYDIDES_BATCH_SIZE,452 /**453 * If batch testing is being used, this is the size of the batches being executed.454 */455 SERENITY_BATCH_SIZE,456 @Deprecated457 THUCYDIDES_BATCH_NUMBER,458 /**459 * If batch testing is being used, this is the number of the batch being run on this machine.460 */461 SERENITY_BATCH_NUMBER,462 @Deprecated463 THUCYDIDES_PROXY_HTTP,464 @Deprecated465 THUCYDIDES_PROXY_HTTP_PORT("thucydides.proxy.http_port"),466 @Deprecated467 THUCYDIDES_PROXY_TYPE,468 @Deprecated469 THUCYDIDES_PROXY_USER,470 @Deprecated471 THUCYDIDES_PROXY_PASSWORD,472 /**473 * HTTP Proxy URL configuration474 * Specify which proxy to use for HTTP connections. Expected format is hostname:1234475 */476 SERENITY_PROXY_HTTP,477 /**478 * HTTP Proxy port configuration479 * Use 'thucydides.proxy.http_port'480 */481 SERENITY_PROXY_HTTP_PORT("serenity.proxy.http_port"),482 /**483 * HTTP Proxy username configuration484 */485 SERENITY_PROXY_USER,486 /**487 * HTTP Proxy password configuration488 */489 SERENITY_PROXY_PASSWORD,490 /**491 * SSL Proxy port configuration - serenity.proxy.sslProxyPort492 */493 SERENITY_PROXY_SSL_PORT("serenity.proxy.sslProxyPort"),494 /**495 * Specify which proxy to use for SSL connections.496 * Expected format is hostname.com:1234497 */498 SERENITY_PROXY_SSL("serenity.proxy.sslProxy"),499 /**500 * Specify which proxy to use for FTP connections.501 */502 SERENITY_PROXY_FTP,503 /**504 * Specifies whether to autodetect proxy settings.505 * Set to true to use proxy auto detection, false to leave proxy settings unspecified506 */507 SERENITY_PROXY_AUTODETECT,508 /**509 * Sets proxy bypass (noproxy) addresses510 * The proxy bypass (noproxy) addresses separated by commas511 */512 SERENITY_PROXY_NOPROXY,513 /**514 * Explicitly sets the proxy type, useful for forcing direct connection on Linux.515 * Takes a value of org.openqa.selenium.Proxy.ProxyType: DIRECT, MANUAL, PAC, RESERVED_1, AUTODETECT, SYSTEM, UNSPECIFIED516 */517 SERENITY_PROXY_TYPE,518 /**519 * Specifies the URL to be used for proxy auto-configuration.520 * Expected format is http://hostname.com:1234/pacfile.521 * This is required if getProxyType() is set to Proxy.ProxyType.PAC, ignored otherwise.522 */523 SERENITY_PROXY_AUTOCONFIG,524 /**525 * Specifies which proxy to use for SOCKS.526 * Expected format is hostname.com:1234527 */528 SERENITY_PROXY_SOCKS_PROXY,529 /**530 * Specifies a username for the SOCKS proxy. Supported by SOCKS v5 and above.531 */532 SERENITY_PROXY_SOCKS_USERNAME,533 /**534 * Gets the SOCKS proxy's password. Supported by SOCKS v5 and above.535 */536 SERENITY_PROXY_SOCKS_PASSWORD,537 /**538 * Specifies which version of SOCKS to use (4 or 5).539 */540 SERENITY_PROXY_SOCKS_VERSION,541 /**542 * Possible values are:none, eager or normal543 */544 SERENITY_DRIVER_PAGE_LOAD_STRATEGY,545 /**546 * Possible values are: accept, dismiss, accept and notify, dismiss and notify, ignore547 */548 SERENITY_DRIVER_UNEXPECTED_ALERT_BEHAVIOUR,549 /**550 * How long webdriver waits for elements to appear by default, in milliseconds.551 */552 WEBDRIVER_TIMEOUTS_IMPLICITLYWAIT,553 /**554 * Synonym for webdriver.wait.for.timeout555 */556 WEBDRIVER_TIMEOUTS_FLUENTWAIT,557 /**558 * How long webdriver waits by default when you use a fluent waiting method, in milliseconds.559 */560 WEBDRIVER_WAIT_FOR_TIMEOUT,561 @Deprecated562 THUCYDIDES_EXT_PACKAGES,563 /**564 * Extension packages. This is a list of packages that will be scanned for custom TagProvider implementations.565 * To add a custom tag provider, just implement the TagProvider interface and specify the root package for this566 * provider in this parameter.567 */568 SERENITY_EXT_PACKAGES,569 /**570 * Arguments to be passed to the Chrome driver, separated by commas.571 */572 CHROME_SWITCHES,573 /**574 * Path to a Chrome-driver specific extensions file575 */576 CHROME_EXTENSION,577 /**578 * Set this to true to activate the "w3c" experimental option for chrome. This needs to be set to true for Saucelabs and false for Browserstack579 */580 CHROME_DEFAULT_OPTIONS_W3C,581 /**582 * Preferences to be passed to the Firefox driver, separated by semi-colons (commas often appear in the preference583 * values.584 */585 FIREFOX_PREFERENCES,586 /**587 * Used to specify either chrome options or firefox preferences, depending on which driver is being used.588 */589 DRIVER_OPTIONS,590 /**591 * Try to create a Chrome driver using a driver service pool592 */593 WEBDRIVER_USE_DRIVER_SERVICE_POOL,594 /**595 * Full path to the Firefox profile to be used with Firefox.596 * You can include Java system properties ${user.dir}, ${user.home} and the Windows environment variables %APPDIR%597 * and %USERPROFILE (assuming these are correctly set in the environment)598 */599 WEBDRIVER_FIREFOX_PROFILE,600 @Deprecated601 THUCYDIDES_JQUERY_INTEGRATION,602 /**603 * Enable JQuery integration.604 * If set to true, JQuery will be injected into any page that does not already have it.605 * This option is activated by default, deactivating can speed up the page loading.606 * Set to false by default in Serenity 3.x607 */608 SERENITY_JQUERY_INTEGRATION,609 SAUCELABS_BROWSERNAME("saucelabs.browserName"),610 SAUCELABS_TARGET_PLATFORM,611 SAUCELABS_BROWSER_VERSION,612 SAUCELABS_TEST_NAME,613 /**614 * SauceLabs datacenter used for interaction with SauceLabs API and adding link to Serenity report615 * Examples:616 * US: us-west-1617 * Europe: eu-central-1618 */619 SAUCELABS_DATACENTER,620 /**621 * Saucelabs URL, including username and api key622 */623 SAUCELABS_URL,624 /**625 * SauceLabs access key - if provided, Thucydides can generate links to the SauceLabs reports that don't require a login.626 */627 SAUCELABS_ACCESS_KEY("saucelabs.accessKey"),628 /**629 * SauceLabs user id - if provided with the access key,630 * Thucydides can generate links to the SauceLabs reports that don't require a login.631 */632 SAUCELABS_USER_ID("saucelabs.username"),633 /**634 * Override the default implicit timeout value for the Saucelabs driver.635 */636 SAUCELABS_IMPLICIT_TIMEOUT,637 /**638 * Saucelabs records screenshots as well as videos by default. Since Thucydides also records screenshots,639 * this feature is disabled by default. It can be reactivated using this system property.640 */641 SAUCELABS_RECORD_SCREENSHOTS,642 /**643 * BrowserStack Hub URL if running the tests on BrowserStack Cloud644 */645 BROWSERSTACK_URL,646 BROWSERSTACK_USER,647 BROWSERSTACK_KEY,648 BROWSERSTACK_OS,649 BROWSERSTACK_OS_VERSION("browserstack.os_version"),650 /**651 * Browserstack uses this property for desktop browsers, like firefox, chrome and IE.652 */653 BROWSERSTACK_BROWSER,654 /**655 * Browserstack uses this one for android and iphone.656 */657 BROWSERSTACK_BROWSERNAME("browserstack.browserName"),658 BROWSERSTACK_BROWSER_VERSION,659 /**660 * BrowserStack mobile device name on which tests should be run661 */662 BROWSERSTACK_DEVICE,663 /**664 * Set the screen orientation of BrowserStack mobile device665 */666 BROWSERSTACK_DEVICE_ORIENTATION,667 /**668 * Specify a name for a logical group of builds on BrowserStack669 */670 BROWSERSTACK_PROJECT,671 /**672 * Specify a name for a logical group of tests on BrowserStack673 */674 BROWSERSTACK_BUILD,675 /**676 * Specify an identifier for the test run on BrowserStack677 */678 BROWSERSTACK_SESSION_NAME,679 /**680 * For Testing against internal/local servers on BrowserStack681 */682 BROWSERSTACK_LOCAL,683 /**684 * Generates screenshots at various steps in tests on BrowserStack685 */686 BROWSERSTACK_DEBUG,687 /**688 * Sets resolution of VM on BrowserStack689 */690 BROWSERSTACK_RESOLUTION,691 BROWSERSTACK_SELENIUM_VERSION,692 /**693 * Disable flash on Internet Explorer on BrowserStack694 */695 BROWSERSTACK_IE_NO_FLASH,696 /**697 * Specify the Internet Explorer webdriver version on BrowserStack698 */699 BROWSERSTACK_IE_DRIVER,700 /**701 * Enable the popup blocker in Internet Explorer on BrowserStack702 */703 BROWSERSTACK_IE_ENABLE_POPUPS,704 @Deprecated705 THUCYDIDES_FILE_IO_RETRY_TIMEOUT,706 /**707 * Timeout (in seconds) for retrying file I/O.708 * Used in net.thucydides.core.resources.FileResources.copyResourceTo().709 * Sometimes, file I/O fails on Windows machine due to the way Windows handles memory-mapped710 * files (http://stackoverflow.com/questions/3602783/file-access-synchronized-on-java-object).711 * This property, if set, will retry copying the resource till timeout. A default value is used712 * if the property is not set.713 */714 SERENITY_FILE_IO_RETRY_TIMEOUT,715 @Deprecated716 THUCYDIDES_LOGGING,717 /**718 * Four levels are supported: NONE, QUIET, NORMAL and VERBOSE719 * - NONE: Disable Serenity logging720 * - QUIET: Only report compromised tests, errors and failures.721 * - NORMAL: Log the start and end of each test, and the result of each test.722 * - VERBOSE: Log the start and end of each test, and the result of each test, and each test step.723 */724 SERENITY_LOGGING,725 @Deprecated726 THUCYDIDES_TEST_ROOT,727 /**728 * The root package for the tests in a given project.729 * If provided, Serenity will log information about the total number of tests to be executed,730 * and keep a tally of the executed tests. It will also use this as the root package when determining the731 * requirements hierarchy associated with a test.732 *733 * Technical note: If you are using the File System Requirements provider, Thucydides will expect this directory structure to exist734 * at the top of the requirements tree. If you want to exclude packages in a requirements definition and start at a735 * lower level in the hierarchy, use the thucydides.requirement.exclusions property.736 * This is also used by the PackageAnnotationBasedTagProvider to know where to look for annotated requirements.737 */738 SERENITY_TEST_ROOT,739 /**740 * Property used to define the current target version for manual tests defined in Cucumber scenarios741 * with the @manual and @@last-version-tested annotations.742 */743 CURRENT_TARGET_VERSION,744 @Deprecated745 THUCYDIDES_REQUIREMENTS_DIR,746 /**747 * Use this property if you need to completely override the location of requirements for the File System Provider.748 */749 SERENITY_REQUIREMENTS_DIR,750 /**751 * if specified, should point to a folder that contains one or more Serenity CSV output files752 */753 SERENITY_TEST_STATISTICS_DIR,754 @Deprecated755 THUCYDIDES_USE_REQUIREMENTS_DIRECTORIES,756 /**757 * Override the directory name for the directory containing feature files. This is designed to work for both758 * simple and multi-module projects. Give the name of the directory inside src/test/resources (e.g. you759 * would put serenity.features.directory = myFeatures for src/test/resources/myFeatures760 */761 SERENITY_FEATURES_DIRECTORY,762 /**763 * If set to true, the full description of the parent story or feature is displayed at the top of an individual test report.764 * Set to false by default/765 */766 SERENITY_SHOW_STORY_DETAILS_IN_TESTS,767 /**768 * Same as serenity.features.directory but for src/test/stories769 */770 SERENITY_STORIES_DIRECTORY,771 /**772 * Normally, REST calls are disabled when a failure occurs. Set this to false to never disable REST calls773 */774 SERENITY_DISABLE_REST_CALLS_AFTER_FAILURES,775 /**776 * By default, Thucydides will read requirements from the directory structure that contains the stories.777 * When other tag and requirements plugins are used, such as the JIRA plugin, this can cause conflicting778 * tags. Set this property to false to deactivate this feature (it is true by default).779 */780 SERENITY_USE_REQUIREMENTS_DIRECTORIES,781 @Deprecated782 THUCYDIDES_ANNOTATED_REQUIREMENTS_DIR,783 /**784 * Use this property if you need to completely override the location of requirements for the Annotated Provider.785 * This is recommended if you use File System and Annotated provider simultaneously.786 * The default value is stories.787 */788 SERENITY_ANNOTATED_REQUIREMENTS_DIR,789 @Deprecated790 THUCYDIDES_LOWEST_REQUIREMENT_TYPE,791 /**792 * Determine what the lowest level requirement (test cases, feature files, story files, should be793 * called. 'Story' is used by default. 'feature' is a popular alternative.794 */795 SERENITY_LOWEST_REQUIREMENT_TYPE,796 @Deprecated797 THUCYDIDES_REQUIREMENT_TYPES,798 /**799 * The hierarchy of requirement types.800 * This is the list of requirement types to be used when reading requirements from the file system801 * and when organizing the reports. It is a comma-separated list of tags.The default value is: capability, feature802 */803 SERENITY_REQUIREMENT_TYPES,804 @Deprecated805 THUCYDIDES_REQUIREMENT_EXCLUSIONS,806 /**807 * When deriving requirement types from a path, exclude any values from this comma-separated list.808 */809 SERENITY_REQUIREMENT_EXCLUSIONS,810 @Deprecated811 THUCYDIDES_RELEASE_TYPES,812 /**813 * What tag names identify the release types (e.g. Release, Iteration, Sprint).814 * A comma-separated list. By default, "Release, Iteration"815 */816 SERENITY_RELEASE_TYPES,817 @Deprecated818 THUCYDIDES_LOCATOR_FACTORY,819 /**820 * Normally, Serenity uses SmartElementLocatorFactory, an extension of the AjaxElementLocatorFactory821 * when instantiating page objects. This is to ensure that web elements are available and usable before they are used.822 * For alternative behaviour, you can set this value to DisplayedElementLocatorFactory, AjaxElementLocatorFactory or DefaultElementLocatorFactory.823 */824 SERENITY_LOCATOR_FACTORY,825 @Deprecated826 THUCYDIDES_DATA_DIR,827 /**828 * Where Serenity stores local data.829 */830 SERENITY_DATA_DIR,831 /**832 * Allows you to override the default serenity.properties location for properties file.833 */834 PROPERTIES,835 @Deprecated836 THUCYDIDES_TEST_REQUIREMENTS_BASEDIR,837 /**838 * The base directory in which requirements are kept. It is assumed that this directory contains sub folders839 * src/test/resources. If this property is set, the requirements are read from src/test/resources under this folder840 * instead of the classpath or working directory. If you need to set an independent requirements directory that841 * does not follow the src/test/resources convention, use thucydides.requirements.dir instead842 * <p>843 * This property is used to support situations where your working directory844 * is different from the requirements base dir (for example when building a multi-module project from parent pom with845 * requirements stored inside a sub-module : See Jira #Thucydides-100)846 */847 SERENITY_TEST_REQUIREMENTS_BASEDIR,848 /**849 * Set to true if you want the HTML source code to be recorded as well as the screenshots.850 * This is not currently used in the reports.851 */852 // THUCYDIDES_STORE_HTML_SOURCE,853 @Deprecated854 THUCYDIDES_KEEP_UNSCALED_SCREENSHOTS,855 /**856 * If set to true, a copy of the original screenshot will be kept when screenshots are scaled for the reports.857 * False by default to conserve disk space.858 */859 SERENITY_KEEP_UNSCALED_SCREENSHOTS,860 /**861 * If provided, only classes and/or methods with tags in this list will be executed. The parameter expects862 * a tag or comma-separated list of tags in the shortened form.863 * This only works for JUnit tests. For Cucumber, use the -Dcucumber.options parameter864 * For example, -Dtags="iteration:I1" or -Dtags="color:red,flavor:strawberry"865 */866 TAGS,867 /**868 * Display only test results and requirements containing any of the specified tags869 */870 REPORT_ON_TAGS,871 /**872 * If provided, each test in a test run will have these tags added.873 */874 INJECTED_TAGS,875 @Deprecated876 THUCYDIDES_CSV_EXTRA_COLUMNS,877 /**878 * If set to true, historical flags will be displayed in test lists.879 * This must be set in conjunction with the serenity.historyDirectory property880 */881 SHOW_HISTORY_FLAGS,882 /**883 * Serenity will look in this directory for the previous build results, to use as a basis for the884 * historical flags shown in the test results. By default, the 'history' folder in the working directory will be used.885 */886 SERENITY_HISTORY_DIRECTORY("serenity.historyDirectory"),887 /**888 * Delete the history directory before a new set of results is recorded889 */890 DELETE_HISTORY_DIRECTORY,891 /**892 * Generate a CSV report for each test result (true by default)893 */894 SERENITY_GENERATE_CSV_REPORTS,895 /**896 * Add extra columns to the CSV output, obtained from tag values.897 */898 SERENITY_CSV_EXTRA_COLUMNS,899 @Deprecated900 THUCYDIDES_CONSOLE_HEADINGS,901 /**902 * Write the console banner using ascii-art ("ascii", default value) or in smaller text ("normal")903 */904 SERENITY_CONSOLE_BANNER,905 /**906 * Write the console headings using ascii-art ("ascii", default value) or in normal text ("normal")907 */908 SERENITY_CONSOLE_HEADINGS,909 @Deprecated910 THUCYDIDES_CONSOLE_COLORS,911 /**912 * Use ASCII color codes when outputing the console logs.913 */914 SERENITY_CONSOLE_COLORS,915 /**916 * Set to true to write the chronological number of each test as it is executed to the console917 */918 SERENITY_DISPLAY_TEST_NUMBERS,919 /**920 * If set to true, Asciidoc formatting will be supported in the narrative texts.921 */922 NARRATIVE_FORMAT,923 /**924 * What format should test results be generated in.925 * By default, this is "json, html".926 */927 OUTPUT_FORMATS,928 /**929 * If set to true (the default), allow markdown formatting in test outcome titles and descriptions.930 * This is a comma-separated lists of values from the following: story, narrative, step931 * By default, Markdown is enabled for story titles and narrative texts, but not for steps.932 */933 ENABLE_MARKDOWN,934 /**935 * Path to PhantomJS executable936 */937 //PHANTOMJS_BINARY_PATH,938 /**939 * Path to the Gecko driver binary940 */941 WEBDRIVER_GECKO_DRIVER,942 /**943 * If set to true, don't format embedded tables in JBehave or Gherkin steps.944 * False by default.945 */946 IGNORE_EMBEDDED_TABLES,947 /**948 * If set, this will display the related tag statistics on the home page.949 * If you are using external requirements, you may not want to display these tags on the dashboard.950 */951 SHOW_RELATED_TAGS,952 /**953 * If set to true (the default value), a story tag will be extracted from the test case or feature file954 * containing the test.955 */956 USE_TEST_CASE_FOR_STORY_TAG,957 /**958 * Display the pie charts on the dashboard by default.959 * If this is set to false, the pie charts will be initially hidden on the dashboard.960 */961 SHOW_PIE_CHARTS,962 /**963 * If set, this will define the list of tag types to appear on the dashboard screens964 */965 DASHBOARD_TAG_LIST,966 /**967 * If set to false, render report names in a readable form as opposed to a hash format.968 * Note: this can cause problems on operating systems that limit path lengths such as Windows.969 */970 SERENITY_COMPRESS_FILENAMES,971 /**972 * If set, Serenity will scale down the screenshots taken during execution to the size of the carousel in the973 * screenshot page. This results in a loss of quality but a gain in disk space.974 */975 SERENITY_COMPRESS_SCREENSHOTS,976 /**977 * Specify the screenshot tool to be used to take screenshots.978 * By default it will be WebDriver. Other values include:979 * <ul>980 * <li>shutterbug (for Shutterbug 0.9.5 - add the serenity-shutterbug dependency to your project)</li>981 * <li>shutterbug1 (for Shutterbug 1.x - add the serenity-shutterbug1x dependency to your project)</li>982 * </ul>983 * You can also provide your own fully qualified class path that implements the ScreenShooter interface.984 * This class MUST have a constructor that accepts a WebDriver parameter.985 */986 SERENITY_SCREENSHOOTER,987 /**988 * If set, Serenity will use full page screenshot strategy.989 */990 @Deprecated991 SERENITY_FULL_PAGE_SCREENSHOT_STRATEGY,992 /**993 * Define the Shutterbug screen capture strategy:994 * - VIEWPORT: capture visible part of the viewport only995 * - FULL: full page screenshot using devtools996 * - FULL_SCROLL: full page screenshot using scroll & stitch method997 * - VERTICAL_SCROLL:vertical scroll page screenshot using scroll & stitch method998 * - HORIZONTAL_SCROLL: horizontal scroll page screenshot using scroll & stitch method999 */1000 @Deprecated1001 SERENITY_SCREENSHOT_STRATEGY,1002 /**1003 * If set, this will define the list of tag types to be excluded from the dashboard screens1004 */1005 DASHBOARD_EXCLUDED_TAG_LIST,1006 /**1007 * If set, this will define the list of tag types which will be not formatted with title case in HTML report.1008 * This option allows to preserve underscores or camel case in tag name.1009 */1010 REPORT_RAW_TAG_LIST,1011 /**1012 * Format the JSON test outcomes nicely.1013 * "true" or "false", turned off by default.1014 */1015 JSON_PRETTY_PRINTING,1016 /**1017 * What charset to use for JSON processing.1018 * Defaults to UTF-81019 */1020 JSON_CHARSET,1021 /**1022 * What charset to use for report generation.1023 * Defaults to UTF-81024 */1025 REPORT_CHARSET,1026 /**1027 * Stack traces are by default decluttered for readability.1028 * For example, calls to instrumented code or internal test libraries is removed.1029 * This behaviour can be deactivated by setting this property to false.1030 */1031 SIMPLIFIED_STACK_TRACES,1032 @Deprecated1033 THUCYDIDES_DRY_RUN,1034 /**1035 * Run through the steps without actually executing them.1036 */1037 SERENITY_DRY_RUN,1038 /**1039 * What (human) language are the Cucumber feature files written in?1040 * Defaults to "en"1041 */1042 FEATURE_FILE_LANGUAGE,1043 /**1044 * Display the context in the test title.1045 * Set to false by default.1046 * If the context is a browser type (chrome, ie, firefox, safari, opera), the browser icon will be displayed1047 * If the context is an OS (linux, mac, windows, android, iphone), an icon will be displayed1048 * Otherwise, the context name will be displayed at the start of the test title.1049 */1050 THUCYDIDES_DISPLAY_CONTEXT,1051 /**1052 * Include a context tag with a test if one is provided.1053 * Set to 'true' by default1054 */1055 THUCYDIDES_ADD_CONTEXT_TAG,1056 /**1057 * What encoding to use for reading Cucumber feature files?1058 * Defaults to system default encoding1059 */1060 FEATURE_FILE_ENCODING,1061 /**1062 * Fine-tune the number of threads Serenity uses for report generation.1063 */1064 REPORT_THREADS,1065 REPORT_MAX_THREADS,1066 REPORT_KEEP_ALIVE_TIME,1067 /**1068 * Set this to true if you want Serenity to report nested step structures for subsequent steps1069 * after a step failure.1070 */1071 DEEP_STEP_EXECUTION_AFTER_FAILURES,1072 /**1073 * What test result (success,ignored, or pending) should be shown for manual annotated tests in the reports?1074 */1075 MANUAL_TEST_REPORT_RESULT,1076 @Deprecated1077 THUCYDIDES_MAINTAIN_SESSION,1078 /**1079 * Keep the Serenity session data between tests.1080 * Normally, the session data is cleared between tests, but it can sometimes be useful to preserve this data.1081 * When using @BeforeAll methods in JUnit or Cucumber, you need to set this variable to true to use values set in these methods.1082 */1083 SERENITY_MAINTAIN_SESSION,1084 /**1085 * Path to PhantomJS SSL support1086 */1087 //PHANTOMJS_SSL_PROTOCOL,1088 /**1089 * Comma-separated list of exception classes that should produce a compromised test in the reports.1090 */1091 SERENITY_COMPROMISED_ON,1092 /**1093 * Comma-separated list of exception classes that should produce a skipped test in the reports.1094 */1095 SERENITY_SKIPPED_ON,1096 /**1097 * Comma-separated list of exception classes that should produce an error in the reports.1098 */1099 SERENITY_ERROR_ON,1100 /**1101 * Comma-separated list of exception classes that should produce a failure in the reports.1102 */1103 SERENITY_FAIL_ON,1104 /**1105 * If batch testing is being used in a multithreaded environment, this is the number of forks that will be created.1106 */1107 SERENITY_FORK_COUNT,1108 /**1109 * If batch testing is being used in a multithreaded environment, this is the executing fork number.1110 */1111 SERENITY_FORK_NUMBER,1112 /**1113 * Comma-separated list of exception classes that should produce a pending test in the reports.1114 */1115 SERENITY_PENDING_ON,1116 /**1117 * If set to true, add a tag for test failures, based on the error type and message1118 */1119 SERENITY_TAG_FAILURES,1120 /**1121 * A comma-separated list of tag types for which human-readable report names will be generated.1122 */1123 SERENITY_LINKED_TAGS,1124 /**1125 * Should we assume that collections of webdriver elements are already on the page, or if we should wait for them to be available.1126 * This property takes two values: Optimistic or Pessimistic. Optimistic means that the elements are assumed to be on the screen, and will be1127 * loaded as-is immediately. This is the normal WebDriver behavior.1128 * For applications with lots of ASynchronous activity, it is often better to wait until the elements are visible before using them. The Pessimistic1129 * mode waits for at least one element to be visible before proceeding.1130 * For legacy reasons, the default strategy is Pessimistic.1131 */1132 SERENITY_WEBDRIVER_COLLECTION_LOADING_STRATEGY("serenity.webdriver.collection_loading_strategy"),1133 /**1134 * If the Gecko Driver is on the system path, it will be used (with Marionnette) by default.1135 * If you want to use the old-style Firefox driver, but have gecko on the system path,1136 * then set this property to false.1137 */1138 USE_GECKO_DRIVER,1139 /**1140 * Use this property to pass options to Marionette using the 'moz:firefoxOptions' capability option.1141 */1142 GECKO_FIREFOX_OPTIONS,1143 /**1144 * An alternative to gecko.firefox.options1145 */1146 FIREFOX_OPTIONS,1147 /**1148 * Use this property to specify the maximum number of times to rerun the failing tests.1149 */1150 TEST_RETRY_COUNT,1151 /**1152 * Use this property to specify the maximum number of times to rerun the failing tests for cucumber tests.1153 */1154 TEST_RETRY_COUNT_CUCUMBER,1155 /**1156 * Record failures to a file specified by property rerun.failures.file or rerun.xml in current directory1157 */1158 RECORD_FAILURES,1159 /**1160 * Replay failures from a file specified by property rerun.failures.file or rerun.xml in current directory1161 */1162 REPLAY_FAILURES,1163 /**1164 * Location of the directory where the failure files are recorded.1165 */1166 RERUN_FAILURES_DIRECTORY,1167 /**1168 * Provide a text that distinguishes tests run in a particular environment or context from the same test1169 * run in a different environment or context.1170 */1171 CONTEXT,1172 APPIUM_HUB,1173 /**1174 * By default, new @Steps libraries are made as new instances, unless declared `shared`, in which case they are1175 * cached by type. Use this property to make Serenity use the older strategy, which was to default to 'shared' and1176 * only create new instances for step libraries with the uniqueInstance attribute.1177 * Possible values are: default (the default value), and legacy.1178 */1179 STEP_CREATION_STRATEGY,1180 /**1181 * Instruct the SafariDriver to delete all existing session data when starting a new session (true by default)1182 */1183 SAFARI_USE_CLEAN_SESSION,1184 /**1185 * Activate headless mode for chrome or firefox1186 */1187 HEADLESS_MODE,1188 /**1189 * Where to find images used in the reports (defaults to src/test/resources/assets)1190 */1191 REPORT_ASSETS_DIRECTORY,1192 FIREFOX_LOG_LEVEL,1193 /**1194 * Unique device identifier of the connected physical device used for appium tests1195 */1196 APPIUM_UDID("appium.udid"),1197 /**1198 * The device name used for Appium tests1199 */1200 APPIUM_DEVICE_NAME("appium.deviceName"),1201 APPIUM_PLATFORMNAME("appium.platformName"),1202 /**1203 * (Experimental) Specifies a list of devices to be used for parallel testing.1204 * Will only be used if manage.appium.servers is set to true1205 */1206 APPIUM_DEVICE_NAMES("appium.deviceNames"),1207 /**1208 * Should Serenity Manage your appium servers for you1209 */1210 MANAGE_APPIUM_SERVERS,1211 /**1212 * List of capabilities that should be provided in addition to supported by w3c or Appium.1213 * Properties, that match w3c pattern or listed in Appium's interfaces, will be included as is and1214 * 'appium:' prefix will be added to each name provided in this property1215 */1216 APPIUM_ADDITIONAL_CAPABILITIES("appium.additional.capabilities"),1217 /**1218 * Set to true to enable processing of desired capabilities, created from the provided 'appium:' properties.1219 * If processing is enabled, only capabilities supported by w3c, Appium or mentioned in1220 * {@link ThucydidesSystemProperty#APPIUM_ADDITIONAL_CAPABILITIES} will be included into desired capabilities.1221 * If processing is disabled, all of the properties that have 'appium:' prefix will be included into desired capabilities.1222 * Disabled by default1223 */1224 APPIUM_PROCESS_DESIRED_CAPABILITIES("appium.process.desired.capabilities"),1225 /**1226 * Set to true to activate the AcceptInsecureCertificates options for Chrome and Firefox.1227 */1228 ACCEPT_INSECURE_CERTIFICATES,1229 /**1230 * The character to be used to separate firefox preference key-value pairs when using the "firefox.preferences" property.1231 * By default this is a semicolon, but sometimes semicolon appears in the preference values.1232 */1233 FIREFOX_PREFERENCE_SEPARATOR,1234 /**1235 * Disable Webdriver integration. Turn this off to avoid Serenity loading WebDriver classes unnecessarily.1236 */1237 SERENITY_WEBDRIVER_INTEGRATION,1238 /**1239 * When creating steps that contain references to other steps serenity does a recursion check to prevent cyclic references.1240 * This property determines how many levels deep the step classes can be nested before it triggers a recursion exception.1241 * By default it is set to 32, but can be increased if you start getting RecursiveOrCyclicStepLibraryReferenceException1242 * due to step nesting rather than actual infinite recursion.1243 */1244 SERENITY_MAXIMUM_STEP_NESTING_DEPTH,1245 /**1246 * The maximum number of entries to appear on report scoreboards (default 5)1247 */1248 REPORT_SCOREBOARD_SIZE,1249 /**1250 * Show the full test results in the emailable reports1251 */1252 SHOW_FULL_TEST_RESULTS,1253 /**1254 * What tag types should be listed in the report summary1255 */1256 REPORT_TAGTYPES,1257 /**1258 * Alternative to report.tagtypes1259 */1260 SERENITY_REPORT_TAGTYPES,1261 MAX_FREQUENT_FAILURES,1262 CUCUMBER_PRETTY_FORMAT_TABLES,1263 IO_BLOCKING_COEFFICIENT,1264 /**1265 * How many days before a manually configured test result expires and goes back to pending.1266 */1267 MANUAL_RESULT_EXPIRY_LIMIT,1268 /**1269 * Set this property to true if you don't want Serenity to try to instrument tasks for you.1270 */1271 MANUAL_TASK_INSTRUMENTATION,1272 /**1273 * The root package or packages used to look for Serenity extension classes, as a comma-separated list.1274 */1275 SERENITY_EXTENSION_PACKAGES,1276 /**1277 * A semi-colon list of (partial) error messages.1278 * If WebDriver creation fails for a reason mentioned in this list, Serenity will retry driver creation1279 * every thirty seconds for at most WEBDRIVER_CREATION_RETRY_MAX_TIME times (the default is 30)1280 * The default recognises BrowserStack timeouts ("All parallel tests are currently in use")1281 */1282 WEBDRIVER_CREATION_RETRY_CAUSES,1283 WEBDRIVER_CREATION_RETRY_MAX_TIME,1284 /**1285 * If set to true, the name of the actor will appear in "should" statements for Screenplay tests.1286 */1287 SERENITY_INCLUDE_ACTOR_NAME_IN_CONSEQUENCES,1288 /**1289 * Wait for an element to be visible and fail if the element is not visible.1290 * By default, this behaviour is deactivated as of version 2.0.49, and the behaviour of getText()1291 * replicates the standard Selenium behavior of returning an empty string if an element is not visible.1292 */1293 LEGACY_WAIT_FOR_TEXT,1294 ENVIRONMENT,1295 /**1296 * Enable WebDriver calls in @After methods, even after a step has failed (true by default).1297 */1298 SERENITY_ENABLE_WEBDRIVER_IN_FIXTURE_METHODS,1299 /**1300 * Use this property to pass options to Edge driver using the 'ms:edgeOptions' capability option.1301 * For example: """{"args": ["headless", "start-maximized", "disable-gpu"]}"""1302 */1303 EDGE_OPTIONS,1304 IE_OPTIONS_ENABLE_NATIVE_EVENTS("ieOptions.EnableNativeEvents"),1305 IE_OPTIONS_IGNORE_ZOOM_LEVEL("ieOptions.IgnoreZoomLevel"),1306 IE_OPTIONS_REQUIRE_WINDOW_FOCUS("ieOptions.RequireWindowFocus"),1307 /**1308 * The title to appear in the tag type table in the email reports1309 */1310 REPORT_TAGTYPE_TITLE;1311 private String propertyName;1312 public static final int DEFAULT_HEIGHT = 700;1313 public static final int DEFAULT_WIDTH = 960;1314 public static final String DEFAULT_HISTORY_DIRECTORY = "history";1315 private final Logger logger = LoggerFactory.getLogger(ThucydidesSystemProperty.class);1316 ThucydidesSystemProperty(final String propertyName) {1317 this.propertyName = propertyName;1318 }1319 ThucydidesSystemProperty() {1320 this.propertyName = name().replaceAll("_", ".").toLowerCase();1321 }1322 public String getPropertyName() {1323 return propertyName;1324 }1325 public String getLegacyPropertyName() {1326 if (propertyName.startsWith("serenity.")) {1327 return "thucydides." + propertyName.substring(9);1328 } else {1329 return propertyName;1330 }1331 }1332 @Override1333 public String toString() {1334 return propertyName;1335 }1336 public Optional<String> optionalFrom(EnvironmentVariables environmentVariables) {1337 return Optional.ofNullable(from(environmentVariables, null));1338 }1339 public String from(EnvironmentVariables environmentVariables) {1340 return from(environmentVariables, null);1341 }1342 private Optional<String> legacyPropertyValueIfPresentIn(EnvironmentVariables environmentVariables) {1343 String legacyValue = environmentVariables.getProperty(withLegacyPrefix(getPropertyName()));1344 if (StringUtils.isNotEmpty(legacyValue)) {1345 logger.warn("Legacy property format detected for {}, please use the serenity.* format instead.", getPropertyName());1346 }1347 return Optional.ofNullable(legacyValue);1348 }1349 private String withLegacyPrefix(String propertyName) {1350 return propertyName.replaceAll("serenity.", "thucydides.");1351 }1352 private String withSerenityPrefix(String propertyName) {1353 return propertyName.replaceAll("thucydides.", "serenity.");1354 }1355 public String preferredName() {1356 return withSerenityPrefix(getPropertyName());1357 }1358 public List<String> legacyNames() {1359 List<String> names = new ArrayList<>(1);1360 names.add(withLegacyPrefix(getPropertyName()));1361 return names;1362 }1363 public String from(EnvironmentVariables environmentVariables, String defaultValue) {1364 Optional<String> newPropertyValue = optionalPropertyValueDefinedIn(environmentVariables);1365// = Optional.ofNullable(environmentVariables.getProperty(withSerenityPrefix(getPropertyName())));1366 if (isDefined(newPropertyValue)) {1367 return newPropertyValue.get();1368 } else {1369 Optional<String> legacyValue = legacyPropertyValueIfPresentIn(environmentVariables);1370 return (isDefined(legacyValue)) ? legacyValue.get() : defaultValue;1371 }1372 }1373 private boolean isDefined(Optional<String> newPropertyValue) {1374 return newPropertyValue.isPresent() && StringUtils.isNotEmpty(newPropertyValue.get());1375 }1376 public int integerFrom(EnvironmentVariables environmentVariables) {1377 return integerFrom(environmentVariables, 0);1378 }1379 public int integerFrom(EnvironmentVariables environmentVariables, int defaultValue) {1380 Optional<String> newPropertyValue = optionalPropertyValueDefinedIn(environmentVariables);1381 if (isDefined(newPropertyValue)) {1382 return Integer.parseInt(newPropertyValue.get().trim());1383 } else {1384 Optional<String> legacyValue = legacyPropertyValueIfPresentIn(environmentVariables);1385 return (isDefined(legacyValue)) ? Integer.parseInt(legacyValue.get().trim()) : defaultValue;1386 }1387 }1388 public long longFrom(EnvironmentVariables environmentVariables, long defaultValue) {1389 Optional<String> newPropertyValue = optionalPropertyValueDefinedIn(environmentVariables);1390 if (isDefined(newPropertyValue)) {1391 return Integer.parseInt(newPropertyValue.get().trim());1392 } else {1393 Optional<String> legacyValue = legacyPropertyValueIfPresentIn(environmentVariables);1394 return (isDefined(legacyValue)) ? Integer.parseInt(legacyValue.get().trim()) : defaultValue;1395 }1396 }1397 public Boolean booleanFrom(EnvironmentVariables environmentVariables) {1398 return booleanFrom(environmentVariables, false);1399 }1400 public Boolean booleanFrom(EnvironmentVariables environmentVariables, Boolean defaultValue) {1401 if (environmentVariables == null) {1402 return defaultValue;1403 }1404 Optional<String> newPropertyValue = optionalPropertyValueDefinedIn(environmentVariables);1405 if (isDefined(newPropertyValue)) {1406 return Boolean.valueOf(newPropertyValue.get().trim());1407 } else {1408 Optional<String> legacyValue = legacyPropertyValueIfPresentIn(environmentVariables);1409 return (isDefined(legacyValue)) ? Boolean.valueOf(legacyValue.get().trim()) : defaultValue;1410 }1411 }1412 private Optional<String> optionalPropertyValueDefinedIn(EnvironmentVariables environmentVariables) {1413 return EnvironmentSpecificConfiguration.from(environmentVariables).getOptionalProperty(withSerenityPrefix(getPropertyName()));1414 }1415 public boolean isDefinedIn(EnvironmentVariables environmentVariables) {1416 return StringUtils.isNotEmpty(from(environmentVariables));1417 }1418}...

Full Screen

Full Screen

Source:DriverFactory.java Github

copy

Full Screen

1/*******************************************************************************2 * Copyright (c) 2015, 2016 Automation RockStars Ltd.3 * All rights reserved. This program and the accompanying materials4 * are made available under the terms of the Apache License v2.05 * which accompanies this distribution, and is available at6 * http://www.apache.org/licenses/LICENSE-2.07 *8 * Contributors:9 * Automation RockStars - initial API and implementation10 *******************************************************************************/11package com.automationrockstars.design.gir.webdriver;12import com.automationrockstars.base.ConfigLoader;13import com.automationrockstars.bmo.AllureStoryReporter;14import com.automationrockstars.bmo.GenericAllureStoryReporter;15import com.automationrockstars.design.gir.webdriver.plugin.UiDriverPluginService;16import com.automationrockstars.design.gir.webdriver.plugin.UiObjectActionPluginService;17import com.automationrockstars.design.gir.webdriver.plugin.UiObjectFindPluginService;18import com.automationrockstars.design.gir.webdriver.plugin.UiObjectInfoPluginService;19import com.google.common.base.Function;20import com.google.common.base.Optional;21import com.google.common.base.Predicate;22import com.google.common.base.Strings;23import com.google.common.collect.*;24import org.apache.commons.collections.list.UnmodifiableList;25import org.apache.commons.io.FileUtils;26import org.apache.commons.io.IOUtils;27import org.apache.commons.lang.StringUtils;28import org.apache.http.client.methods.CloseableHttpResponse;29import org.apache.http.client.methods.HttpGet;30import org.apache.http.impl.client.CloseableHttpClient;31import org.apache.http.impl.client.HttpClients;32import org.openqa.selenium.*;33import org.openqa.selenium.Platform;34import org.openqa.selenium.chrome.ChromeDriver;35import org.openqa.selenium.chrome.ChromeOptions;36import org.openqa.selenium.firefox.FirefoxDriver;37import org.openqa.selenium.firefox.FirefoxProfile;38import org.openqa.selenium.ie.InternetExplorerDriver;39import org.openqa.selenium.interactions.Actions;40import org.openqa.selenium.WrapsDriver;41import org.openqa.selenium.remote.BrowserType;42import org.openqa.selenium.remote.CapabilityType;43import org.openqa.selenium.remote.DesiredCapabilities;44import org.openqa.selenium.remote.RemoteWebDriver;45import org.openqa.selenium.support.ui.WebDriverWait;46import org.slf4j.Logger;47import org.slf4j.LoggerFactory;48import java.awt.*;49import java.io.File;50import java.io.IOException;51import java.net.MalformedURLException;52import java.net.URI;53import java.net.URL;54import java.util.*;55import java.util.List;56import java.util.concurrent.ConcurrentMap;57import static com.automationrockstars.base.ConfigLoader.config;58import static com.automationrockstars.design.gir.webdriver.plugin.UiObjectFindPluginService.findPlugins;59public class DriverFactory {60 public static final String WEBDRIVER_SESSION = "webdriver.session";61 public static final String DEFAULT_AUTO_DOWNLOAD = "application/octet-stream,application/x-gzip,application/gzip,application/zip,application/pdf,application/vnd.cups-pdf";62 public static final ConcurrentMap<WebDriver, WebDriver> wdsInstances = Maps.newConcurrentMap();63 private static final ThreadLocal<WebDriver> instances = new InheritableThreadLocal<>();64 private static final List<WebDriver> activeDrivers = Lists.newCopyOnWriteArrayList();65 ;66 private static final Logger log = LoggerFactory.getLogger(DriverFactory.class);67 private static final ThreadLocal<String> url = new ThreadLocal<>();68 private static final String GRID_URL = ConfigLoader.config().getString("grid.url", null);69 private static final String MATRIX_PROP = "webdriver.matrix.browsers";70 private static final String BROWSER_PROP = "webdriver.browser";71 private static final String DEF_BROWSER_PROP = "webdriver.browser.default";72 private static final String DEF_BROWSER = "phantomjs";73 private static Capabilities capabilities;74 private static WebDriver DISPLAY_BROWSER = null;75 private static PeekingIterator<String> matrix = null;76 private static boolean pluginInitialized = false;77 private static ThreadLocal<WdsProvider> providers = new ThreadLocal<>();78 private static final ThreadLocal<String> browser = new InheritableThreadLocal<String>() {79 protected String initialValue() {80 String browser = DEF_BROWSER;81 if (!isWds()) {82 if (browserQueue().hasNext()) {83 browser = browserQueue().next();84 } else {85 if (ConfigLoader.config().containsKey("webdriver.browser")) {86 browser = ConfigLoader.config().getString("webdriver.browser");87 }88 }89 }90 return browser;91 }92 };93 private static final WebDriver instance() {94 return instances.get();95 }96 public static void url(String url) {97 DriverFactory.url.set(url);98 }99 public static String url() {100 return url.get();101 }102 public static final WebDriver getUnwrappedDriver() {103 WebDriver toUnwrap = null;104 if (isWds()) {105 toUnwrap = wdsInstance();106 } else {107 if (instance() == null) {108 getDriver();109 }110 toUnwrap = instance();111 }112 return unwrap(toUnwrap);113 }114 public static WebDriver unwrap(WebDriver wrapped) {115 if (WrapsDriver.class.isAssignableFrom(wrapped.getClass())) {116 return unwrap(((WrapsDriver) wrapped).getWrappedDriver());117 } else return wrapped;118 }119 public static boolean canScreenshot() {120 return instance() != null || providers.get() != null;121 }122 public static byte[] getScreenshot() {123 return ((RemoteWebDriver) getUnwrappedDriver()).getScreenshotAs(OutputType.BYTES);124 }125 public static String getScreenshotAsBase64() {126 return ((RemoteWebDriver) getUnwrappedDriver()).getScreenshotAs(OutputType.BASE64);127 }128 public static void displayScreenshotFile() {129 try {130 File screenshot = getScreenshotFile();131 if (FileUtils.waitFor(screenshot, 1)) {132 log.info("Screenshot file available {}", screenshot.getAbsolutePath());133 Desktop.getDesktop().open(screenshot);134 } else {135 log.warn("File {} not created", screenshot);136 }137 } catch (IOException e) {138 log.error("Cannot display screenshot due to", e);139 }140 }141 public static void displayScreenshotBrowser() {142 if (DISPLAY_BROWSER == null) {143 DISPLAY_BROWSER = new ChromeDriver();144 }145 if (DISPLAY_BROWSER != null) {146 DISPLAY_BROWSER.get("data:image/gif;base64," + getScreenshotAsBase64());147 }148 }149 public static File getScreenshotFile() {150 if (TakesScreenshot.class.isAssignableFrom(getUnwrappedDriver().getClass())) {151 return ((TakesScreenshot) getUnwrappedDriver()).getScreenshotAs(OutputType.FILE);152 } else return new File(UUID.randomUUID().toString());153 }154 public static void setCapabilities(Capabilities capabilities) {155 DriverFactory.capabilities = capabilities;156 }157 public static Actions actions() {158 return new Actions(getUnwrappedDriver());159 }160 private static final boolean isGridAvailable(String gridUrl) {161 boolean result = true;162 CloseableHttpResponse gridResponse;163 try {164 CloseableHttpClient cl = HttpClients.createDefault();165 gridResponse = cl.execute(new HttpGet(new URI(gridUrl)));166 if (gridResponse.getStatusLine().getStatusCode() == 404) {167 log.warn("Response from contacting grid {}", IOUtils.toString(gridResponse.getEntity().getContent()));168 result = false;169 }170 gridResponse.close();171 cl.close();172 } catch (Throwable e) {173 result = false;174 log.error("Selenium grid not available due to {}", e.getMessage());175 }176 return result;177 }178 private static boolean checkGridExtras(String gridUrl, RemoteWebDriver driver) {179 String gridExtras = GridUtils.getNodeExtras(gridUrl, driver);180 if (gridExtras == null) {181 log.info("No grid extras foud");182 return false;183 } else {184 log.info("Grid extras available at {}", gridExtras);185 return true;186 }187 }188 private static synchronized Iterator<String> browserQueue() {189 while (matrix == null || !matrix.hasNext() || matrix.peek() == null) {190 matrix = browserMatrix();191 }192 if (!pluginInitialized) {193 UiObjectFindPluginService.findPlugins();194 UiObjectActionPluginService.actionPlugins();195 UiObjectInfoPluginService.infoPlugins();196 UiDriverPluginService.driverPlugins();197 pluginInitialized = true;198 }199 return matrix;200 }201 public static synchronized PeekingIterator<String> browserMatrix() {202 PeekingIterator<String> result;203 if (ConfigLoader.config().containsKey(MATRIX_PROP)) {204 result = Iterators.peekingIterator(Iterators.forArray(ConfigLoader.config().getStringArray(MATRIX_PROP)));205 } else {206 String bName = ConfigLoader.config().getString(BROWSER_PROP, ConfigLoader.config().getString(DEF_BROWSER_PROP, DEF_BROWSER));207 if (bName.equalsIgnoreCase("ie")) {208 bName = BrowserType.IE;209 log.info("Using {} for browser", bName);210 }211 result = Iterators.peekingIterator(Iterators.cycle(bName));212 }213 return result;214 }215 public static void setBrowser(String browser) {216 DriverFactory.browser.set(browser);217 }218 private static String storyName() {219 String story = null;220 try {221 if (!Strings.isNullOrEmpty(GenericAllureStoryReporter.storyName())) {222 story = GenericAllureStoryReporter.storyName();223 } else if (!Strings.isNullOrEmpty(AllureStoryReporter.storyName())) {224 story = AllureStoryReporter.storyName();225 }226 } catch (Throwable t) {227 }228 return story;229 }230 private static String scenarioName() {231 String scenario = null;232 try {233 if (!Strings.isNullOrEmpty(GenericAllureStoryReporter.storyName())) {234 scenario = GenericAllureStoryReporter.scenarioName();235 } else if (!Strings.isNullOrEmpty(AllureStoryReporter.storyName())) {236 scenario = AllureStoryReporter.scenarioName();237 }238 } catch (Throwable t) {239 }240 return scenario;241 }242 private static synchronized void enableGridExtras(RemoteWebDriver driver) {243 if (checkGridExtras(GRID_URL, driver)) {244 String videoLink = String.format("%s/download_video/%s.mp4", GridUtils.getNodeExtras(GRID_URL, driver), driver.getSessionId().toString()).replace("//download","/download");245 ConfigLoader.config().addProperty("webdriver.video", videoLink);246 List<Object> videos = ConfigLoader.config().getList("webdriver.videos", new ArrayList<Map<String, String>>());247 String story = String.format("%s->%s::", storyName(), scenarioName());248 if (Strings.isNullOrEmpty(story)) {249 story = "recording " + driver.getSessionId();250 }251 String title = "video_" + story;252 int videoRepetition = 0;253 String titlePostfix = "";254 Optional<Object> titleAlreadyThere = Optional.absent();255 do {256 if (videoRepetition > 0) {257 titlePostfix = String.format("_%s", videoRepetition);258 }259 final String titleBase = title + titlePostfix;260 titleAlreadyThere = FluentIterable.from(videos).firstMatch(new Predicate<Object>() {261 @SuppressWarnings("unchecked")262 @Override263 public boolean apply(Object input) {264 return ((Map<String, String>) input).keySet().contains(titleBase);265 }266 });267 if (!titleAlreadyThere.isPresent()) {268 title = titleBase;269 } else {270 videoRepetition++;271 }272 } while (titleAlreadyThere.isPresent());273 log.info("Session for story {}", title);274 videos.add(Collections.singletonMap(title, videoLink));275 ConfigLoader.config().setProperty("webdriver.videos", videos);276 }277 }278 private static WebDriver createRemoteDriver() {279 String name = "";280// if (ConfigLoader.config().containsKey("noui")) {281// name = HeadlessWebDriver.name();282// browser.set(name);283// }284 log.info("Creating browser for {}", browser.get());285 try {286 name = browser.get().toLowerCase();287 if (name.equalsIgnoreCase("ie") || name.equals("internet_explorer") || name.equals("internet explorer")) {288 name = BrowserType.IE;289 } else if (name.equals("edge") || name.toLowerCase().equals("microsoftedge")) {290 name = BrowserType.EDGE;291 }292 if (Strings.isNullOrEmpty(GRID_URL) || !isGridAvailable(GRID_URL)) {293 log.info("Grid not detected");294 if (name.equals(BrowserType.IE)) {295 return new InternetExplorerDriver(getCapabilities(BrowserType.IE));296 }297 String browserName = StringUtils.capitalize(name + "Driver");298 WebDriver res = null;299 try {300 String className = browser.get();301 if (!browserName.contains(".")) {302 className = "org.openqa.selenium." + name + "." + browserName;303 }304 res = (WebDriver) Class.forName(className).getConstructor(Capabilities.class).newInstance(getCapabilities(name));305 } catch (Exception e) {306 throw new IllegalStateException(String.format("Browser for name %s failed to start", name), e);307 }308 return res;309 } else {310 log.info("Using Selenium grid at {}", GRID_URL);311 URL gridUrl = new URL(GRID_URL);312 RemoteWebDriver result = new RemoteWebDriver(gridUrl, getCapabilities(name));313 log.info("Driver instance created {}", result);314 log.debug("Test session id {}", result.getSessionId());315 log.info("Executing on node {}", GridUtils.getNode(GRID_URL, result));316 enableGridExtras(result);317 return result;318 }319 } catch (MalformedURLException e) {320 throw new RuntimeException("Cannot connect to grid", e);321 }322 }323 /**324 * Close all drivers created by DriverFactory325 */326 public static synchronized void closeAllDrivers(){327 Lists.newArrayList(activeDrivers).stream().forEach(d-> closeDriver(d));328 }329 /**330 * Close driver that has been created using different method331 * @param driver332 */333 public static synchronized void closeDriver(WebDriver driver) {334 UiDriverPluginService.driverPlugins().beforeCloseDriver(driver);335 if (driver != null) {336 try {337 driver.close();338 } catch (Throwable ignore) {}339 try {340 if (!dontUseQuit()) {341 driver.quit();342 }343 } catch (Throwable ignore){}344 if (activeDrivers.contains(driver)) {345 activeDrivers.remove(driver);346 }347 }348 UiDriverPluginService.driverPlugins().afterCloseDriver();349 }350 /**351 * Close currently used driver352 */353 public static void closeDriver() {354 closeDriver(instance());355 instances.remove();356 }357 public static List<String> activeSessions() {358 return Lists.newArrayList(Iterables.transform(activeInstances(), new Function<WebDriver, String>() {359 @Override360 public String apply(WebDriver input) {361 return ((RemoteWebDriver) unwrap(input)).getSessionId().toString();362 }363 }));364 }365 public static boolean isSessionOpened(final String session) {366 return Iterables.tryFind(activeInstances(), new Predicate<WebDriver>() {367 @Override368 public boolean apply(WebDriver input) {369 return ((RemoteWebDriver) unwrap(input)).getSessionId().toString().equals(session);370 }371 }).isPresent();372 }373 @SuppressWarnings("unchecked")374 public static List<WebDriver> activeInstances() {375 return UnmodifiableList.decorate(activeDrivers);376 }377 public static void closeSession(final String session) {378 Optional<WebDriver> driver = Iterables.tryFind(activeInstances(), input -> ((RemoteWebDriver) unwrap(input)).getSessionId().toString().equals(session));379 if (driver.isPresent()) {380 closeDriver(driver.get());381 }382 }383 public static void destroy() {384 closeDriver();385 matrix = null;386 browser.remove();387 }388 private static final boolean dontUseQuit() {389 return ConfigLoader.config().getBoolean("webdriver.close.only", false);390 }391 private static String autoDownloadFiles() {392 return ConfigLoader.config().getString("webdriver.autodownload.files", DEFAULT_AUTO_DOWNLOAD);393 }394 private static Capabilities getCapabilities(String driverType) {395 DesiredCapabilities result = new DesiredCapabilities();396 switch (driverType) {397 case BrowserType.FIREFOX:398 result = DesiredCapabilities.firefox();399 FirefoxProfile profile = (FirefoxProfile) ConfigLoader.config().getProperty("firefox.profile");400 if (profile == null) {401 profile = new FirefoxProfile();402 if (ConfigLoader.config().getBoolean("webdriver.accept.java", true)) {403 profile.setPreference("plugin.state.java", 2);404 }405 if (ConfigLoader.config().getBoolean("webdriver.accept.ssl", true)) {406 profile.setAcceptUntrustedCertificates(true);407 profile.setAssumeUntrustedCertificateIssuer(true);408 }409 if (ConfigLoader.config().getBoolean("webdriver.autodownload", true)) {410 profile.setPreference("browser.download.folderList", 2);411 profile.setPreference("browser.helperApps.alwaysAsk.force", false);412 profile.setPreference("browser.download.manager.showWhenStarting", false);413 profile.setPreference("browser.helperApps.neverAsk.saveToDisk", autoDownloadFiles());414 }415 }416 result.setCapability(FirefoxDriver.PROFILE, profile);417 result.setCapability("acceptInsecureCerts", true);418 result.setCapability(FirefoxDriver.SystemProperty.DRIVER_USE_MARIONETTE, true);419 break;420 case BrowserType.IE:421 result = DesiredCapabilities.internetExplorer();422 result.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);423 result.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);424 result.setCapability("ie.validateCookieDocumentType", false);425 break;426 case BrowserType.CHROME:427 result = DesiredCapabilities.chrome();428 ChromeOptions chromOptions = new ChromeOptions();429 chromOptions.addArguments("chrome.switches", "--disable-extensions");430 if (ConfigLoader.config().getBoolean("noui",false)){431 chromOptions.addArguments("window-size=1200x900");432 chromOptions.setHeadless(config().getBoolean("webdriver.headless", true));433 }434 chromOptions.setAcceptInsecureCerts(true);435 result.setCapability(ChromeOptions.CAPABILITY, chromOptions);436 result.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);437 break;438 case "com.machinepublishers.jbrowserdriver.jbrowserdriver":439 result.merge(HeadlessWebDriver.jDriverCapabilities());440 break;441 default:442 result = new DesiredCapabilities(driverType, "", Platform.ANY);443 break;444 }445 String proxy = ConfigLoader.config().getString("webdriver.proxy");446 result.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);447 if (!Strings.isNullOrEmpty(proxy)) {448 Proxy p = new Proxy();449 p.setHttpProxy(proxy)450 .setSslProxy(proxy);451 result.setCapability(CapabilityType.PROXY, p);452 log.info("Using proxy {}", proxy);453 }454 result.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);455 result.setCapability("acceptInsecureCerts", true);456 return concatenate(result, capabilities);457 }458 private static Capabilities concatenate(Capabilities... toJoin) {459 return new DesiredCapabilities(toJoin);460 }461 private static Thread createDriverCloser(final WebDriver driver) {462 if (ConfigLoader.config().getBoolean("webdriver.dontclose", false)) {463 return new Thread(new Runnable() {464 @Override465 public void run() {466 log.info("Leaving open");467 }468 });469 } else {470 return new Thread(new Runnable() {471 @Override472 public void run() {473 closeDriver(driver);474 }475 });476 }477 }478 public static boolean isWrong(WebDriver driver) {479 try {480 driver.getCurrentUrl();481 return false;482 } catch (Exception e) {483 return true;484 }485 }486 private static boolean isWds() {487 return providers.get() != null;488 }489 public static final void setWds(WdsProvider provider) {490 UiDriverPluginService.driverPlugins().beforeInstantiateDriver();491 providers.set(provider);492 UiDriverPluginService.driverPlugins().afterInstantiateDriver(provider.wds());493 }494 private static WebDriver wdsInstance() {495 WebDriver wds = providers.get().wds();496 UiDriverPluginService.driverPlugins().beforeGetDriver();497 if (wdsInstances.get(wds) == null) {498 wdsInstances.put(wds, new VisibleElementFilter(providers.get().wds()));499 }500 UiDriverPluginService.driverPlugins().afterGetDriver(wdsInstances.get(wds));501 return wdsInstances.get(wds);502 }503 public static final WebDriver getDriver() {504 UiDriverPluginService.driverPlugins().beforeGetDriver();505 if (isWds()) return wdsInstance();506 if (instance() == null || isWrong(instance())) {507 UiDriverPluginService.driverPlugins().beforeInstantiateDriver();508 WebDriver dr = createRemoteDriver();509 if (wrap(dr)) {510 dr = new VisibleElementFilter(dr);511 }512 instances.set(dr);513 activeDrivers.add(dr);514 Runtime.getRuntime().addShutdownHook(createDriverCloser(instance()));515 UiDriverPluginService.driverPlugins().afterInstantiateDriver(dr);516 }517 UiDriverPluginService.driverPlugins().afterGetDriver(instance());518 return instance();519 }520 private static boolean wrap(WebDriver driver) {521 if (HasCapabilities.class.isAssignableFrom(driver.getClass())) {522 Capabilities cp = ((HasCapabilities) driver).getCapabilities();523 return !((cp != null) && cp.is("cannot_wrap"));524 } else return true;525 }526 private static boolean hasCapabilities(WebDriver driver, Capabilities capabilities) {527 return ((RemoteWebDriver) unwrap(driver)).getCapabilities().equals(capabilities);528 }529 public static final WebDriver getDriver(Capabilities desiredCapabilities) {530 if (instance() == null || !hasCapabilities(instance(), desiredCapabilities)) {531 setCapabilities(desiredCapabilities);532 instances.set(new VisibleElementFilter(createRemoteDriver()));533 }534 return instance();535 }536 public static final WebDriverWait delay(long timeInSeconds) {537 return new WebDriverWait(getDriver(), timeInSeconds);538 }539 public static final WebDriverWait delay() {540 return delay(ConfigLoader.config().getLong("webdriver.timeouts.implicitlywait", 5));541 }542 public static String browserName() {543 Capabilities caps = ((HasCapabilities) getUnwrappedDriver()).getCapabilities();544 return (caps == null) ? null : caps.getBrowserName();545 }546 public static boolean isIe() {547 return BrowserType.IE.equals(browserName());548 }549 public static boolean isPhantom() {550 return BrowserType.PHANTOMJS.equals(browserName());551 }552 public static boolean isEdge() {553 return BrowserType.EDGE.equals(browserName());554 }555 public static interface WdsProvider {556 WebDriver wds();557 }558 public static class VisibleElementFilter implements HasCapabilities, JavascriptExecutor, WebDriver, WrapsDriver {559 private static final UiObject browser = new UiObject(null, By.tagName("html"), "WebDriver");560 private final WebDriver driver;561 private final SearchContext searchContext;562 public VisibleElementFilter(WebDriver driver) {563 this.driver = driver;564 searchContext = new FilterableSearchContext(driver);565 }566 public void get(String url) {567 driver.get(url);568 }569 public String toString() {570 return String.format("VisibleElementFilter of %s", driver);571 }572 public String getCurrentUrl() {573 return driver.getCurrentUrl();574 }575 public String getTitle() {576 return driver.getTitle();577 }578 public List<WebElement> findElements(By by) {579 findPlugins().beforeFindElement(browser, by);580 List<WebElement> result = UiObject.wrapAll(searchContext.findElements(by), By.tagName("html"), by);581 findPlugins().afterFindElements(browser, by, result);582 return result;583 }584 public WebElement findElement(By by) {585 findPlugins().beforeFindElement(browser, by);586 WebElement result = UiObject.wrap(searchContext.findElement(by), by);587 findPlugins().afterFindElement(browser, by, result);588 return result;589 }590 public String getPageSource() {591 return driver.getPageSource();592 }593 public void close() {594 driver.close();595 }596 public void quit() {597 driver.quit();598 }599 public Set<String> getWindowHandles() {600 return driver.getWindowHandles();601 }602 public String getWindowHandle() {603 return driver.getWindowHandle();604 }605 public TargetLocator switchTo() {606 return driver.switchTo();607 }608 public Navigation navigate() {609 return driver.navigate();610 }611 public Options manage() {612 return driver.manage();613 }614 public WebDriver getWrappedDriver() {615 return driver;616 }617 @Override618 public Object executeScript(String script, Object... args) {619 return ((JavascriptExecutor) driver).executeScript(script, args);620 }621 @Override622 public Object executeAsyncScript(String script, Object... args) {623 return ((JavascriptExecutor) driver).executeAsyncScript(script, args);624 }625 @Override626 public Capabilities getCapabilities() {627 return ((HasCapabilities) driver).getCapabilities();628 }629 }630}...

Full Screen

Full Screen

Source:TimeoutManagement.java Github

copy

Full Screen

...2324 //amount of time the driver should wait when searching for an element if it is not immediately present.25 //driver should poll the page until the element has26 //been found, or this timeout expires before throwing a {@link NoSuchElementException}.27 timeouts.implicitlyWait(2, TimeUnit.SECONDS);2829 //amount of time to wait for a page load to complete before throwing an error30 timeouts.pageLoadTimeout(10, TimeUnit.SECONDS);3132 WebDriver.Navigation navigator = driver.navigate();33 navigator.to("http://www.google.com");3435 WebElement searchBox = driver.findElement(By.name("q"));36 searchBox.sendKeys("Selenium WebDriver");37 WebElement searchButton = driver.findElement(By.name("btnG"));38 searchButton.click();39 searchBox.clear();40 searchBox.sendKeys("Packt Publishing");41 searchButton.click(); ...

Full Screen

Full Screen

Source:WaiterInt.java Github

copy

Full Screen

1package waiters;2import org.openqa.selenium.By;3import org.openqa.selenium.WebElement;4import org.openqa.selenium.support.ui.ExpectedCondition;5/**6 * Интерфейс стандартного набора ожиданий7 * @author Pavel Balahonov <p.balahonov@corp.mail.ru>8 */9public interface WaiterInt {10 boolean waitForCondition(ExpectedCondition condition);11 long IMPLICITLY_WAIT_SECOND = Integer.parseInt(System.getProperty("webdriver.timeouts.implicitlywait", "5000")) / 1000;12}...

Full Screen

Full Screen

implicitlyWait

Using AI Code Generation

copy

Full Screen

1driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);2driver.manage().timeouts().setScriptTimeout(15, TimeUnit.SECONDS);3driver.manage().timeouts().pageLoadTimeout(20, TimeUnit.SECONDS);4driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);5driver.manage().timeouts().setScriptTimeout(15, TimeUnit.SECONDS);6driver.manage().timeouts().pageLoadTimeout(20, TimeUnit.SECONDS);7driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);8driver.manage().timeouts().setScriptTimeout(15, TimeUnit.SECONDS);9driver.manage().timeouts().pageLoadTimeout(20, TimeUnit.SECONDS);10driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);11driver.manage().timeouts().setScriptTimeout(15, TimeUnit.SECONDS);12driver.manage().timeouts().pageLoadTimeout(20, TimeUnit.SECONDS

Full Screen

Full Screen

implicitlyWait

Using AI Code Generation

copy

Full Screen

1driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);2WebDriverWait wait = new WebDriverWait(driver, 10);3wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("someid")));4WebDriverWait wait = new WebDriverWait(driver, 10);5wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("someid")));6WebDriverWait wait = new WebDriverWait(driver, 10);7wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("someid")));8WebDriverWait wait = new WebDriverWait(driver, 10);9wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("someid")));10WebDriverWait wait = new WebDriverWait(driver, 10);11wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("someid")));12WebDriverWait wait = new WebDriverWait(driver, 10);13wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("someid")));14WebDriverWait wait = new WebDriverWait(driver, 10);15wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("someid")));16WebDriverWait wait = new WebDriverWait(driver, 10);17wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("someid")));18WebDriverWait wait = new WebDriverWait(driver, 10);19wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("someid")));20WebDriverWait wait = new WebDriverWait(driver, 10);21wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("someid")));22WebDriverWait wait = new WebDriverWait(driver, 10);23wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("someid")));24WebDriverWait wait = new WebDriverWait(driver, 10);25wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("someid")));

Full Screen

Full Screen

Selenium 4 Tutorial:

LambdaTest’s Selenium 4 tutorial is covering every aspects of Selenium 4 testing with examples and best practices. Here you will learn basics, such as how to upgrade from Selenium 3 to Selenium 4, to some advanced concepts, such as Relative locators and Selenium Grid 4 for Distributed testing. Also will learn new features of Selenium 4, such as capturing screenshots of specific elements, opening a new tab or window on the browser, and new protocol adoptions.

Chapters:

  1. Upgrading From Selenium 3 To Selenium 4?: In this chapter, learn in detail how to update Selenium 3 to Selenium 4 for Java binding. Also, learn how to upgrade while using different build tools such as Maven or Gradle and get comprehensive guidance for upgrading Selenium.

  2. What’s New In Selenium 4 & What’s Being Deprecated? : Get all information about new implementations in Selenium 4, such as W3S protocol adaption, Optimized Selenium Grid, and Enhanced Selenium IDE. Also, learn what is deprecated for Selenium 4, such as DesiredCapabilites and FindsBy methods, etc.

  3. Selenium 4 With Python: Selenium supports all major languages, such as Python, C#, Ruby, and JavaScript. In this chapter, learn how to install Selenium 4 for Python and the features of Python in Selenium 4, such as Relative locators, Browser manipulation, and Chrom DevTool protocol.

  4. Selenium 4 Is Now W3C Compliant: JSON Wireframe protocol is retiring from Selenium 4, and they are adopting W3C protocol to learn in detail about the advantages and impact of these changes.

  5. How To Use Selenium 4 Relative Locator? : Selenium 4 came with new features such as Relative Locators that allow constructing locators with reference and easily located constructors nearby. Get to know its different use cases with examples.

  6. Selenium Grid 4 Tutorial For Distributed Testing: Selenium Grid 4 allows you to perform tests over different browsers, OS, and device combinations. It also enables parallel execution browser testing, reads up on various features of Selenium Grid 4 and how to download it, and runs a test on Selenium Grid 4 with best practices.

  7. Selenium Video Tutorials: Binge on video tutorials on Selenium by industry experts to get step-by-step direction from automating basic to complex test scenarios with Selenium.

Selenium 101 certifications:

LambdaTest also provides certification for Selenium testing to accelerate your career in Selenium automation testing.

Run Selenium automation tests on LambdaTest cloud grid

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

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful