diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml new file mode 100644 index 00000000000..76549f2eed9 --- /dev/null +++ b/.github/workflows/codeql-analysis.yml @@ -0,0 +1,41 @@ +name: "CodeQL" + +on: + push: + branches: [ master ] + pull_request: + # The branches below must be a subset of the branches above + branches: [ master ] + schedule: + - cron: '20 9 * * 2' + +jobs: + analyze: + name: Analyze + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + language: [ 'java' ] + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v1 + with: + languages: ${{ matrix.language }} + + - name: Set up JDK 15 + uses: actions/setup-java@v1.4.3 + with: + java-version: 15 + + - name: Build SHAFT_Engine + run: mvn clean install -DskipTests + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v1 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0a9de5327f3..3b6a8b499b9 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,6 +1,13 @@ name: Ubuntu - Test -on: [pull_request] +on: + push: + branches: [ master ] + pull_request: + # The branches below must be a subset of the branches above + branches: [ master ] + schedule: + - cron: '00 1 * * *' jobs: build: @@ -22,7 +29,7 @@ jobs: run: docker ps - name: Run all tests continue-on-error: true - run: mvn test -DexecutionAddress="localhost:4444" -DtargetOperatingSystem="Linux-64" -DmaximumPerformanceMode="true" -DtargetBrowserName="GoogleChrome" -Dtest="!%regex[.*checksum.*], !%regex[.*cucumber.*], !%regex[.*sikulix.*], !%regex[.*imageComparison.*], !%regex[.*FileActions.*], !%regex[.*TerminalActions.*], !%regex[.*localShell.*], !%regex[.*fullPageScreenshotWithHeader.*], !%regex[.*dbConnection.*], !%regex[.*Appium.*]" + run: mvn test -DexecutionAddress="localhost:4444" -DtargetOperatingSystem="Linux-64" -DmaximumPerformanceMode="2" -DtargetBrowserName="GoogleChrome" -Dtest="!%regex[.*checksum.*], !%regex[.*cucumber.*], !%regex[.*sikulix.*], !%regex[.*imageComparison.*], !%regex[.*FileActions.*], !%regex[.*TerminalActions.*], !%regex[.*localShell.*], !%regex[.*fullPageScreenshotWithHeader.*], !%regex[.*dbConnection.*], !%regex[.*Appium.*]" - name: Generate Allure Report with history uses: simple-elf/allure-report-action@v1.3 with: @@ -39,7 +46,7 @@ jobs: - name: Deploy report to Github Pages uses: peaceiris/actions-gh-pages@v3.7.3 with: - personal_token: ${{ secrets.PERSONAL_TOKEN }} + personal_token: ${{ secrets.GITHUB_TOKEN }} publish_dir: allure-history/allure destination_dir: allure publish_branch: gh-pages diff --git a/.gitignore b/.gitignore index 47dfdf7c031..dc270dc3858 100755 --- a/.gitignore +++ b/.gitignore @@ -14,4 +14,5 @@ /.git/* *.iml ajcore*.txt -debug.log \ No newline at end of file +debug.log +/extent-reports/ \ No newline at end of file diff --git a/README.md b/README.md index 79fc5930f55..a3a22ebccf7 100755 --- a/README.md +++ b/README.md @@ -7,11 +7,11 @@ [![Maven Central](https://img.shields.io/maven-central/v/io.github.mohabmohie/SHAFT_ENGINE?style=for-the-badge)](https://search.maven.org/search?q=g:%22io.github.mohabmohie%22%20AND%20a:%22SHAFT_ENGINE%22) [![Codacy grade](https://img.shields.io/codacy/grade/3579cfd02a2c4f67bd1dce5dad0b1562?style=for-the-badge)](https://www.codacy.com/manual/mohab.mohieeldeen/SHAFT_ENGINE?utm_source=github.com&utm_medium=referral&utm_content=MohabMohie/SHAFT_ENGINE&utm_campaign=Badge_Grade) - [![GitHub Workflow Status](https://img.shields.io/github/workflow/status/MohabMohie/SHAFT_ENGINE/CodeQL%20-%20Security%20Analysis?label=CodeQL%20-%20Security%20Analysis&style=for-the-badge)](https://github.com/MohabMohie/SHAFT_ENGINE/actions?query=workflow%3A%22CodeQL+-+Security+Analysis%22) - [![GitHub Workflow Status](https://img.shields.io/github/workflow/status/MohabMohie/SHAFT_ENGINE/Ubuntu%20-%20Test?label=Ubuntu%20-%20Test&style=for-the-badge)](https://github.com/MohabMohie/SHAFT_ENGINE/actions?query=workflow%3A%22Ubuntu+-+Test%22) + [![GitHub Workflow Status](https://img.shields.io/github/workflow/status/MohabMohie/SHAFT_Engine/CodeQL?label=CodeQL&style=for-the-badge)](https://github.com/MohabMohie/SHAFT_ENGINE/actions?query=workflow%3ACodeQL) + [![GitHub Workflow Status](https://img.shields.io/github/workflow/status/MohabMohie/SHAFT_Engine/Ubuntu%20-%20Test?label=Ubuntu%20-%20Test&style=for-the-badge)](https://github.com/MohabMohie/SHAFT_ENGINE/actions?query=workflow%3A%22Ubuntu+-+Test%22) -#### If you want to contribute to this project, or you need any help/support getting started feel free to join our online Facebook group Automatest: -[![Automatest](https://facebookbrand.com/wp-content/uploads/2019/04/f_logo_RGB-Hex-Blue_512.png?w=50&h=50)](https://www.facebook.com/groups/Automatest) +#### To contribute to SHAFT_Engine join our Slack Channel, for support using SHAFT_Engine join our Facebook group: +automatest-workspace Automatest ### Getting Started: - How to do cross-browser test automation in 10 minutes using SHAFT_Engine ▶️: diff --git a/docker-compose_native.yml b/docker-compose_native.yml index cf21eae9ba5..1e705669089 100644 --- a/docker-compose_native.yml +++ b/docker-compose_native.yml @@ -1,55 +1,95 @@ # This file can be used to quickly setup a selenium grid with one hub and two nodes + # https://github.com/SeleniumHQ/docker-selenium + # docker-compose -f docker-compose_native.yml up --scale chrome=4 --remove-orphans -d + # add '-d' option for detached execution + # docker-compose -f docker-compose_native.yml down --remove-orphans + # http://localhost:4444/grid/console -version: '3' + +version: '3.7' + services: + selenium-hub: - #image: selenium/hub:3.141.59-20200515 - image: selenium/hub:4.0.0 + + image: selenium/hub:3.141.59-20200515 + ports: - - "4442:4442" - - "4443:4443" - - "4444:4444" + + - 4444:4444 + environment: + GRID_MAX_SESSION: 5 + GRID_BROWSER_TIMEOUT: 300 + GRID_TIMEOUT: 300 + chrome: - #image: selenium/node-chrome:3.141.59-20200515 - image: selenium/node-chrome:4.0.0 + + image: selenium/node-chrome:3.141.59-20200515 + depends_on: - - selenium-hub + + - selenium-hub + shm_size: 2gb + volumes: + - /dev/shm:/dev/shm + environment: - SE_EVENT_BUS_HOST: selenium-hub - SE_EVENT_BUS_PUBLISH_PORT: 4442 - SE_EVENT_BUS_SUBSCRIBE_PORT: 4443 + + HUB_HOST: selenium-hub + + HUB_PORT: 4444 + SCREEN_WIDTH: 1920 + SCREEN_HEIGHT: 1080 + # set false for headless execution + START_XVFB: "false" + NODE_MAX_SESSION: 1 + NODE_MAX_INSTANCES: 1 + # firefox: + # image: selenium/node-firefox:3.141.59-20200515 -# image: selenium/node-firefox:4.0.0 + # depends_on: -# - selenium-hub + +# - selenium-hub + # shm_size: 2gb + # volumes: + # - /dev/shm:/dev/shm + # environment: -# SE_EVENT_BUS_HOST: selenium-hub -# SE_EVENT_BUS_PUBLISH_PORT: 4442 -# SE_EVENT_BUS_SUBSCRIBE_PORT: 4443 + +# HUB_HOST: selenium-hub + +# HUB_PORT: 4444 + # SCREEN_WIDTH: 1920 + # SCREEN_HEIGHT: 1080 + ## set false for headless execution + # START_XVFB: "false" + # NODE_MAX_SESSION: 1 -# NODE_MAX_INSTANCES: 1 \ No newline at end of file + +# NODE_MAX_INSTANCES: 1 diff --git a/docker-compose_native4.0.yml b/docker-compose_native4.0.yml new file mode 100644 index 00000000000..85640461009 --- /dev/null +++ b/docker-compose_native4.0.yml @@ -0,0 +1,55 @@ +# This file can be used to quickly setup a selenium grid with one hub and two nodes +# https://github.com/SeleniumHQ/docker-selenium +# docker-compose -f docker-compose_native.yml up --scale chrome=4 --remove-orphans -d +# add '-d' option for detached execution +# docker-compose -f docker-compose_native.yml down --remove-orphans +# http://localhost:4444/grid/console +version: '3' +services: + selenium-hub: + #image: selenium/hub:3.141.59-20200515 + image: selenium/hub:4.0.0 + ports: + - "4442:4442" + - "4443:4443" + - "4444:4444" + environment: + GRID_MAX_SESSION: 5 + GRID_BROWSER_TIMEOUT: 300 + GRID_TIMEOUT: 300 + chrome: + #image: selenium/node-chrome:3.141.59-20200515 + image: selenium/node-chrome:4.0.0 + depends_on: + - selenium-hub + shm_size: 2gb + volumes: + - /dev/shm:/dev/shm + environment: + SE_EVENT_BUS_HOST: selenium-hub + SE_EVENT_BUS_PUBLISH_PORT: 4442 + SE_EVENT_BUS_SUBSCRIBE_PORT: 4443 + SCREEN_WIDTH: 1920 + SCREEN_HEIGHT: 1080 + # set false for headless execution + START_XVFB: "false" + NODE_MAX_SESSION: 1 + NODE_MAX_INSTANCES: 1 +# firefox: +# image: selenium/node-firefox:3.141.59-20200515 +# image: selenium/node-firefox:4.0.0 +# depends_on: +# - selenium-hub +# shm_size: 2gb +# volumes: +# - /dev/shm:/dev/shm +# environment: +# SE_EVENT_BUS_HOST: selenium-hub +# SE_EVENT_BUS_PUBLISH_PORT: 4442 +# SE_EVENT_BUS_SUBSCRIBE_PORT: 4443 +# SCREEN_WIDTH: 1920 +# SCREEN_HEIGHT: 1080 +## set false for headless execution +# START_XVFB: "false" +# NODE_MAX_SESSION: 1 +# NODE_MAX_INSTANCES: 1 diff --git a/pom.xml b/pom.xml index 02acb450363..aa1933635cf 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 io.github.mohabmohie SHAFT_ENGINE - 4.4.20201208 + 5.1.20210217 ${project.groupId}:${project.artifactId} Selenium Hybrid Automation Framework for Testing [SHAFT] https://github.com/MohabMohie/SHAFT_ENGINE @@ -30,12 +30,13 @@ - 4.0.0-alpha-6 + 4.0.0-alpha-7 3.141.59 7.4.1 4.3.1 2.13.8 + 5.0.6 1.9.6 4.3.3 @@ -46,7 +47,7 @@ 7.3.0 8.0.23 - 9.1.1.jre15-preview + 9.2.0.jre15 9.1-901-1.jdbc4 @@ -64,7 +65,7 @@ 0.1.55 - 6.9.1 + 6.10.2 1.9 4.3.0-3 @@ -77,6 +78,10 @@ mvn clean install -DskipTests mvn resources:resources javadoc:javadoc scm-publish:publish-scm + + + https://automatest.jfrog.io/ + io/github/mohabmohie/SHAFT_ENGINE/${project.version} @@ -224,6 +229,13 @@ ${aspectj.version} + + + com.aventstack + extentreports + ${extentreports.version} + + io.rest-assured diff --git a/src/main/java/com/shaft/cli/FileActions.java b/src/main/java/com/shaft/cli/FileActions.java index 301aec18e5b..bbc076c5144 100755 --- a/src/main/java/com/shaft/cli/FileActions.java +++ b/src/main/java/com/shaft/cli/FileActions.java @@ -7,6 +7,7 @@ import org.apache.commons.io.IOUtils; import org.apache.commons.io.filefilter.TrueFileFilter; import org.apache.commons.lang3.SystemUtils; +import org.sikuli.basics.FileManager; import org.testng.Assert; import java.io.*; @@ -295,17 +296,9 @@ public static byte[] readFromImageFile(String pathToTargetImage) { } public static String readFromFile(String pathToTargetFile) { - String text = ""; String absoluteFilePath = getAbsolutePath(pathToTargetFile); - Path filePath = Paths.get(absoluteFilePath); - - try { - text = String.join(System.lineSeparator(), Files.readAllLines(filePath)); - passAction("File Path: \"" + filePath + "\"", text); - } catch (IOException e) { - ReportManager.log(e); - failAction(e); - } + String text = FileManager.readFileToString(new File(absoluteFilePath)); + passAction("File Path: \"" + absoluteFilePath + "\"", text); return text; } diff --git a/src/main/java/com/shaft/gui/browser/BrowserFactory.java b/src/main/java/com/shaft/gui/browser/BrowserFactory.java index 122715d6ac0..94c21810dba 100755 --- a/src/main/java/com/shaft/gui/browser/BrowserFactory.java +++ b/src/main/java/com/shaft/gui/browser/BrowserFactory.java @@ -323,92 +323,87 @@ private static void setDriverOptions(String browserName, MutableCapabilities cus switch (browserType) { case MOZILLA_FIREFOX: + ffOptions = new FirefoxOptions(); if (customBrowserOptions != null) { ffOptions = (FirefoxOptions) customBrowserOptions; - } else { - ffOptions = new FirefoxOptions(); - ffOptions.setCapability(CapabilityType.PLATFORM_NAME, getDesiredOperatingSystem()); - ffOptions.setCapability(CapabilityType.HAS_NATIVE_EVENTS, true); - ffOptions.setCapability(CapabilityType.LOGGING_PREFS, logPrefs); - if (Boolean.TRUE.equals(HEADLESS_EXECUTION)) { - // https://developer.mozilla.org/en-US/docs/Mozilla/Firefox/Headless_mode - ffOptions.addArguments("-headless"); - } - ffOptions.addArguments("-foreground"); - - FirefoxProfile ffProfile = new FirefoxProfile(); - ffProfile.setPreference("browser.download.dir", downloadsFolderPath); - ffProfile.setPreference("browser.download.folderList", 2); - ffProfile.setPreference("browser.helperApps.neverAsk.saveToDisk", - "application/vnd.hzn-3d-crossword;video/3gpp;video/3gpp2;application/vnd.mseq;application/vnd.3m.post-it-notes;application/vnd.3gpp.pic-bw-large;application/vnd.3gpp.pic-bw-small;application/vnd.3gpp.pic-bw-var;application/vnd.3gp2.tcap;application/x-7z-compressed;application/x-abiword;application/x-ace-compressed;application/vnd.americandynamics.acc;application/vnd.acucobol;application/vnd.acucorp;audio/adpcm;application/x-authorware-bin;application/x-athorware-map;application/x-authorware-seg;application/vnd.adobe.air-application-installer-package+zip;application/x-shockwave-flash;application/vnd.adobe.fxp;application/pdf;application/vnd.cups-ppd;application/x-director;applicaion/vnd.adobe.xdp+xml;application/vnd.adobe.xfdf;audio/x-aac;application/vnd.ahead.space;application/vnd.airzip.filesecure.azf;application/vnd.airzip.filesecure.azs;application/vnd.amazon.ebook;application/vnd.amiga.ami;applicatin/andrew-inset;application/vnd.android.package-archive;application/vnd.anser-web-certificate-issue-initiation;application/vnd.anser-web-funds-transfer-initiation;application/vnd.antix.game-component;application/vnd.apple.installe+xml;application/applixware;application/vnd.hhe.lesson-player;application/vnd.aristanetworks.swi;text/x-asm;application/atomcat+xml;application/atomsvc+xml;application/atom+xml;application/pkix-attr-cert;audio/x-aiff;video/x-msvieo;application/vnd.audiograph;image/vnd.dxf;model/vnd.dwf;text/plain-bas;application/x-bcpio;application/octet-stream;image/bmp;application/x-bittorrent;application/vnd.rim.cod;application/vnd.blueice.multipass;application/vnd.bm;application/x-sh;image/prs.btif;application/vnd.businessobjects;application/x-bzip;application/x-bzip2;application/x-csh;text/x-c;application/vnd.chemdraw+xml;text/css;chemical/x-cdx;chemical/x-cml;chemical/x-csml;application/vn.contact.cmsg;application/vnd.claymore;application/vnd.clonk.c4group;image/vnd.dvb.subtitle;application/cdmi-capability;application/cdmi-container;application/cdmi-domain;application/cdmi-object;application/cdmi-queue;applicationvnd.cluetrust.cartomobile-config;application/vnd.cluetrust.cartomobile-config-pkg;image/x-cmu-raster;model/vnd.collada+xml;text/csv;application/mac-compactpro;application/vnd.wap.wmlc;image/cgm;x-conference/x-cooltalk;image/x-cmx;application/vnd.xara;application/vnd.cosmocaller;application/x-cpio;application/vnd.crick.clicker;application/vnd.crick.clicker.keyboard;application/vnd.crick.clicker.palette;application/vnd.crick.clicker.template;application/vn.crick.clicker.wordbank;application/vnd.criticaltools.wbs+xml;application/vnd.rig.cryptonote;chemical/x-cif;chemical/x-cmdf;application/cu-seeme;application/prs.cww;text/vnd.curl;text/vnd.curl.dcurl;text/vnd.curl.mcurl;text/vnd.crl.scurl;application/vnd.curl.car;application/vnd.curl.pcurl;application/vnd.yellowriver-custom-menu;application/dssc+der;application/dssc+xml;application/x-debian-package;audio/vnd.dece.audio;image/vnd.dece.graphic;video/vnd.dec.hd;video/vnd.dece.mobile;video/vnd.uvvu.mp4;video/vnd.dece.pd;video/vnd.dece.sd;video/vnd.dece.video;application/x-dvi;application/vnd.fdsn.seed;application/x-dtbook+xml;application/x-dtbresource+xml;application/vnd.dvb.ait;applcation/vnd.dvb.service;audio/vnd.digital-winds;image/vnd.djvu;application/xml-dtd;application/vnd.dolby.mlp;application/x-doom;application/vnd.dpgraph;audio/vnd.dra;application/vnd.dreamfactory;audio/vnd.dts;audio/vnd.dts.hd;imag/vnd.dwg;application/vnd.dynageo;application/ecmascript;application/vnd.ecowin.chart;image/vnd.fujixerox.edmics-mmr;image/vnd.fujixerox.edmics-rlc;application/exi;application/vnd.proteus.magazine;application/epub+zip;message/rfc82;application/vnd.enliven;application/vnd.is-xpr;image/vnd.xiff;application/vnd.xfdl;application/emma+xml;application/vnd.ezpix-album;application/vnd.ezpix-package;image/vnd.fst;video/vnd.fvt;image/vnd.fastbidsheet;application/vn.denovo.fcselayout-link;video/x-f4v;video/x-flv;image/vnd.fpx;image/vnd.net-fpx;text/vnd.fmi.flexstor;video/x-fli;application/vnd.fluxtime.clip;application/vnd.fdf;text/x-fortran;application/vnd.mif;application/vnd.framemaker;imae/x-freehand;application/vnd.fsc.weblaunch;application/vnd.frogans.fnc;application/vnd.frogans.ltf;application/vnd.fujixerox.ddd;application/vnd.fujixerox.docuworks;application/vnd.fujixerox.docuworks.binder;application/vnd.fujitu.oasys;application/vnd.fujitsu.oasys2;application/vnd.fujitsu.oasys3;application/vnd.fujitsu.oasysgp;application/vnd.fujitsu.oasysprs;application/x-futuresplash;application/vnd.fuzzysheet;image/g3fax;application/vnd.gmx;model/vn.gtw;application/vnd.genomatix.tuxedo;application/vnd.geogebra.file;application/vnd.geogebra.tool;model/vnd.gdl;application/vnd.geometry-explorer;application/vnd.geonext;application/vnd.geoplan;application/vnd.geospace;applicatio/x-font-ghostscript;application/x-font-bdf;application/x-gtar;application/x-texinfo;application/x-gnumeric;application/vnd.google-earth.kml+xml;application/vnd.google-earth.kmz;application/vnd.grafeq;image/gif;text/vnd.graphviz;aplication/vnd.groove-account;application/vnd.groove-help;application/vnd.groove-identity-message;application/vnd.groove-injector;application/vnd.groove-tool-message;application/vnd.groove-tool-template;application/vnd.groove-vcar;video/h261;video/h263;video/h264;application/vnd.hp-hpid;application/vnd.hp-hps;application/x-hdf;audio/vnd.rip;application/vnd.hbci;application/vnd.hp-jlyt;application/vnd.hp-pcl;application/vnd.hp-hpgl;application/vnd.yamaha.h-script;application/vnd.yamaha.hv-dic;application/vnd.yamaha.hv-voice;application/vnd.hydrostatix.sof-data;application/hyperstudio;application/vnd.hal+xml;text/html;application/vnd.ibm.rights-management;application/vnd.ibm.securecontainer;text/calendar;application/vnd.iccprofile;image/x-icon;application/vnd.igloader;image/ief;application/vnd.immervision-ivp;application/vnd.immervision-ivu;application/reginfo+xml;text/vnd.in3d.3dml;text/vnd.in3d.spot;mode/iges;application/vnd.intergeo;application/vnd.cinderella;application/vnd.intercon.formnet;application/vnd.isac.fcs;application/ipfix;application/pkix-cert;application/pkixcmp;application/pkix-crl;application/pkix-pkipath;applicaion/vnd.insors.igm;application/vnd.ipunplugged.rcprofile;application/vnd.irepository.package+xml;text/vnd.sun.j2me.app-descriptor;application/java-archive;application/java-vm;application/x-java-jnlp-file;application/java-serializd-object;text/x-java-source,java;application/javascript;application/json;application/vnd.joost.joda-archive;video/jpm;image/jpeg;video/jpeg;application/vnd.kahootz;application/vnd.chipnuts.karaoke-mmd;application/vnd.kde.karbon;aplication/vnd.kde.kchart;application/vnd.kde.kformula;application/vnd.kde.kivio;application/vnd.kde.kontour;application/vnd.kde.kpresenter;application/vnd.kde.kspread;application/vnd.kde.kword;application/vnd.kenameaapp;applicatin/vnd.kidspiration;application/vnd.kinar;application/vnd.kodak-descriptor;application/vnd.las.las+xml;application/x-latex;application/vnd.llamagraphics.life-balance.desktop;application/vnd.llamagraphics.life-balance.exchange+xml;application/vnd.jam;application/vnd.lotus-1-2-3;application/vnd.lotus-approach;application/vnd.lotus-freelance;application/vnd.lotus-notes;application/vnd.lotus-organizer;application/vnd.lotus-screencam;application/vnd.lotus-wordro;audio/vnd.lucent.voice;audio/x-mpegurl;video/x-m4v;application/mac-binhex40;application/vnd.macports.portpkg;application/vnd.osgeo.mapguide.package;application/marc;application/marcxml+xml;application/mxf;application/vnd.wolfrm.player;application/mathematica;application/mathml+xml;application/mbox;application/vnd.medcalcdata;application/mediaservercontrol+xml;application/vnd.mediastation.cdkey;application/vnd.mfer;application/vnd.mfmp;model/mesh;appliation/mads+xml;application/mets+xml;application/mods+xml;application/metalink4+xml;application/vnd.ms-powerpoint.template.macroenabled.12;application/vnd.ms-word.document.macroenabled.12;application/vnd.ms-word.template.macroenabed.12;application/vnd.mcd;application/vnd.micrografx.flo;application/vnd.micrografx.igx;application/vnd.eszigno3+xml;application/x-msaccess;video/x-ms-asf;application/x-msdownload;application/vnd.ms-artgalry;application/vnd.ms-ca-compressed;application/vnd.ms-ims;application/x-ms-application;application/x-msclip;image/vnd.ms-modi;application/vnd.ms-fontobject;application/vnd.ms-excel;application/vnd.ms-excel.addin.macroenabled.12;application/vnd.ms-excelsheet.binary.macroenabled.12;application/vnd.ms-excel.template.macroenabled.12;application/vnd.ms-excel.sheet.macroenabled.12;application/vnd.ms-htmlhelp;application/x-mscardfile;application/vnd.ms-lrm;application/x-msmediaview;aplication/x-msmoney;application/vnd.openxmlformats-officedocument.presentationml.presentation;application/vnd.openxmlformats-officedocument.presentationml.slide;application/vnd.openxmlformats-officedocument.presentationml.slideshw;application/vnd.openxmlformats-officedocument.presentationml.template;application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;application/vnd.openxmlformats-officedocument.spreadsheetml.template;application/vnd.openxmformats-officedocument.wordprocessingml.document;application/vnd.openxmlformats-officedocument.wordprocessingml.template;application/x-msbinder;application/vnd.ms-officetheme;application/onenote;audio/vnd.ms-playready.media.pya;vdeo/vnd.ms-playready.media.pyv;application/vnd.ms-powerpoint;application/vnd.ms-powerpoint.addin.macroenabled.12;application/vnd.ms-powerpoint.slide.macroenabled.12;application/vnd.ms-powerpoint.presentation.macroenabled.12;appliation/vnd.ms-powerpoint.slideshow.macroenabled.12;application/vnd.ms-project;application/x-mspublisher;application/x-msschedule;application/x-silverlight-app;application/vnd.ms-pki.stl;application/vnd.ms-pki.seccat;application/vn.visio;video/x-ms-wm;audio/x-ms-wma;audio/x-ms-wax;video/x-ms-wmx;application/x-ms-wmd;application/vnd.ms-wpl;application/x-ms-wmz;video/x-ms-wmv;video/x-ms-wvx;application/x-msmetafile;application/x-msterminal;application/msword;application/x-mswrite;application/vnd.ms-works;application/x-ms-xbap;application/vnd.ms-xpsdocument;audio/midi;application/vnd.ibm.minipay;application/vnd.ibm.modcap;application/vnd.jcp.javame.midlet-rms;application/vnd.tmobile-ivetv;application/x-mobipocket-ebook;application/vnd.mobius.mbk;application/vnd.mobius.dis;application/vnd.mobius.plc;application/vnd.mobius.mqy;application/vnd.mobius.msl;application/vnd.mobius.txf;application/vnd.mobius.daf;tex/vnd.fly;application/vnd.mophun.certificate;application/vnd.mophun.application;video/mj2;audio/mpeg;video/vnd.mpegurl;video/mpeg;application/mp21;audio/mp4;video/mp4;application/mp4;application/vnd.apple.mpegurl;application/vnd.msician;application/vnd.muvee.style;application/xv+xml;application/vnd.nokia.n-gage.data;application/vnd.nokia.n-gage.symbian.install;application/x-dtbncx+xml;application/x-netcdf;application/vnd.neurolanguage.nlu;application/vnd.na;application/vnd.noblenet-directory;application/vnd.noblenet-sealer;application/vnd.noblenet-web;application/vnd.nokia.radio-preset;application/vnd.nokia.radio-presets;text/n3;application/vnd.novadigm.edm;application/vnd.novadim.edx;application/vnd.novadigm.ext;application/vnd.flographit;audio/vnd.nuera.ecelp4800;audio/vnd.nuera.ecelp7470;audio/vnd.nuera.ecelp9600;application/oda;application/ogg;audio/ogg;video/ogg;application/vnd.oma.dd2+xml;applicatin/vnd.oasis.opendocument.text-web;application/oebps-package+xml;application/vnd.intu.qbo;application/vnd.openofficeorg.extension;application/vnd.yamaha.openscoreformat;audio/webm;video/webm;application/vnd.oasis.opendocument.char;application/vnd.oasis.opendocument.chart-template;application/vnd.oasis.opendocument.database;application/vnd.oasis.opendocument.formula;application/vnd.oasis.opendocument.formula-template;application/vnd.oasis.opendocument.grapics;application/vnd.oasis.opendocument.graphics-template;application/vnd.oasis.opendocument.image;application/vnd.oasis.opendocument.image-template;application/vnd.oasis.opendocument.presentation;application/vnd.oasis.opendocumen.presentation-template;application/vnd.oasis.opendocument.spreadsheet;application/vnd.oasis.opendocument.spreadsheet-template;application/vnd.oasis.opendocument.text;application/vnd.oasis.opendocument.text-master;application/vnd.asis.opendocument.text-template;image/ktx;application/vnd.sun.xml.calc;application/vnd.sun.xml.calc.template;application/vnd.sun.xml.draw;application/vnd.sun.xml.draw.template;application/vnd.sun.xml.impress;application/vnd.sun.xl.impress.template;application/vnd.sun.xml.math;application/vnd.sun.xml.writer;application/vnd.sun.xml.writer.global;application/vnd.sun.xml.writer.template;application/x-font-otf;application/vnd.yamaha.openscoreformat.osfpvg+xml;application/vnd.osgi.dp;application/vnd.palm;text/x-pascal;application/vnd.pawaafile;application/vnd.hp-pclxl;application/vnd.picsel;image/x-pcx;image/vnd.adobe.photoshop;application/pics-rules;image/x-pict;application/x-chat;aplication/pkcs10;application/x-pkcs12;application/pkcs7-mime;application/pkcs7-signature;application/x-pkcs7-certreqresp;application/x-pkcs7-certificates;application/pkcs8;application/vnd.pocketlearn;image/x-portable-anymap;image/-portable-bitmap;application/x-font-pcf;application/font-tdpfr;application/x-chess-pgn;image/x-portable-graymap;image/png;image/x-portable-pixmap;application/pskc+xml;application/vnd.ctc-posml;application/postscript;application/xfont-type1;application/vnd.powerbuilder6;application/pgp-encrypted;application/pgp-signature;application/vnd.previewsystems.box;application/vnd.pvi.ptid1;application/pls+xml;application/vnd.pg.format;application/vnd.pg.osasli;tex/prs.lines.tag;application/x-font-linux-psf;application/vnd.publishare-delta-tree;application/vnd.pmi.widget;application/vnd.quark.quarkxpress;application/vnd.epson.esf;application/vnd.epson.msf;application/vnd.epson.ssf;applicaton/vnd.epson.quickanime;application/vnd.intu.qfx;video/quicktime;application/x-rar-compressed;audio/x-pn-realaudio;audio/x-pn-realaudio-plugin;application/rsd+xml;application/vnd.rn-realmedia;application/vnd.realvnc.bed;applicatin/vnd.recordare.musicxml;application/vnd.recordare.musicxml+xml;application/relax-ng-compact-syntax;application/vnd.data-vision.rdz;application/rdf+xml;application/vnd.cloanto.rp9;application/vnd.jisp;application/rtf;text/richtex;application/vnd.route66.link66+xml;application/rss+xml;application/shf+xml;application/vnd.sailingtracker.track;image/svg+xml;application/vnd.sus-calendar;application/sru+xml;application/set-payment-initiation;application/set-reistration-initiation;application/vnd.sema;application/vnd.semd;application/vnd.semf;application/vnd.seemail;application/x-font-snf;application/scvp-vp-request;application/scvp-vp-response;application/scvp-cv-request;application/svp-cv-response;application/sdp;text/x-setext;video/x-sgi-movie;application/vnd.shana.informed.formdata;application/vnd.shana.informed.formtemplate;application/vnd.shana.informed.interchange;application/vnd.shana.informed.package;application/thraud+xml;application/x-shar;image/x-rgb;application/vnd.epson.salt;application/vnd.accpac.simply.aso;application/vnd.accpac.simply.imp;application/vnd.simtech-mindmapper;application/vnd.commonspace;application/vnd.ymaha.smaf-audio;application/vnd.smaf;application/vnd.yamaha.smaf-phrase;application/vnd.smart.teacher;application/vnd.svd;application/sparql-query;application/sparql-results+xml;application/srgs;application/srgs+xml;application/sml+xml;application/vnd.koan;text/sgml;application/vnd.stardivision.calc;application/vnd.stardivision.draw;application/vnd.stardivision.impress;application/vnd.stardivision.math;application/vnd.stardivision.writer;application/vnd.tardivision.writer-global;application/vnd.stepmania.stepchart;application/x-stuffit;application/x-stuffitx;application/vnd.solent.sdkm+xml;application/vnd.olpc-sugar;audio/basic;application/vnd.wqd;application/vnd.symbian.install;application/smil+xml;application/vnd.syncml+xml;application/vnd.syncml.dm+wbxml;application/vnd.syncml.dm+xml;application/x-sv4cpio;application/x-sv4crc;application/sbml+xml;text/tab-separated-values;image/tiff;application/vnd.to.intent-module-archive;application/x-tar;application/x-tcl;application/x-tex;application/x-tex-tfm;application/tei+xml;text/plain;application/vnd.spotfire.dxp;application/vnd.spotfire.sfs;application/timestamped-data;applicationvnd.trid.tpt;application/vnd.triscape.mxs;text/troff;application/vnd.trueapp;application/x-font-ttf;text/turtle;application/vnd.umajin;application/vnd.uoml+xml;application/vnd.unity;application/vnd.ufdl;text/uri-list;application/nd.uiq.theme;application/x-ustar;text/x-uuencode;text/x-vcalendar;text/x-vcard;application/x-cdlink;application/vnd.vsf;model/vrml;application/vnd.vcx;model/vnd.mts;model/vnd.vtu;application/vnd.visionary;video/vnd.vivo;applicatin/ccxml+xml,;application/voicexml+xml;application/x-wais-source;application/vnd.wap.wbxml;image/vnd.wap.wbmp;audio/x-wav;application/davmount+xml;application/x-font-woff;application/wspolicy+xml;image/webp;application/vnd.webturb;application/widget;application/winhlp;text/vnd.wap.wml;text/vnd.wap.wmlscript;application/vnd.wap.wmlscriptc;application/vnd.wordperfect;application/vnd.wt.stf;application/wsdl+xml;image/x-xbitmap;image/x-xpixmap;image/x-xwindowump;application/x-x509-ca-cert;application/x-xfig;application/xhtml+xml;application/xml;application/xcap-diff+xml;application/xenc+xml;application/patch-ops-error+xml;application/resource-lists+xml;application/rls-services+xml;aplication/resource-lists-diff+xml;application/xslt+xml;application/xop+xml;application/x-xpinstall;application/xspf+xml;application/vnd.mozilla.xul+xml;chemical/x-xyz;text/yaml;application/yang;application/yin+xml;application/vnd.ul;application/zip;application/vnd.handheld-entertainment+xml;application/vnd.zzazz.deck+xml"); - ffOptions.setProfile(ffProfile); } + ffOptions.setCapability(CapabilityType.PLATFORM_NAME, getDesiredOperatingSystem()); + ffOptions.setCapability(CapabilityType.HAS_NATIVE_EVENTS, true); + ffOptions.setCapability(CapabilityType.LOGGING_PREFS, logPrefs); + if (Boolean.TRUE.equals(HEADLESS_EXECUTION)) { + // https://developer.mozilla.org/en-US/docs/Mozilla/Firefox/Headless_mode + ffOptions.addArguments("-headless"); + } + ffOptions.addArguments("-foreground"); + + FirefoxProfile ffProfile = new FirefoxProfile(); + ffProfile.setPreference("browser.download.dir", downloadsFolderPath); + ffProfile.setPreference("browser.download.folderList", 2); + ffProfile.setPreference("browser.helperApps.neverAsk.saveToDisk", + "application/vnd.hzn-3d-crossword;video/3gpp;video/3gpp2;application/vnd.mseq;application/vnd.3m.post-it-notes;application/vnd.3gpp.pic-bw-large;application/vnd.3gpp.pic-bw-small;application/vnd.3gpp.pic-bw-var;application/vnd.3gp2.tcap;application/x-7z-compressed;application/x-abiword;application/x-ace-compressed;application/vnd.americandynamics.acc;application/vnd.acucobol;application/vnd.acucorp;audio/adpcm;application/x-authorware-bin;application/x-athorware-map;application/x-authorware-seg;application/vnd.adobe.air-application-installer-package+zip;application/x-shockwave-flash;application/vnd.adobe.fxp;application/pdf;application/vnd.cups-ppd;application/x-director;applicaion/vnd.adobe.xdp+xml;application/vnd.adobe.xfdf;audio/x-aac;application/vnd.ahead.space;application/vnd.airzip.filesecure.azf;application/vnd.airzip.filesecure.azs;application/vnd.amazon.ebook;application/vnd.amiga.ami;applicatin/andrew-inset;application/vnd.android.package-archive;application/vnd.anser-web-certificate-issue-initiation;application/vnd.anser-web-funds-transfer-initiation;application/vnd.antix.game-component;application/vnd.apple.installe+xml;application/applixware;application/vnd.hhe.lesson-player;application/vnd.aristanetworks.swi;text/x-asm;application/atomcat+xml;application/atomsvc+xml;application/atom+xml;application/pkix-attr-cert;audio/x-aiff;video/x-msvieo;application/vnd.audiograph;image/vnd.dxf;model/vnd.dwf;text/plain-bas;application/x-bcpio;application/octet-stream;image/bmp;application/x-bittorrent;application/vnd.rim.cod;application/vnd.blueice.multipass;application/vnd.bm;application/x-sh;image/prs.btif;application/vnd.businessobjects;application/x-bzip;application/x-bzip2;application/x-csh;text/x-c;application/vnd.chemdraw+xml;text/css;chemical/x-cdx;chemical/x-cml;chemical/x-csml;application/vn.contact.cmsg;application/vnd.claymore;application/vnd.clonk.c4group;image/vnd.dvb.subtitle;application/cdmi-capability;application/cdmi-container;application/cdmi-domain;application/cdmi-object;application/cdmi-queue;applicationvnd.cluetrust.cartomobile-config;application/vnd.cluetrust.cartomobile-config-pkg;image/x-cmu-raster;model/vnd.collada+xml;text/csv;application/mac-compactpro;application/vnd.wap.wmlc;image/cgm;x-conference/x-cooltalk;image/x-cmx;application/vnd.xara;application/vnd.cosmocaller;application/x-cpio;application/vnd.crick.clicker;application/vnd.crick.clicker.keyboard;application/vnd.crick.clicker.palette;application/vnd.crick.clicker.template;application/vn.crick.clicker.wordbank;application/vnd.criticaltools.wbs+xml;application/vnd.rig.cryptonote;chemical/x-cif;chemical/x-cmdf;application/cu-seeme;application/prs.cww;text/vnd.curl;text/vnd.curl.dcurl;text/vnd.curl.mcurl;text/vnd.crl.scurl;application/vnd.curl.car;application/vnd.curl.pcurl;application/vnd.yellowriver-custom-menu;application/dssc+der;application/dssc+xml;application/x-debian-package;audio/vnd.dece.audio;image/vnd.dece.graphic;video/vnd.dec.hd;video/vnd.dece.mobile;video/vnd.uvvu.mp4;video/vnd.dece.pd;video/vnd.dece.sd;video/vnd.dece.video;application/x-dvi;application/vnd.fdsn.seed;application/x-dtbook+xml;application/x-dtbresource+xml;application/vnd.dvb.ait;applcation/vnd.dvb.service;audio/vnd.digital-winds;image/vnd.djvu;application/xml-dtd;application/vnd.dolby.mlp;application/x-doom;application/vnd.dpgraph;audio/vnd.dra;application/vnd.dreamfactory;audio/vnd.dts;audio/vnd.dts.hd;imag/vnd.dwg;application/vnd.dynageo;application/ecmascript;application/vnd.ecowin.chart;image/vnd.fujixerox.edmics-mmr;image/vnd.fujixerox.edmics-rlc;application/exi;application/vnd.proteus.magazine;application/epub+zip;message/rfc82;application/vnd.enliven;application/vnd.is-xpr;image/vnd.xiff;application/vnd.xfdl;application/emma+xml;application/vnd.ezpix-album;application/vnd.ezpix-package;image/vnd.fst;video/vnd.fvt;image/vnd.fastbidsheet;application/vn.denovo.fcselayout-link;video/x-f4v;video/x-flv;image/vnd.fpx;image/vnd.net-fpx;text/vnd.fmi.flexstor;video/x-fli;application/vnd.fluxtime.clip;application/vnd.fdf;text/x-fortran;application/vnd.mif;application/vnd.framemaker;imae/x-freehand;application/vnd.fsc.weblaunch;application/vnd.frogans.fnc;application/vnd.frogans.ltf;application/vnd.fujixerox.ddd;application/vnd.fujixerox.docuworks;application/vnd.fujixerox.docuworks.binder;application/vnd.fujitu.oasys;application/vnd.fujitsu.oasys2;application/vnd.fujitsu.oasys3;application/vnd.fujitsu.oasysgp;application/vnd.fujitsu.oasysprs;application/x-futuresplash;application/vnd.fuzzysheet;image/g3fax;application/vnd.gmx;model/vn.gtw;application/vnd.genomatix.tuxedo;application/vnd.geogebra.file;application/vnd.geogebra.tool;model/vnd.gdl;application/vnd.geometry-explorer;application/vnd.geonext;application/vnd.geoplan;application/vnd.geospace;applicatio/x-font-ghostscript;application/x-font-bdf;application/x-gtar;application/x-texinfo;application/x-gnumeric;application/vnd.google-earth.kml+xml;application/vnd.google-earth.kmz;application/vnd.grafeq;image/gif;text/vnd.graphviz;aplication/vnd.groove-account;application/vnd.groove-help;application/vnd.groove-identity-message;application/vnd.groove-injector;application/vnd.groove-tool-message;application/vnd.groove-tool-template;application/vnd.groove-vcar;video/h261;video/h263;video/h264;application/vnd.hp-hpid;application/vnd.hp-hps;application/x-hdf;audio/vnd.rip;application/vnd.hbci;application/vnd.hp-jlyt;application/vnd.hp-pcl;application/vnd.hp-hpgl;application/vnd.yamaha.h-script;application/vnd.yamaha.hv-dic;application/vnd.yamaha.hv-voice;application/vnd.hydrostatix.sof-data;application/hyperstudio;application/vnd.hal+xml;text/html;application/vnd.ibm.rights-management;application/vnd.ibm.securecontainer;text/calendar;application/vnd.iccprofile;image/x-icon;application/vnd.igloader;image/ief;application/vnd.immervision-ivp;application/vnd.immervision-ivu;application/reginfo+xml;text/vnd.in3d.3dml;text/vnd.in3d.spot;mode/iges;application/vnd.intergeo;application/vnd.cinderella;application/vnd.intercon.formnet;application/vnd.isac.fcs;application/ipfix;application/pkix-cert;application/pkixcmp;application/pkix-crl;application/pkix-pkipath;applicaion/vnd.insors.igm;application/vnd.ipunplugged.rcprofile;application/vnd.irepository.package+xml;text/vnd.sun.j2me.app-descriptor;application/java-archive;application/java-vm;application/x-java-jnlp-file;application/java-serializd-object;text/x-java-source,java;application/javascript;application/json;application/vnd.joost.joda-archive;video/jpm;image/jpeg;video/jpeg;application/vnd.kahootz;application/vnd.chipnuts.karaoke-mmd;application/vnd.kde.karbon;aplication/vnd.kde.kchart;application/vnd.kde.kformula;application/vnd.kde.kivio;application/vnd.kde.kontour;application/vnd.kde.kpresenter;application/vnd.kde.kspread;application/vnd.kde.kword;application/vnd.kenameaapp;applicatin/vnd.kidspiration;application/vnd.kinar;application/vnd.kodak-descriptor;application/vnd.las.las+xml;application/x-latex;application/vnd.llamagraphics.life-balance.desktop;application/vnd.llamagraphics.life-balance.exchange+xml;application/vnd.jam;application/vnd.lotus-1-2-3;application/vnd.lotus-approach;application/vnd.lotus-freelance;application/vnd.lotus-notes;application/vnd.lotus-organizer;application/vnd.lotus-screencam;application/vnd.lotus-wordro;audio/vnd.lucent.voice;audio/x-mpegurl;video/x-m4v;application/mac-binhex40;application/vnd.macports.portpkg;application/vnd.osgeo.mapguide.package;application/marc;application/marcxml+xml;application/mxf;application/vnd.wolfrm.player;application/mathematica;application/mathml+xml;application/mbox;application/vnd.medcalcdata;application/mediaservercontrol+xml;application/vnd.mediastation.cdkey;application/vnd.mfer;application/vnd.mfmp;model/mesh;appliation/mads+xml;application/mets+xml;application/mods+xml;application/metalink4+xml;application/vnd.ms-powerpoint.template.macroenabled.12;application/vnd.ms-word.document.macroenabled.12;application/vnd.ms-word.template.macroenabed.12;application/vnd.mcd;application/vnd.micrografx.flo;application/vnd.micrografx.igx;application/vnd.eszigno3+xml;application/x-msaccess;video/x-ms-asf;application/x-msdownload;application/vnd.ms-artgalry;application/vnd.ms-ca-compressed;application/vnd.ms-ims;application/x-ms-application;application/x-msclip;image/vnd.ms-modi;application/vnd.ms-fontobject;application/vnd.ms-excel;application/vnd.ms-excel.addin.macroenabled.12;application/vnd.ms-excelsheet.binary.macroenabled.12;application/vnd.ms-excel.template.macroenabled.12;application/vnd.ms-excel.sheet.macroenabled.12;application/vnd.ms-htmlhelp;application/x-mscardfile;application/vnd.ms-lrm;application/x-msmediaview;aplication/x-msmoney;application/vnd.openxmlformats-officedocument.presentationml.presentation;application/vnd.openxmlformats-officedocument.presentationml.slide;application/vnd.openxmlformats-officedocument.presentationml.slideshw;application/vnd.openxmlformats-officedocument.presentationml.template;application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;application/vnd.openxmlformats-officedocument.spreadsheetml.template;application/vnd.openxmformats-officedocument.wordprocessingml.document;application/vnd.openxmlformats-officedocument.wordprocessingml.template;application/x-msbinder;application/vnd.ms-officetheme;application/onenote;audio/vnd.ms-playready.media.pya;vdeo/vnd.ms-playready.media.pyv;application/vnd.ms-powerpoint;application/vnd.ms-powerpoint.addin.macroenabled.12;application/vnd.ms-powerpoint.slide.macroenabled.12;application/vnd.ms-powerpoint.presentation.macroenabled.12;appliation/vnd.ms-powerpoint.slideshow.macroenabled.12;application/vnd.ms-project;application/x-mspublisher;application/x-msschedule;application/x-silverlight-app;application/vnd.ms-pki.stl;application/vnd.ms-pki.seccat;application/vn.visio;video/x-ms-wm;audio/x-ms-wma;audio/x-ms-wax;video/x-ms-wmx;application/x-ms-wmd;application/vnd.ms-wpl;application/x-ms-wmz;video/x-ms-wmv;video/x-ms-wvx;application/x-msmetafile;application/x-msterminal;application/msword;application/x-mswrite;application/vnd.ms-works;application/x-ms-xbap;application/vnd.ms-xpsdocument;audio/midi;application/vnd.ibm.minipay;application/vnd.ibm.modcap;application/vnd.jcp.javame.midlet-rms;application/vnd.tmobile-ivetv;application/x-mobipocket-ebook;application/vnd.mobius.mbk;application/vnd.mobius.dis;application/vnd.mobius.plc;application/vnd.mobius.mqy;application/vnd.mobius.msl;application/vnd.mobius.txf;application/vnd.mobius.daf;tex/vnd.fly;application/vnd.mophun.certificate;application/vnd.mophun.application;video/mj2;audio/mpeg;video/vnd.mpegurl;video/mpeg;application/mp21;audio/mp4;video/mp4;application/mp4;application/vnd.apple.mpegurl;application/vnd.msician;application/vnd.muvee.style;application/xv+xml;application/vnd.nokia.n-gage.data;application/vnd.nokia.n-gage.symbian.install;application/x-dtbncx+xml;application/x-netcdf;application/vnd.neurolanguage.nlu;application/vnd.na;application/vnd.noblenet-directory;application/vnd.noblenet-sealer;application/vnd.noblenet-web;application/vnd.nokia.radio-preset;application/vnd.nokia.radio-presets;text/n3;application/vnd.novadigm.edm;application/vnd.novadim.edx;application/vnd.novadigm.ext;application/vnd.flographit;audio/vnd.nuera.ecelp4800;audio/vnd.nuera.ecelp7470;audio/vnd.nuera.ecelp9600;application/oda;application/ogg;audio/ogg;video/ogg;application/vnd.oma.dd2+xml;applicatin/vnd.oasis.opendocument.text-web;application/oebps-package+xml;application/vnd.intu.qbo;application/vnd.openofficeorg.extension;application/vnd.yamaha.openscoreformat;audio/webm;video/webm;application/vnd.oasis.opendocument.char;application/vnd.oasis.opendocument.chart-template;application/vnd.oasis.opendocument.database;application/vnd.oasis.opendocument.formula;application/vnd.oasis.opendocument.formula-template;application/vnd.oasis.opendocument.grapics;application/vnd.oasis.opendocument.graphics-template;application/vnd.oasis.opendocument.image;application/vnd.oasis.opendocument.image-template;application/vnd.oasis.opendocument.presentation;application/vnd.oasis.opendocumen.presentation-template;application/vnd.oasis.opendocument.spreadsheet;application/vnd.oasis.opendocument.spreadsheet-template;application/vnd.oasis.opendocument.text;application/vnd.oasis.opendocument.text-master;application/vnd.asis.opendocument.text-template;image/ktx;application/vnd.sun.xml.calc;application/vnd.sun.xml.calc.template;application/vnd.sun.xml.draw;application/vnd.sun.xml.draw.template;application/vnd.sun.xml.impress;application/vnd.sun.xl.impress.template;application/vnd.sun.xml.math;application/vnd.sun.xml.writer;application/vnd.sun.xml.writer.global;application/vnd.sun.xml.writer.template;application/x-font-otf;application/vnd.yamaha.openscoreformat.osfpvg+xml;application/vnd.osgi.dp;application/vnd.palm;text/x-pascal;application/vnd.pawaafile;application/vnd.hp-pclxl;application/vnd.picsel;image/x-pcx;image/vnd.adobe.photoshop;application/pics-rules;image/x-pict;application/x-chat;aplication/pkcs10;application/x-pkcs12;application/pkcs7-mime;application/pkcs7-signature;application/x-pkcs7-certreqresp;application/x-pkcs7-certificates;application/pkcs8;application/vnd.pocketlearn;image/x-portable-anymap;image/-portable-bitmap;application/x-font-pcf;application/font-tdpfr;application/x-chess-pgn;image/x-portable-graymap;image/png;image/x-portable-pixmap;application/pskc+xml;application/vnd.ctc-posml;application/postscript;application/xfont-type1;application/vnd.powerbuilder6;application/pgp-encrypted;application/pgp-signature;application/vnd.previewsystems.box;application/vnd.pvi.ptid1;application/pls+xml;application/vnd.pg.format;application/vnd.pg.osasli;tex/prs.lines.tag;application/x-font-linux-psf;application/vnd.publishare-delta-tree;application/vnd.pmi.widget;application/vnd.quark.quarkxpress;application/vnd.epson.esf;application/vnd.epson.msf;application/vnd.epson.ssf;applicaton/vnd.epson.quickanime;application/vnd.intu.qfx;video/quicktime;application/x-rar-compressed;audio/x-pn-realaudio;audio/x-pn-realaudio-plugin;application/rsd+xml;application/vnd.rn-realmedia;application/vnd.realvnc.bed;applicatin/vnd.recordare.musicxml;application/vnd.recordare.musicxml+xml;application/relax-ng-compact-syntax;application/vnd.data-vision.rdz;application/rdf+xml;application/vnd.cloanto.rp9;application/vnd.jisp;application/rtf;text/richtex;application/vnd.route66.link66+xml;application/rss+xml;application/shf+xml;application/vnd.sailingtracker.track;image/svg+xml;application/vnd.sus-calendar;application/sru+xml;application/set-payment-initiation;application/set-reistration-initiation;application/vnd.sema;application/vnd.semd;application/vnd.semf;application/vnd.seemail;application/x-font-snf;application/scvp-vp-request;application/scvp-vp-response;application/scvp-cv-request;application/svp-cv-response;application/sdp;text/x-setext;video/x-sgi-movie;application/vnd.shana.informed.formdata;application/vnd.shana.informed.formtemplate;application/vnd.shana.informed.interchange;application/vnd.shana.informed.package;application/thraud+xml;application/x-shar;image/x-rgb;application/vnd.epson.salt;application/vnd.accpac.simply.aso;application/vnd.accpac.simply.imp;application/vnd.simtech-mindmapper;application/vnd.commonspace;application/vnd.ymaha.smaf-audio;application/vnd.smaf;application/vnd.yamaha.smaf-phrase;application/vnd.smart.teacher;application/vnd.svd;application/sparql-query;application/sparql-results+xml;application/srgs;application/srgs+xml;application/sml+xml;application/vnd.koan;text/sgml;application/vnd.stardivision.calc;application/vnd.stardivision.draw;application/vnd.stardivision.impress;application/vnd.stardivision.math;application/vnd.stardivision.writer;application/vnd.tardivision.writer-global;application/vnd.stepmania.stepchart;application/x-stuffit;application/x-stuffitx;application/vnd.solent.sdkm+xml;application/vnd.olpc-sugar;audio/basic;application/vnd.wqd;application/vnd.symbian.install;application/smil+xml;application/vnd.syncml+xml;application/vnd.syncml.dm+wbxml;application/vnd.syncml.dm+xml;application/x-sv4cpio;application/x-sv4crc;application/sbml+xml;text/tab-separated-values;image/tiff;application/vnd.to.intent-module-archive;application/x-tar;application/x-tcl;application/x-tex;application/x-tex-tfm;application/tei+xml;text/plain;application/vnd.spotfire.dxp;application/vnd.spotfire.sfs;application/timestamped-data;applicationvnd.trid.tpt;application/vnd.triscape.mxs;text/troff;application/vnd.trueapp;application/x-font-ttf;text/turtle;application/vnd.umajin;application/vnd.uoml+xml;application/vnd.unity;application/vnd.ufdl;text/uri-list;application/nd.uiq.theme;application/x-ustar;text/x-uuencode;text/x-vcalendar;text/x-vcard;application/x-cdlink;application/vnd.vsf;model/vrml;application/vnd.vcx;model/vnd.mts;model/vnd.vtu;application/vnd.visionary;video/vnd.vivo;applicatin/ccxml+xml,;application/voicexml+xml;application/x-wais-source;application/vnd.wap.wbxml;image/vnd.wap.wbmp;audio/x-wav;application/davmount+xml;application/x-font-woff;application/wspolicy+xml;image/webp;application/vnd.webturb;application/widget;application/winhlp;text/vnd.wap.wml;text/vnd.wap.wmlscript;application/vnd.wap.wmlscriptc;application/vnd.wordperfect;application/vnd.wt.stf;application/wsdl+xml;image/x-xbitmap;image/x-xpixmap;image/x-xwindowump;application/x-x509-ca-cert;application/x-xfig;application/xhtml+xml;application/xml;application/xcap-diff+xml;application/xenc+xml;application/patch-ops-error+xml;application/resource-lists+xml;application/rls-services+xml;aplication/resource-lists-diff+xml;application/xslt+xml;application/xop+xml;application/x-xpinstall;application/xspf+xml;application/vnd.mozilla.xul+xml;chemical/x-xyz;text/yaml;application/yang;application/yin+xml;application/vnd.ul;application/zip;application/vnd.handheld-entertainment+xml;application/vnd.zzazz.deck+xml"); + ffOptions.setProfile(ffProfile); break; case MICROSOFT_IE: + ieOptions = new InternetExplorerOptions(); if (customBrowserOptions != null) { ieOptions = (InternetExplorerOptions) customBrowserOptions; - } else { - ieOptions = new InternetExplorerOptions(); - ieOptions.setCapability(CapabilityType.PLATFORM_NAME, getDesiredOperatingSystem()); - ieOptions.setCapability(CapabilityType.LOGGING_PREFS, logPrefs); } + ieOptions.setCapability(CapabilityType.PLATFORM_NAME, getDesiredOperatingSystem()); + ieOptions.setCapability(CapabilityType.LOGGING_PREFS, logPrefs); break; case MOBILE_CHROME: case GOOGLE_CHROME: + chOptions = new ChromeOptions(); if (customBrowserOptions != null) { chOptions = (ChromeOptions) customBrowserOptions; - } else { - chOptions = new ChromeOptions(); - chOptions.setCapability(CapabilityType.PLATFORM_NAME, getDesiredOperatingSystem()); - chOptions.setHeadless(HEADLESS_EXECUTION); - if (Boolean.TRUE.equals(HEADLESS_EXECUTION)) { - // https://developers.google.com/web/updates/2017/04/headless-chrome - chOptions.addArguments("--headless"); // only if you are ACTUALLY running headless - } - if (Boolean.TRUE.equals(AUTO_MAXIMIZE) && !isMobileWebExecution() && !OperatingSystemType.MACOS.equals(getOperatingSystemFromName(targetOperatingSystem))) { - chOptions.addArguments("--start-maximized"); - } - chOptions.setCapability(CapabilityType.LOGGING_PREFS, logPrefs); + } + chOptions.setCapability(CapabilityType.PLATFORM_NAME, getDesiredOperatingSystem()); + chOptions.setHeadless(HEADLESS_EXECUTION); + if (Boolean.TRUE.equals(HEADLESS_EXECUTION)) { + // https://developers.google.com/web/updates/2017/04/headless-chrome + chOptions.addArguments("--headless"); // only if you are ACTUALLY running headless + } + if (Boolean.TRUE.equals(AUTO_MAXIMIZE) && !isMobileWebExecution() && !OperatingSystemType.MACOS.equals(getOperatingSystemFromName(targetOperatingSystem))) { + chOptions.addArguments("--start-maximized"); + } + chOptions.setCapability(CapabilityType.LOGGING_PREFS, logPrefs); - chOptions.setPageLoadStrategy(PageLoadStrategy.NORMAL); // https://www.skptricks.com/2018/08/timed-out-receiving-message-from-renderer-selenium.html + chOptions.setPageLoadStrategy(PageLoadStrategy.NORMAL); // https://www.skptricks.com/2018/08/timed-out-receiving-message-from-renderer-selenium.html // chOptions.addArguments("enable-automation"); // https://stackoverflow.com/a/43840128/1689770 - chOptions.addArguments("--enable-automation"); // https://stackoverflow.com/a/43840128/1689770 - chOptions.addArguments("--no-sandbox"); //https://stackoverflow.com/a/50725918/1689770 - chOptions.addArguments("--disable-infobars"); //https://stackoverflow.com/a/43840128/1689770 - chOptions.addArguments("--disable-dev-shm-usage"); //https://stackoverflow.com/a/50725918/1689770 - chOptions.addArguments("--disable-browser-side-navigation"); //https://stackoverflow.com/a/49123152/1689770 - chOptions.addArguments("--disable-gpu"); //https://stackoverflow.com/questions/51959986/how-to-solve-selenium-chromedriver-timed-out-receiving-message-from-renderer-exc - - //chOptions.setExperimentalOption("excludeSwitches", new String[]{"enable-automation"}); - //https://github.com/GoogleChrome/chrome-launcher/blob/master/docs/chrome-flags-for-tools.md#--enable-automation - - Map chromePreferences = new HashMap<>(); - chromePreferences.put("profile.default_content_settings.popups", 0); - chromePreferences.put("download.prompt_for_download", "false"); - chromePreferences.put("download.default_directory", downloadsFolderPath); - chOptions.setExperimentalOption("prefs", chromePreferences); - chOptions.setExperimentalOption("w3c", false); - } + chOptions.addArguments("--enable-automation"); // https://stackoverflow.com/a/43840128/1689770 + chOptions.addArguments("--no-sandbox"); //https://stackoverflow.com/a/50725918/1689770 + chOptions.addArguments("--disable-infobars"); //https://stackoverflow.com/a/43840128/1689770 + chOptions.addArguments("--disable-dev-shm-usage"); //https://stackoverflow.com/a/50725918/1689770 + chOptions.addArguments("--disable-browser-side-navigation"); //https://stackoverflow.com/a/49123152/1689770 + chOptions.addArguments("--disable-gpu"); //https://stackoverflow.com/questions/51959986/how-to-solve-selenium-chromedriver-timed-out-receiving-message-from-renderer-exc + + //chOptions.setExperimentalOption("excludeSwitches", new String[]{"enable-automation"}); + //https://github.com/GoogleChrome/chrome-launcher/blob/master/docs/chrome-flags-for-tools.md#--enable-automation + + Map chromePreferences = new HashMap<>(); + chromePreferences.put("profile.default_content_settings.popups", 0); + chromePreferences.put("download.prompt_for_download", "false"); + chromePreferences.put("download.default_directory", downloadsFolderPath); + chOptions.setExperimentalOption("prefs", chromePreferences); + chOptions.setExperimentalOption("w3c", false); break; case MICROSOFT_EDGE: + edOptions = new EdgeOptions(); if (customBrowserOptions != null) { edOptions = (EdgeOptions) customBrowserOptions; - } else { - edOptions = new EdgeOptions(); - edOptions.setCapability(CapabilityType.PLATFORM_NAME, getDesiredOperatingSystem()); - edOptions.setCapability(CapabilityType.LOGGING_PREFS, logPrefs); } + edOptions.setCapability(CapabilityType.PLATFORM_NAME, getDesiredOperatingSystem()); + edOptions.setCapability(CapabilityType.LOGGING_PREFS, logPrefs); break; case APPLE_SAFARI: + sfOptions = new SafariOptions(); if (customBrowserOptions != null) { sfOptions = (SafariOptions) customBrowserOptions; - } else { - sfOptions = new SafariOptions(); - sfOptions.setCapability(CapabilityType.PLATFORM_NAME, getDesiredOperatingSystem()); - sfOptions.setCapability(CapabilityType.LOGGING_PREFS, logPrefs); - sfOptions.setCapability("safari.options.dataDir", downloadsFolderPath); } + sfOptions.setCapability(CapabilityType.PLATFORM_NAME, getDesiredOperatingSystem()); + sfOptions.setCapability(CapabilityType.LOGGING_PREFS, logPrefs); + sfOptions.setCapability("safari.options.dataDir", downloadsFolderPath); break; default: failAction("Unsupported Browser Type [" + browserName + "]."); diff --git a/src/main/java/com/shaft/gui/element/ElementActions.java b/src/main/java/com/shaft/gui/element/ElementActions.java index d11f758501f..0f07c49e66f 100755 --- a/src/main/java/com/shaft/gui/element/ElementActions.java +++ b/src/main/java/com/shaft/gui/element/ElementActions.java @@ -555,7 +555,7 @@ public static List getContextHandles(WebDriver driver) { * desired elementLocator */ public static int getElementsCount(WebDriver driver, By elementLocator) { - return getMatchingElementsCount(driver, elementLocator, ATTEMPTS_BEFORE_THROWING_ELEMENT_NOT_FOUND_EXCEPTION); + return getMatchingElementsCount(driver, elementLocator, ElementActions.ATTEMPTS_BEFORE_THROWING_ELEMENT_NOT_FOUND_EXCEPTION, FORCE_CHECK_FOR_ELEMENT_VISIBILITY); } /** @@ -571,26 +571,7 @@ public static int getElementsCount(WebDriver driver, By elementLocator) { * desired elementLocator */ public static int getElementsCount(WebDriver driver, By elementLocator, int numberOfAttempts) { - return getMatchingElementsCount(driver, elementLocator, numberOfAttempts); - } - - /** - * Returns the number of elements that match a certain elementLocator - * - * @param driver the current instance of Selenium webdriver - * @param elementLocator the locator of the webElement under test (By xpath, - * id, selector, name ...etc) - * @param numberOfAttempts the number of retries before returning a count - * [returns zero if no elements were found after all - * the retries] - * @param waitForLazyLoading if true, will wait before lazy loading, else if - * false skips this wait - * @return integer value that represents the number of elements that match the - * desired elementLocator - */ - public static int getElementsCount(WebDriver driver, By elementLocator, int numberOfAttempts, - boolean waitForLazyLoading) { - return getMatchingElementsCount(driver, elementLocator, numberOfAttempts, waitForLazyLoading); + return getMatchingElementsCount(driver, elementLocator, numberOfAttempts, FORCE_CHECK_FOR_ELEMENT_VISIBILITY); } /** @@ -1299,7 +1280,7 @@ public static void waitForElementToBePresent(WebDriver driver, By elementLocator boolean isElementFound; int i = 1; do { - foundElementsCount = getMatchingElementsCount(driver, internalElementLocator, 1); + foundElementsCount = getMatchingElementsCount(driver, internalElementLocator, 1, FORCE_CHECK_FOR_ELEMENT_VISIBILITY); isElementFound = foundElementsCount >= 1; i++; } while (i < numberOfTries && Boolean.compare(stateOfPresence, isElementFound) != 0); @@ -1437,20 +1418,6 @@ protected static By updateLocatorWithAIGeneratedOne(By elementLocator) { return elementLocator; } - private static void checkForElementVisibility(WebDriver driver, By elementLocator) { - if (FORCE_CHECK_FOR_ELEMENT_VISIBILITY) { - try { - (new WebDriverWait(driver, DEFAULT_ELEMENT_IDENTIFICATION_TIMEOUT_INTEGER)) - .until(ExpectedConditions.visibilityOfElementLocated(elementLocator)); -// new WebDriverWait(driver, DEFAULT_ELEMENT_IDENTIFICATION_TIMEOUT).until(waitDriver -> ExpectedConditions.visibilityOfElementLocated(elementLocator)); - } catch (TimeoutException rootCauseException) { - ReportManager.log(rootCauseException); - failAction(driver, "unique element matching this locator \"" + elementLocator + "\" is not visible.", - null, rootCauseException); - } - } - } - private static void clearBeforeTyping(WebDriver driver, By elementLocator, TextDetectionStrategy successfulTextLocationStrategy) { try { @@ -1545,49 +1512,49 @@ private static void failAction(WebDriver driver, String actionName, String testD } } - private static int getMatchingElementsCount(WebDriver driver, By elementLocator, int numberOfAttempts) { - return getMatchingElementsCount(driver, elementLocator, numberOfAttempts, true); + private static int getMatchingElementsCount(WebDriver driver, By elementLocator, int numberOfAttempts, boolean checkForVisibility) { + if (elementLocator == null) { + return 0; + } + JavaScriptWaitManager.waitForLazyLoading(); + RecordManager.startVideoRecording(driver); + + if (elementLocator.equals(By.tagName("html")) || Boolean.FALSE.equals(ScreenshotManager.getAiSupportedElementIdentification())) { + return waitForElementPresence(driver, elementLocator, numberOfAttempts, checkForVisibility); + } + + // not null AND not html AND ai self healing is enabled + return getMatchingElementsCountAI(driver, elementLocator, numberOfAttempts); } - private static int getMatchingElementsCount(WebDriver driver, By elementLocator, int numberOfAttempts, - boolean waitForLazyLoading) { + private static int getMatchingElementsCountAI(WebDriver driver, By elementLocator, int numberOfAttempts) { By internalElementLocator = elementLocator; - RecordManager.startVideoRecording(driver); - if (waitForLazyLoading) { - JavaScriptWaitManager.waitForLazyLoading(); - } - - int matchingElementsCount = 0; - if (internalElementLocator != null && internalElementLocator.equals(By.tagName("html"))) { - matchingElementsCount = waitForElementPresence(driver, internalElementLocator, numberOfAttempts); - } else if (internalElementLocator != null) { - // check to see if this element was already identified using AI, and if it's - // still unique, use that locator directly - String hashedLocatorName = ImageProcessingActions.formatElementLocatorToImagePath(internalElementLocator); - String previouslyIdentifiedXpath = System.getProperty(hashedLocatorName); - setAiGeneratedXpath(previouslyIdentifiedXpath); - - // wait for element presence - if (previouslyIdentifiedXpath != null && Boolean.TRUE.equals(ScreenshotManager.getAiSupportedElementIdentification())) { + // check to see if this element was already identified using AI, and if it's + // still unique, use that locator directly + String hashedLocatorName = ImageProcessingActions.formatElementLocatorToImagePath(internalElementLocator); + String previouslyIdentifiedXpath = System.getProperty(hashedLocatorName); + setAiGeneratedXpath(previouslyIdentifiedXpath); + + // wait for element presence + if (previouslyIdentifiedXpath != null && Boolean.TRUE.equals(ScreenshotManager.getAiSupportedElementIdentification())) { + internalElementLocator = aiGeneratedElementLocator; + } + int matchingElementsCount = waitForElementPresence(driver, internalElementLocator, numberOfAttempts, true); + + if (matchingElementsCount == 0 + && Boolean.TRUE.equals(attemptToFindElementUsingAI(driver, internalElementLocator))) { + matchingElementsCount = 1; + } else if (matchingElementsCount == 1) { + if (previouslyIdentifiedXpath != null) { + boolean initialLoggingState = ReportManager.isDiscreteLogging(); + ReportManager.setDiscreteLogging(false); + ReportManager + .log("Element was previously found using AI... Kindly update your element locator from [" + + internalElementLocator + "] to [" + aiGeneratedElementLocator + "]."); + ReportManager.setDiscreteLogging(initialLoggingState); internalElementLocator = aiGeneratedElementLocator; } - matchingElementsCount = waitForElementPresence(driver, internalElementLocator, numberOfAttempts); - - if (matchingElementsCount == 0 - && Boolean.TRUE.equals(attemptToFindElementUsingAI(driver, internalElementLocator))) { - matchingElementsCount = 1; - } else if (matchingElementsCount == 1) { - if (previouslyIdentifiedXpath != null) { - boolean initialLoggingState = ReportManager.isDiscreteLogging(); - ReportManager.setDiscreteLogging(false); - ReportManager - .log("Element was previously found using AI... Kindly update your element locator from [" - + internalElementLocator + "] to [" + aiGeneratedElementLocator + "]."); - ReportManager.setDiscreteLogging(initialLoggingState); - internalElementLocator = aiGeneratedElementLocator; - } - ScreenshotManager.storeElementScreenshotForAISupportedElementIdentification(driver, internalElementLocator); - } + ScreenshotManager.storeElementScreenshotForAISupportedElementIdentification(driver, internalElementLocator); } return matchingElementsCount; } @@ -1598,7 +1565,7 @@ private static boolean identifyUniqueElement(WebDriver driver, By elementLocator // Override current locator with the aiGeneratedElementLocator internalElementLocator = updateLocatorWithAIGeneratedOne(internalElementLocator); - int matchingElementsCount = getMatchingElementsCount(driver, internalElementLocator, ElementActions.ATTEMPTS_BEFORE_THROWING_ELEMENT_NOT_FOUND_EXCEPTION); + int matchingElementsCount = getMatchingElementsCount(driver, elementLocator, ElementActions.ATTEMPTS_BEFORE_THROWING_ELEMENT_NOT_FOUND_EXCEPTION, checkForVisibility); if (internalElementLocator != null) { // unique element found switch (matchingElementsCount) { @@ -1616,9 +1583,6 @@ private static boolean identifyUniqueElement(WebDriver driver, By elementLocator // } //ReportManager.logDiscrete(getElementLocationOnceScrolledIntoView); } - - // check for visibility - checkForElementVisibility(driver, internalElementLocator); } return true; } @@ -1947,14 +1911,26 @@ private static String typeWrapper(WebDriver driver, By elementLocator, String ta } } - private static int waitForElementPresence(WebDriver driver, By elementLocator, int numberOfAttempts) { + private static int waitForElementPresence(WebDriver driver, By elementLocator, int numberOfAttempts, boolean checkForVisibility) { + ArrayList> expectedExceptions = new ArrayList<>(); + expectedExceptions.add(NoSuchElementException.class); + expectedExceptions.add(StaleElementReferenceException.class); + if (checkForVisibility) expectedExceptions.add(ElementNotVisibleException.class); + try { - new FluentWait<>(driver) + int elementsCount = new FluentWait<>(driver) .withTimeout(Duration.ofSeconds( (long) DEFAULT_ELEMENT_IDENTIFICATION_TIMEOUT_INTEGER * numberOfAttempts)) .pollingEvery(Duration.ofSeconds(ELEMENT_IDENTIFICATION_POLLING_DELAY)) - .ignoring(NoSuchElementException.class).until(nestedDriver -> driver.findElement(elementLocator)); - return driver.findElements(elementLocator).size(); + .ignoreAll(expectedExceptions) + .until(nestedDriver -> { + nestedDriver.findElement(elementLocator); + return nestedDriver.findElements(elementLocator).size(); + }); + if (elementsCount == 1 && checkForVisibility) { + new WebDriverWait(driver, (long) DEFAULT_ELEMENT_IDENTIFICATION_TIMEOUT_INTEGER * numberOfAttempts).until(ExpectedConditions.visibilityOf(driver.findElement(elementLocator))); + } + return elementsCount; } catch (TimeoutException e) { // In case the element was not found and the timeout expired ReportManager.logDiscrete(e); diff --git a/src/main/java/com/shaft/tools/io/JSONFileManager.java b/src/main/java/com/shaft/tools/io/JSONFileManager.java index 62aa6a39d4f..d17f7a74d4d 100644 --- a/src/main/java/com/shaft/tools/io/JSONFileManager.java +++ b/src/main/java/com/shaft/tools/io/JSONFileManager.java @@ -24,13 +24,7 @@ public class JSONFileManager { */ public JSONFileManager(String jsonFilePath) { this.jsonFilePath = jsonFilePath; - try { - this.reader = new FileReader(jsonFilePath); - } catch (FileNotFoundException rootCauseException) { - ReportManager.log(rootCauseException); - ReportManager.log("Couldn't find the desired file. [" + jsonFilePath + "]."); - Assert.fail("Couldn't find the desired file. [" + jsonFilePath + "]."); - } + initializeReader(); List> attachments = new ArrayList<>(); List testDataFileAttachment = null; try { @@ -112,6 +106,7 @@ public Map getTestDataAsMap(String jsonPath) { */ private Object getTestData(String jsonPath, DataType dataType) { Object testData = null; + initializeReader(); try { switch (dataType) { case STRING -> testData = JsonPath.from(this.reader).getString(jsonPath); @@ -129,6 +124,23 @@ private Object getTestData(String jsonPath, DataType dataType) { } return testData; } + + /** + * initializes the json reader using the target json file path + * + * @return the current value of the reader that had been initialized + */ + private FileReader initializeReader() { + this.reader = null; + try { + reader = new FileReader(jsonFilePath); + } catch (FileNotFoundException rootCauseException) { + ReportManager.log(rootCauseException); + ReportManager.log("Couldn't find the desired file. [" + jsonFilePath + "]."); + Assert.fail("Couldn't find the desired file. [" + jsonFilePath + "]."); + } + return reader; + } public enum DataType { STRING, LIST, MAP diff --git a/src/main/java/com/shaft/tools/io/LogsReporter.java b/src/main/java/com/shaft/tools/io/LogsReporter.java index 04c384d5e1e..e286913408a 100755 --- a/src/main/java/com/shaft/tools/io/LogsReporter.java +++ b/src/main/java/com/shaft/tools/io/LogsReporter.java @@ -15,6 +15,10 @@ public void closureActivities() { attachBrowserLogs(); attachFullLogs(); attachCucumberReport(); + attachExtentReport(); + ReportManager.setDiscreteLogging(true); + ReportManager.generateAllureReportArchive(); + ReportManager.openAllureReportAfterExecution(); } public void attachFullLogs() { @@ -37,6 +41,13 @@ private void attachCucumberReport() { } } + private void attachExtentReport() { + ReportManager.extentReportsFlush(); + if (FileActions.doesFileExist(ReportManager.getExtentReportFileName())) { + ReportManager.attach("HTML", "Extent Emailable Execution Report", FileActions.readFromFile(ReportManager.getExtentReportFileName())); + } + } + private void initializeClosureActivities() { ReportManager.logClosureActivitiesInitialization(); } diff --git a/src/main/java/com/shaft/tools/io/PropertyFileManager.java b/src/main/java/com/shaft/tools/io/PropertyFileManager.java index 4e3aedfbfc2..9781ae2bc72 100644 --- a/src/main/java/com/shaft/tools/io/PropertyFileManager.java +++ b/src/main/java/com/shaft/tools/io/PropertyFileManager.java @@ -53,7 +53,6 @@ public static synchronized void readPropertyFiles() { readPropertyFiles(getDefaultPropertiesFolderPath()); overrideTargetOperatingSystemForLocalExecution(); - manageMaximumPerformanceMode(); readPropertyFiles = false; } @@ -121,7 +120,7 @@ public static String getDefaultPropertiesFolderPath() { * overridden: *

*

    - *
  • aiPoweredElementIdentification=>false; + *
  • aiPoweredSelfHealingElementIdentification=>false; *
  • headlessExecution=>true; *
  • autoMaximizeBrowserWindow=>false; *
  • forceCheckForElementVisibility=>false; @@ -129,30 +128,34 @@ public static String getDefaultPropertiesFolderPath() { *
  • screenshotParams_whenToTakeAScreenshot=>FailuresOnly; *
  • screenshotParams_highlightElements=>false; *
  • screenshotParams_screenshotType=>Regular; - *
  • screenshotParams_watermark=>false; + *
  • screenshotParams_watermark=>true; *
  • createAnimatedGif=>false; *
  • recordVideo=>false; *
  • debugMode"=>"false; *
*/ private static void manageMaximumPerformanceMode() { - if (Boolean.TRUE.equals(Boolean.valueOf(System.getProperty("maximumPerformanceMode")))) { - // Beast Mode On - System.setProperty("aiPoweredSelfHealingElementIdentification", String.valueOf(false)); - System.setProperty("headlessExecution", String.valueOf(true)); - System.setProperty("autoMaximizeBrowserWindow", String.valueOf(true)); - System.setProperty("forceCheckForElementVisibility", String.valueOf(false)); - System.setProperty("forceCheckElementLocatorIsUnique", String.valueOf(false)); - System.setProperty("screenshotParams_whenToTakeAScreenshot", "ValidationPointsOnly"); - System.setProperty("screenshotParams_highlightElements", String.valueOf(true)); - System.setProperty("screenshotParams_highlightMethod", "AI"); - System.setProperty("screenshotParams_screenshotType", "Regular"); - System.setProperty("screenshotParams_watermark", String.valueOf(true)); - System.setProperty("createAnimatedGif", String.valueOf(false)); - System.setProperty("recordVideo", String.valueOf(false)); - System.setProperty("debugMode", String.valueOf(false)); + String maximumPerformanceMode = System.getProperty("maximumPerformanceMode"); + switch (maximumPerformanceMode) { + case "true", "1", "2" -> { + System.setProperty("aiPoweredSelfHealingElementIdentification", String.valueOf(false)); + System.setProperty("autoMaximizeBrowserWindow", String.valueOf(true)); + System.setProperty("forceCheckForElementVisibility", String.valueOf(false)); + System.setProperty("forceCheckElementLocatorIsUnique", String.valueOf(false)); + System.setProperty("screenshotParams_whenToTakeAScreenshot", "ValidationPointsOnly"); + System.setProperty("screenshotParams_highlightElements", String.valueOf(true)); + System.setProperty("screenshotParams_highlightMethod", "AI"); + System.setProperty("screenshotParams_screenshotType", "Regular"); + System.setProperty("screenshotParams_watermark", String.valueOf(true)); + System.setProperty("createAnimatedGif", String.valueOf(false)); + System.setProperty("recordVideo", String.valueOf(false)); + System.setProperty("debugMode", String.valueOf(false)); + System.setProperty("headlessExecution", String.valueOf(false)); + if (maximumPerformanceMode.equals("2")) System.setProperty("headlessExecution", String.valueOf(true)); + } + case "false", "0" -> { + } } - } private static void loadPropertiesFileIntoSystemProperties(Properties properties, File propertyFile) { diff --git a/src/main/java/com/shaft/tools/io/ReportManager.java b/src/main/java/com/shaft/tools/io/ReportManager.java index d6a9b8b6dda..8a00c11346c 100755 --- a/src/main/java/com/shaft/tools/io/ReportManager.java +++ b/src/main/java/com/shaft/tools/io/ReportManager.java @@ -1,10 +1,19 @@ package com.shaft.tools.io; +import com.aventstack.extentreports.ExtentReports; +import com.aventstack.extentreports.ExtentTest; +import com.aventstack.extentreports.MediaEntityBuilder; +import com.aventstack.extentreports.markuputils.CodeLanguage; +import com.aventstack.extentreports.markuputils.MarkupHelper; +import com.aventstack.extentreports.reporter.ExtentSparkReporter; +import com.aventstack.extentreports.reporter.configuration.Theme; +import com.aventstack.extentreports.reporter.configuration.ViewName; import com.shaft.api.RestActions; import com.shaft.cli.FileActions; import com.shaft.cli.TerminalActions; import io.qameta.allure.Allure; import io.qameta.allure.Step; +import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.SystemUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -48,10 +57,20 @@ public class ReportManager { private static List> listOfNewIssuesForFailedTests = new ArrayList<>(); private static String featureName = ""; + private static String extentReportsFolderPath = ""; + private static ExtentReports extentReport; + private static ExtentTest extentTest; + private static String extentReportFileName; + private static String generateExtentReports; + private ReportManager() { throw new IllegalStateException("Utility class"); } + public static String getExtentReportFileName() { + return extentReportFileName; + } + public static void setOpenIssuesForFailedTestsCounter(int openIssuesForFailedTestsCounter) { ReportManager.openIssuesForFailedTestsCounter = openIssuesForFailedTestsCounter; } @@ -344,7 +363,7 @@ public static void attachIssuesLog(String executionEndTimestamp) { } } - public static void openAllureReportAfterExecution() { + protected static void openAllureReportAfterExecution() { String commandToOpenAllureReport; if (Boolean.TRUE.equals(Boolean.valueOf(System.getProperty("openAllureReportAfterExecution").trim())) && System.getProperty("executionAddress").trim().equals("local")) { @@ -358,7 +377,7 @@ public static void openAllureReportAfterExecution() { } } - public static void generateAllureReportArchive() { + protected static void generateAllureReportArchive() { if (Boolean.TRUE.equals(Boolean.valueOf(System.getProperty("generateAllureReportArchive").trim())) && System.getProperty("executionAddress").trim().equals("local")) { logDiscrete("Generating Allure Report Archive..."); @@ -418,6 +437,89 @@ public static void setFeatureName(String featureName) { ReportManager.featureName = featureName; } + private static boolean generateExtentReports() { + if (generateExtentReports == null) { + generateExtentReports = System.getProperty("generateExtentReports").trim(); + } + return Boolean.parseBoolean(generateExtentReports); + } + + public static void initializeExtentReports() { + if (Boolean.TRUE.equals(generateExtentReports())) { + extentReportsFolderPath = System.getProperty("extentReportsFolderPath").trim(); + cleanExtentReportsDirectory(); + extentReportFileName = extentReportsFolderPath + "ExtentReports_" + (new SimpleDateFormat("dd-MM-yyyy_HH-mm-ss-SSSS-aaa")).format(System.currentTimeMillis()) + ".html"; + extentReport = new ExtentReports(); + ExtentSparkReporter spark = new ExtentSparkReporter(extentReportFileName) + .viewConfigurer() + .viewOrder() + .as(new ViewName[]{ViewName.DASHBOARD, ViewName.TEST, ViewName.EXCEPTION}) + .apply(); + extentReport.attachReporter(spark); + spark.config().setTheme(Theme.STANDARD); + spark.config().setDocumentTitle("Extent Reports"); + spark.config().setReportName("Extent Reports - Powered by SHAFT_Engine"); + } + } + + private static void cleanExtentReportsDirectory() { + if (Boolean.TRUE.equals( + Boolean.valueOf(System.getProperty("cleanExtentReportsDirectoryBeforeExecution")))) { + FileActions.deleteFolder(extentReportsFolderPath.substring(0, extentReportsFolderPath.length() - 1)); + } + + } + + public static void extentReportsReset() { + extentTest = null; + } + + public static void extentReportsCreateTest(String testName, String testDescription) { + if (Boolean.TRUE.equals(generateExtentReports())) { + if (testDescription.equals("")) { + extentTest = extentReport.createTest(testName); + } else { + extentTest = extentReport.createTest(testDescription); + } + } + } + + public static void extentReportsPass(String message) { + if (Boolean.TRUE.equals(generateExtentReports())) { + extentTest.pass(message); + } + } + + public static void extentReportsFail(String message) { + if (Boolean.TRUE.equals(generateExtentReports())) { + extentTest.fail(message); + } + } + + public static void extentReportsFail(Throwable t) { + if (Boolean.TRUE.equals(generateExtentReports())) { + extentTest.fail(t); + } + } + + public static void extentReportsSkip(String message) { + if (Boolean.TRUE.equals(generateExtentReports())) { + extentTest.skip(message); + } + } + + public static void extentReportsSkip(Throwable t) { + if (Boolean.TRUE.equals(generateExtentReports())) { + extentTest.skip(t); + } + } + + public static void extentReportsFlush() { + if (Boolean.TRUE.equals(generateExtentReports())) { + extentReport.flush(); + } + } + protected static void logClosureActivitiesInitialization() { String closureActivities = "Test Closure Activities"; createImportantReportEntry(closureActivities, true); @@ -465,6 +567,10 @@ private static void createReportEntry(String logText, Boolean addToFullLog) { } String log = REPORT_MANAGER_PREFIX + logText.trim() + " @" + timestamp; Reporter.log(log, true); + if (extentTest != null && !logText.contains("created attachment") && !logText.contains(" -1) { - baos.write(buffer, 0, len); - } - baos.flush(); + attachmentContent.transferTo(baos); } catch (IOException e) { String error = "Error while creating Attachment"; slf4jLogger.info(error, e); Reporter.log(error, false); } - attachmentContent = new ByteArrayInputStream(baos.toByteArray()); - attachmentContentCopy = new ByteArrayInputStream(baos.toByteArray()); - String attachmentDescription = "Attachment: " + attachmentType + " - " + attachmentName; + attachBasedOnFileType(attachmentType, attachmentName, baos, attachmentDescription); + logAttachmentAction(attachmentType, attachmentName, baos); + } - attachBasedOnFileType(attachmentType, attachmentName, attachmentContent, attachmentDescription); + private static synchronized void attachBasedOnFileType(String attachmentType, String attachmentName, + ByteArrayOutputStream attachmentContent, String attachmentDescription) { + if (attachmentType.toLowerCase().contains("screenshot")) { + Allure.addAttachment(attachmentDescription, "image/png", new ByteArrayInputStream(attachmentContent.toByteArray()), ".png"); + attachImageToExtentReport("image/png", new ByteArrayInputStream(attachmentContent.toByteArray())); + } else if (attachmentType.toLowerCase().contains("recording")) { + Allure.addAttachment(attachmentDescription, "video/mp4", new ByteArrayInputStream(attachmentContent.toByteArray()), ".mp4"); + // attachmentDescription, "video/quicktime", attachmentContent, ".mov"); + // attachmentDescription, "video/webm", attachmentContent, ".webm"); + // attachmentDescription, "video/mp4", attachmentContent, ".mp4"); + // attachmentDescription, "video/ogg", attachmentContent, ".ogg"); + } else if (attachmentType.toLowerCase().contains("gif")) { + Allure.addAttachment(attachmentDescription, "image/gif", new ByteArrayInputStream(attachmentContent.toByteArray()), ".gif"); + attachImageToExtentReport("image/gif", new ByteArrayInputStream(attachmentContent.toByteArray())); + } else if (attachmentType.toLowerCase().contains("csv") || attachmentName.toLowerCase().contains("csv")) { + Allure.addAttachment(attachmentDescription, "text/csv", new ByteArrayInputStream(attachmentContent.toByteArray()), ".csv"); + attachCodeBlockToExtentReport("text/csv", new ByteArrayInputStream(attachmentContent.toByteArray())); + } else if (attachmentType.toLowerCase().contains("xml") || attachmentName.toLowerCase().contains("xml")) { + Allure.addAttachment(attachmentDescription, "text/xml", new ByteArrayInputStream(attachmentContent.toByteArray()), ".xml"); + attachCodeBlockToExtentReport("text/xml", new ByteArrayInputStream(attachmentContent.toByteArray())); + } else if (attachmentType.toLowerCase().contains("excel") || attachmentName.toLowerCase().contains("excel")) { + Allure.addAttachment(attachmentDescription, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", new ByteArrayInputStream(attachmentContent.toByteArray()), ".xlsx"); + } else if (attachmentType.toLowerCase().contains("json") || attachmentName.toLowerCase().contains("json")) { + Allure.addAttachment(attachmentDescription, "text/json", new ByteArrayInputStream(attachmentContent.toByteArray()), ".json"); + attachCodeBlockToExtentReport("text/json", new ByteArrayInputStream(attachmentContent.toByteArray())); + } else if (attachmentType.toLowerCase().contains("engine logs")) { + Allure.addAttachment(attachmentDescription, "text/plain", new ByteArrayInputStream(attachmentContent.toByteArray()), ".txt"); + } else { + Allure.addAttachment(attachmentDescription, new ByteArrayInputStream(attachmentContent.toByteArray())); + } + } + private static synchronized void logAttachmentAction(String attachmentType, String attachmentName, ByteArrayOutputStream attachmentContent) { if (!(attachmentType.equals(SHAFT_ENGINE_LOGS_ATTACHMENT_TYPE) && attachmentName.equals("Execution log"))) { createReportEntry("Successfully created attachment [" + attachmentType + " - " + attachmentName + "]", false); @@ -557,7 +688,7 @@ private static void createAttachment(String attachmentType, String attachmentNam String theString; BufferedReader br = new BufferedReader( - new InputStreamReader(attachmentContentCopy, StandardCharsets.UTF_8)); + new InputStreamReader(new ByteArrayInputStream(attachmentContent.toByteArray()), StandardCharsets.UTF_8)); theString = br.lines().collect(Collectors.joining(System.lineSeparator())); if (!theString.isEmpty()) { String logEntry = REPORT_MANAGER_PREFIX + "Debugging Attachment Entry" + " @" + timestamp @@ -567,30 +698,33 @@ private static void createAttachment(String attachmentType, String attachmentNam } } - private static synchronized void attachBasedOnFileType(String attachmentType, String attachmentName, - InputStream attachmentContent, String attachmentDescription) { - if (attachmentType.toLowerCase().contains("screenshot")) { - Allure.addAttachment(attachmentDescription, "image/png", attachmentContent, ".png"); - } else if (attachmentType.toLowerCase().contains("recording")) { - Allure.addAttachment(attachmentDescription, "video/mp4", attachmentContent, ".mp4"); - // attachmentDescription, "video/quicktime", attachmentContent, ".mov"); - // attachmentDescription, "video/webm", attachmentContent, ".webm"); - // attachmentDescription, "video/mp4", attachmentContent, ".mp4"); - // attachmentDescription, "video/ogg", attachmentContent, ".ogg"); - } else if (attachmentType.toLowerCase().contains("gif")) { - Allure.addAttachment(attachmentDescription, "image/gif", attachmentContent, ".gif"); - } else if (attachmentType.toLowerCase().contains("csv") || attachmentName.toLowerCase().contains("csv")) { - Allure.addAttachment(attachmentDescription, "text/csv", attachmentContent, ".csv"); - } else if (attachmentType.toLowerCase().contains("xml") || attachmentName.toLowerCase().contains("xml")) { - Allure.addAttachment(attachmentDescription, "text/xml", attachmentContent, ".xml"); - } else if (attachmentType.toLowerCase().contains("excel") || attachmentName.toLowerCase().contains("excel")) { - Allure.addAttachment(attachmentDescription, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", attachmentContent, ".xlsx"); - } else if (attachmentType.toLowerCase().contains("json") || attachmentName.toLowerCase().contains("json")) { - Allure.addAttachment(attachmentDescription, "text/json", attachmentContent, ".json"); - } else if (attachmentType.toLowerCase().contains("engine logs")) { - Allure.addAttachment(attachmentDescription, "text/plain", attachmentContent, ".txt"); - } else { - Allure.addAttachment(attachmentDescription, attachmentContent); + private static void attachCodeBlockToExtentReport(String attachmentType, InputStream attachmentContent) { + if (extentTest != null) { + try { + String codeBlock = IOUtils.toString(attachmentContent, StandardCharsets.UTF_8.name()); + switch (attachmentType) { + case "text/json" -> extentTest.info(MarkupHelper.createCodeBlock(codeBlock, CodeLanguage.JSON)); + case "text/xml" -> extentTest.info(MarkupHelper.createCodeBlock(codeBlock, CodeLanguage.XML)); + default -> extentTest.info(MarkupHelper.createCodeBlock(codeBlock)); + } + } catch (IOException e) { + ReportManager.logDiscrete("Failed to attach code block to extentReport."); + } + } + } + + private static void attachImageToExtentReport(String attachmentType, InputStream attachmentContent) { + if (extentTest != null) { + try { + String image = Base64.getEncoder().encodeToString(IOUtils.toByteArray(attachmentContent)); + if (attachmentType.toLowerCase().contains("gif")) { + extentTest.addScreenCaptureFromBase64String(image); + } else { + extentTest.info(MediaEntityBuilder.createScreenCaptureFromBase64String(image).build()); + } + } catch (IOException e) { + ReportManager.logDiscrete("Failed to attach screenshot to extentReport."); + } } } @@ -621,7 +755,6 @@ private static void writeEnvironmentVariablesToAllureResultsDirectory() { if (propertyValue.contains("&")) { propertyValue = propertyValue.replace("&", "&"); } - String parameter = "" + "" + propertyKey + "" + "" + propertyValue + "" + ""; if (propertyKey.equals(SHAFT_ENGINE_VERSION_PROPERTY_NAME)) { @@ -670,7 +803,7 @@ private static void writeGenerateReportShellFilesToProjectDirectory() { if (SystemUtils.IS_OS_WINDOWS) { // create windows batch file commandsToServeAllureReport = Arrays.asList("@echo off", - "set path=" + allureExtractionLocation + "allure-" + allureVersion + "\\bin;%path%", + "set path=" + allureExtractionLocation + "allure-" + allureVersion + "\\bin;" + System.getProperty("java.home") + "\\bin;%path%", "allure serve " + allureResultsFolderPath.substring(0, allureResultsFolderPath.length() - 1), "pause", "exit"); FileActions.writeToFile("", "generate_allure_report.bat", commandsToServeAllureReport); @@ -720,7 +853,7 @@ private static void writeOpenReportShellFilesToGeneratedDirectory() { // create windows batch file commandsToOpenAllureReport = Arrays.asList("@echo off", - "set path=allure\\allure-" + System.getProperty(ALLURE_VERSION_PROPERTY_NAME) + "\\bin;%path%", + "set path=allure\\allure-" + System.getProperty(ALLURE_VERSION_PROPERTY_NAME) + "\\bin;" + System.getProperty("java.home") + ";%path%", "allure open allure-report", "pause", "exit"); FileActions.writeToFile("generatedReport/", "open_allure_report.bat", commandsToOpenAllureReport); diff --git a/src/main/java/com/shaft/tools/listeners/InvokedMethodListener.java b/src/main/java/com/shaft/tools/listeners/InvokedMethodListener.java index 0a880a1c81d..c81591398fc 100755 --- a/src/main/java/com/shaft/tools/listeners/InvokedMethodListener.java +++ b/src/main/java/com/shaft/tools/listeners/InvokedMethodListener.java @@ -38,21 +38,31 @@ public void beforeInvocation(IInvokedMethod method, ITestResult testResult) { ReportManager.log(e); } ITestNGMethod testMethod = method.getTestMethod(); + + String className; + String methodName; + String methodDescription = ""; + if (!testMethod.getQualifiedName().contains("AbstractTestNGCucumberTests")) { if (testMethod.isTest()) { + className = ReportManager.getTestClassName(); + methodName = ReportManager.getTestMethodName(); if (testMethod.getDescription() != null) { - ReportManager.logTestInformation(ReportManager.getTestClassName(), ReportManager.getTestMethodName(), - testMethod.getDescription()); - } else { - ReportManager.logTestInformation(ReportManager.getTestClassName(), ReportManager.getTestMethodName(), ""); + methodDescription = testMethod.getDescription(); } + + ReportManager.logTestInformation(className, methodName, methodDescription); + ReportManager.extentReportsCreateTest(className + "." + methodName, methodDescription); } else if (testMethod instanceof ConfigurationMethod) { // org.testng.internal.ConfigurationMethod // ReportManager.logDiscrete("Current TestNG Method Name: " + // testMethod.getClass().getName()); // configuration method information is not added to any logger (TestNG.Reporter) - ReportManager.logConfigurationMethodInformation(testMethod.getTestClass().getName(), - testMethod.getMethodName()); + className = testMethod.getTestClass().getName(); + methodName = testMethod.getMethodName(); + + ReportManager.logConfigurationMethodInformation(className, methodName); + ReportManager.extentReportsReset(); } } // implementing the new kill switch at the start of every test method @@ -119,9 +129,22 @@ private void updateIssuesLog(ITestResult testResult, ITestNGMethod testMethod) { if (testResult != null && testResult.getStatus() == ITestResult.SUCCESS) { // if test passed reportOpenIssueStatus(testMethod, true); + ReportManager.extentReportsPass("Test Passed."); } else if (testResult != null && testResult.getStatus() == ITestResult.FAILURE) { // if test failed reportOpenIssueStatus(testMethod, false); + if (testResult.getThrowable() != null) { + ReportManager.extentReportsFail(testResult.getThrowable()); + } else { + ReportManager.extentReportsFail("Test Failed."); + } + } else if (testResult != null && testResult.getStatus() == ITestResult.SKIP) { + // if test skipped + if (testResult.getThrowable() != null) { + ReportManager.extentReportsSkip(testResult.getThrowable()); + } else { + ReportManager.extentReportsSkip("Test Skipped as it depends on unsuccessfully executed methods."); + } } } diff --git a/src/main/java/com/shaft/tools/listeners/SuiteListener.java b/src/main/java/com/shaft/tools/listeners/SuiteListener.java index b8d42e4c4ec..cc364b859bd 100755 --- a/src/main/java/com/shaft/tools/listeners/SuiteListener.java +++ b/src/main/java/com/shaft/tools/listeners/SuiteListener.java @@ -20,6 +20,7 @@ public void onStart(ISuite suite) { PropertyFileManager.readPropertyFiles(ScreenshotManager.getAiAidedElementIdentificationFolderpath()); } ProjectStructureFactory.initialize(); + ReportManager.initializeExtentReports(); ReportManager.prepareAllureReportingEnvironment(); ReportManager.logEngineVersion(); if (!(suite.getAllMethods().size() == 1 && suite.getAllMethods().get(0).getMethodName().equals("runScenario"))) { @@ -29,11 +30,4 @@ public void onStart(ISuite suite) { ReportManager.setDiscreteLogging(Boolean.parseBoolean(System.getProperty("alwaysLogDiscreetly"))); ReportManager.setDebugMode(Boolean.valueOf(System.getProperty("debugMode"))); } - - @Override - public void onFinish(ISuite suite) { - ReportManager.setDiscreteLogging(true); - ReportManager.generateAllureReportArchive(); - ReportManager.openAllureReportAfterExecution(); - } } \ No newline at end of file diff --git a/src/main/javadoc/index.html b/src/main/javadoc/index.html index 67343be19f6..5962791d8f7 100644 --- a/src/main/javadoc/index.html +++ b/src/main/javadoc/index.html @@ -378,15 +378,22 @@

Configuration Manager

+
+
+
ExperimentalFeature* Enabling maximumPerformanceMode will disable all complementary features to ensure the fastest execution possible with a 400% calculated performance boost. @@ -1177,6 +1184,60 @@

Configuration Manager

+ +
+ +
+
+ +
+
+ +
+ • Enabling this setting will create an emailable extent report html file after every test execution. +
+
+ + +
+ +
+
+ +
+
+ +
+ • Enabling this setting will reset the extent report before every test run, while disabling it will allow you to keep track of your old reports. +
+
+