From be1b98d36ca47e509d9f63a86cb582a8d7b6aa41 Mon Sep 17 00:00:00 2001 From: "Hoisko Sakari.M 10802213" Date: Thu, 23 Aug 2018 14:22:45 +0300 Subject: [PATCH 01/95] Added dockerized env where to build / test / demo JavaFXLibrary with minimal setup --- AUTHORS.txt | 3 +- Dockerfile_build | 23 ++++++++++ Dockerfile_release | 24 ++++++++++ README.md | 20 ++++++++ docker-compose.yml | 46 +++++++++++++++++++ docker/robot-javafx-demo/Dockerfile | 30 ++++++++++++ docker/robot-javafx-demo/entrypoint.sh | 3 ++ .../acceptance/0_ClickRobotTest.robot | 4 +- .../acceptance/BoundsLocationTest.robot | 4 +- .../acceptance/DatePickerTest.robot | 2 +- .../acceptance/DragRobotTest.robot | 6 +-- .../robotframework/acceptance/FindTest.robot | 2 +- .../acceptance/KeyboardRobotTest.robot | 4 +- .../acceptance/MenuAppTest.robot | 2 +- .../robotframework/acceptance/MiscTests.robot | 4 +- .../acceptance/MoveRobotTest.robot | 6 +-- .../acceptance/NodeLookupTest.robot | 4 +- .../acceptance/PointLocationTest.robot | 6 +-- .../acceptance/ScreenCapturingTest.robot | 4 +- .../acceptance/ScrollRobotTest.robot | 6 +-- .../acceptance/ScrollRobotTest2.robot | 4 +- .../SwingApplicationWrapperTest.robot | 2 +- .../acceptance/WindowLookupTest.robot | 4 +- .../acceptance/WindowManagementTest.robot | 4 +- .../acceptance/WindowTargetingTest.robot | 2 +- src/test/robotframework/resource.robot | 3 ++ 26 files changed, 186 insertions(+), 36 deletions(-) create mode 100644 Dockerfile_build create mode 100644 Dockerfile_release create mode 100644 docker-compose.yml create mode 100644 docker/robot-javafx-demo/Dockerfile create mode 100644 docker/robot-javafx-demo/entrypoint.sh create mode 100644 src/test/robotframework/resource.robot diff --git a/AUTHORS.txt b/AUTHORS.txt index 8566740..2a85cf4 100644 --- a/AUTHORS.txt +++ b/AUTHORS.txt @@ -4,4 +4,5 @@ Sami Pesonen 2017 - Pasi Saikkonen 2017 - Other contributors: -Tatu Lahtela Find All With Pseudo Class and Find Class keywords \ No newline at end of file +Tatu Lahtela Find All With Pseudo Class and Find Class keywords +Sakari Hoisko Dockerized linux env with X diff --git a/Dockerfile_build b/Dockerfile_build new file mode 100644 index 0000000..e226d39 --- /dev/null +++ b/Dockerfile_build @@ -0,0 +1,23 @@ +FROM ubuntu:16.04 as builder +ENV DEBIAN_FRONTEND noninteractive +RUN apt-get -qq update && apt-get dist-upgrade -y && apt-get install -qq --no-install-recommends --allow-unauthenticated -y \ + openjdk-8-jdk \ + openjfx \ + python3-pip \ + maven \ + git-all \ + && rm -rf /var/lib/apt/lists/* \ + && mkdir code +COPY . /code +WORKDIR /code +RUN mvn package -Dmaven.test.skip=true +# ENTRYPOINT java -jar /code/target/javafxlibrary-*-SNAPSHOT-jar-with-dependencies.jar + +FROM ubuntu:16.04 +RUN apt-get -qq update && apt-get dist-upgrade -y && apt-get install -qq --no-install-recommends --allow-unauthenticated -y \ + openjdk-8-jre \ + openjfx \ + && rm -rf /var/lib/apt/lists/* +COPY --from=builder /code/target/javafxlibrary-*-SNAPSHOT-jar-with-dependencies.jar . +EXPOSE 8270 +ENTRYPOINT java -jar javafxlibrary-*-SNAPSHOT-jar-with-dependencies.jar diff --git a/Dockerfile_release b/Dockerfile_release new file mode 100644 index 0000000..cf9b761 --- /dev/null +++ b/Dockerfile_release @@ -0,0 +1,24 @@ +THIS IS JUST DRAFT!!! + +FROM ubuntu:16.04 as builder +ENV DEBIAN_FRONTEND noninteractive +RUN apt-get -qq update && apt-get dist-upgrade -y && apt-get install -qq --no-install-recommends --allow-unauthenticated -y \ + openjdk-8-jdk \ + openjfx \ + python3-pip \ + maven \ + git-all \ + && mkdir code +RUN wget latest https://github.com/eficode/JavaFXLibrary/releases Source code.zip && unzip +WORKDIR /code +RUN mvn package -Dmaven.test.skip=true + +FROM ubuntu:16.04 +RUN apt-get -qq update && apt-get dist-upgrade -y && apt-get install -qq --no-install-recommends --allow-unauthenticated -y \ + openjdk-8-jre \ + openjfx \ + && rm -rf /var/lib/apt/lists/* +COPY --from=builder /code/target/JAVAFX:n testisoftat +RUN wget https://github.com/eficode/JavaFXLibrary/releases JavaFXLibrary-0.4.1.jar +EXPOSE 8270 +ENTRYPOINT java -jar JavaFXLibrary-0.4.1.jar jolle sisäään myös testisofta jarrit class pathinä/etc? diff --git a/README.md b/README.md index b76286a..014eab3 100644 --- a/README.md +++ b/README.md @@ -77,6 +77,26 @@ java -cp "target/javafxlibrary-.jar" org.robotframework.RobotFramework ``` +## JavaFXLibrary Dockerized environment over remote library +Requirements: +* VNC viewer e.g. https://www.realvnc.com/en/connect/download/viewer/ +* Docker CE: https://docs.docker.com/install/ +* Docker-compose: https://docs.docker.com/compose/install/ +* VNC port: vnc://localhost:5900 + +Build & Start Dockerized Environment: +``` +docker-compose up -d robot-framework javafxcompile +``` +Take VNC connecion to: vnc://:5900 +
Password is: 1234 +
Right click a mouse in VNC desktop and open shell. +
Execute in shell: +``` +robot -d /robot/results /robot/acceptance +``` +FYI: remote server is running in different container than tests just GUIs are forwarded to VNC container + ## Known issues * If the remote library server and tests are running on the same machine, the server must be restarted between test executions. If the server is not restarted, test applications will launch behind other windows, causing tests to fail when robot is trying to interact with them. diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..493ae8a --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,46 @@ +version: '2' +services: + + robot-framework: + build: + context: ./docker/robot-javafx-demo + ports: + - '5900:5900' + volumes: + - './src/test/robotframework/:/robot' + - screen-thing:/tmp/.X11-unix + networks: + - testapp + + javafxcompile: + build: + context: ./ + dockerfile: Dockerfile_build + restart: on-failure + networks: + - testapp + volumes: + - './src/:/src' # ScreenCapturingTest.robot require this. + - screen-thing:/tmp/.X11-unix + environment: + - DISPLAY=:20.0 + +# javafxrelease: +# build: +# context: ./ +# dockerfile: Dockerfile_release +# restart: on-failure +# networks: +# testapp: +# aliases: +# - javafxcompile +# volumes: +# - './src/:/src' # ScreenCapturingTest.robot require this. +# - screen-thing:/tmp/.X11-unix +# environment: +# - DISPLAY=:20.0 + +networks: + testapp: +volumes: + screen-thing: diff --git a/docker/robot-javafx-demo/Dockerfile b/docker/robot-javafx-demo/Dockerfile new file mode 100644 index 0000000..4dd923c --- /dev/null +++ b/docker/robot-javafx-demo/Dockerfile @@ -0,0 +1,30 @@ +FROM ubuntu:16.04 + +ENV DEBIAN_FRONTEND noninteractive + +RUN apt-get -qq update && apt-get dist-upgrade -y && apt-get install -qq --no-install-recommends --allow-unauthenticated -y \ + dbus \ + openssh-client \ + x11vnc \ + xvfb \ + bash \ + xterm \ + fluxbox \ + python-pip \ + git \ + nano \ + python-setuptools \ + wget \ + xvfb \ + xorg \ + && apt-get clean && rm -rf /var/lib/apt/lists/* + +RUN pip install --no-cache-dir \ + robotframework + +RUN mkdir ~/.vnc +RUN x11vnc -storepasswd 1234 ~/.vnc/passwd +COPY entrypoint.sh /entrypoint.sh +EXPOSE 5900 + +ENTRYPOINT ["x11vnc", "-create", "-forever", "-env", "FD_PROG=/entrypoint.sh", "-env", "X11VNC_CREATE_GEOM=${1:-1024x768x16}", "-usepw"] diff --git a/docker/robot-javafx-demo/entrypoint.sh b/docker/robot-javafx-demo/entrypoint.sh new file mode 100644 index 0000000..f175d17 --- /dev/null +++ b/docker/robot-javafx-demo/entrypoint.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env bash +xhost + +/usr/bin/fluxbox diff --git a/src/test/robotframework/acceptance/0_ClickRobotTest.robot b/src/test/robotframework/acceptance/0_ClickRobotTest.robot index c1e9047..3097c1e 100644 --- a/src/test/robotframework/acceptance/0_ClickRobotTest.robot +++ b/src/test/robotframework/acceptance/0_ClickRobotTest.robot @@ -1,6 +1,6 @@ *** Settings *** Documentation Tests to test javafxlibrary.keywords.ClickRobot related keywords -Library JavaFXLibrary +Resource ../resource.robot Suite Setup Setup all tests Suite Teardown Teardown all tests Test Setup Reset Counters @@ -307,7 +307,7 @@ Reset Counters Verify String id=buttonLabel Button has been clicked 0 times. Verify String id=rightClickButtonLabel Button has been right-clicked 0 times. Verify String id=doubleClickButtonLabel Button has been double-clicked 0 times. - + Verify String [Documentation] Verifies that string is equal in location [Arguments] ${query} ${string} diff --git a/src/test/robotframework/acceptance/BoundsLocationTest.robot b/src/test/robotframework/acceptance/BoundsLocationTest.robot index 52792df..c437927 100644 --- a/src/test/robotframework/acceptance/BoundsLocationTest.robot +++ b/src/test/robotframework/acceptance/BoundsLocationTest.robot @@ -1,6 +1,6 @@ *** Settings *** Documentation Tests to test javafxlibrary.keywords.BoundsLocation related keywords -Library JavaFXLibrary +Resource ../resource.robot Suite Setup Setup all tests Suite Teardown Teardown all tests Force Tags set-boundslocation @@ -143,4 +143,4 @@ Get Bottom Decoration Height ${SCENEY} Call Object Method ${SCENE} getY ${SCENEHEIGHT} Call Object Method ${SCENE} getHeight ${DECOHEIGHT} Evaluate ${WINDOWHEIGHT} - ${SCENEHEIGHT} - ${SCENEY} - [Return] ${DECOHEIGHT} \ No newline at end of file + [Return] ${DECOHEIGHT} diff --git a/src/test/robotframework/acceptance/DatePickerTest.robot b/src/test/robotframework/acceptance/DatePickerTest.robot index d61e7c6..74f20cf 100644 --- a/src/test/robotframework/acceptance/DatePickerTest.robot +++ b/src/test/robotframework/acceptance/DatePickerTest.robot @@ -1,6 +1,6 @@ *** Settings *** Documentation Tests to test DatePicker related keywords -Library JavaFXLibrary +Resource ../resource.robot Suite Setup Setup all tests Suite Teardown Teardown all tests Test Teardown Clear Text Input css=.text-field diff --git a/src/test/robotframework/acceptance/DragRobotTest.robot b/src/test/robotframework/acceptance/DragRobotTest.robot index 4d32344..4b5b091 100644 --- a/src/test/robotframework/acceptance/DragRobotTest.robot +++ b/src/test/robotframework/acceptance/DragRobotTest.robot @@ -1,6 +1,6 @@ *** Settings *** Documentation Tests to test javafxlibrary.keywords.DragRobot related keywords -Library JavaFXLibrary +Resource ../resource.robot Suite Setup Setup all tests Suite Teardown Teardown all tests Force tags set-dragrobot @@ -264,10 +264,10 @@ Set Coordinates To Use ${SET_Y} Convert To Integer ${SET_Y} Set Suite Variable ${COORD_X} ${SET_X} Set Suite Variable ${COORD_Y} ${SET_Y} - + Verify String [Documentation] Verifies that string is equal in location [Arguments] ${query} ${string} ${target_node} Find ${query} ${text_label} Get Node Text ${target_node} - Should Be Equal As Strings ${string} ${text_label} \ No newline at end of file + Should Be Equal As Strings ${string} ${text_label} diff --git a/src/test/robotframework/acceptance/FindTest.robot b/src/test/robotframework/acceptance/FindTest.robot index 3d64900..86ac853 100644 --- a/src/test/robotframework/acceptance/FindTest.robot +++ b/src/test/robotframework/acceptance/FindTest.robot @@ -1,6 +1,6 @@ *** Settings *** Documentation Tests to test javafxlibrary.keywords.AdditionalKeywords.Find related keywords -Library JavaFXLibrary +Resource ../resource.robot Suite Teardown Teardown all tests Force Tags set-find diff --git a/src/test/robotframework/acceptance/KeyboardRobotTest.robot b/src/test/robotframework/acceptance/KeyboardRobotTest.robot index 2783571..c24e345 100644 --- a/src/test/robotframework/acceptance/KeyboardRobotTest.robot +++ b/src/test/robotframework/acceptance/KeyboardRobotTest.robot @@ -1,6 +1,6 @@ *** Settings *** Documentation Tests to test javafxlibrary.keywords.KeyboardRobot related keywords -Library JavaFXLibrary +Resource ../resource.robot Suite Setup Setup all tests Suite Teardown Teardown all tests Force Tags set-keyboardrobot @@ -104,4 +104,4 @@ Verify String [Arguments] ${query} ${string} ${target_node} Find ${query} ${text_label} Get Node Text ${target_node} - Should Be Equal As Strings ${string} ${text_label} \ No newline at end of file + Should Be Equal As Strings ${string} ${text_label} diff --git a/src/test/robotframework/acceptance/MenuAppTest.robot b/src/test/robotframework/acceptance/MenuAppTest.robot index fd6604e..ffd1736 100644 --- a/src/test/robotframework/acceptance/MenuAppTest.robot +++ b/src/test/robotframework/acceptance/MenuAppTest.robot @@ -1,6 +1,6 @@ *** Settings *** Documentation Tests to test javafxlibrary keywords -Library JavaFXLibrary +Resource ../resource.robot Suite Setup Setup all tests Suite Teardown Teardown all tests Force Tags set-menuapp diff --git a/src/test/robotframework/acceptance/MiscTests.robot b/src/test/robotframework/acceptance/MiscTests.robot index 146c0a9..9dd17e3 100644 --- a/src/test/robotframework/acceptance/MiscTests.robot +++ b/src/test/robotframework/acceptance/MiscTests.robot @@ -1,6 +1,6 @@ *** Settings *** Documentation Tests for AdditionalKeywords -Library JavaFXLibrary +Resource ../resource.robot Library Collections Library String Suite Teardown Close Javafx Application @@ -319,4 +319,4 @@ Reset Node Id To Yellow [Arguments] ${node} ${original} Call Object Method ${node} setId yellow ${after_reset} Find id=yellow - Should Be Equal ${after_reset} ${original} \ No newline at end of file + Should Be Equal ${after_reset} ${original} diff --git a/src/test/robotframework/acceptance/MoveRobotTest.robot b/src/test/robotframework/acceptance/MoveRobotTest.robot index 358a0ed..23a7ae7 100644 --- a/src/test/robotframework/acceptance/MoveRobotTest.robot +++ b/src/test/robotframework/acceptance/MoveRobotTest.robot @@ -1,6 +1,6 @@ *** Settings *** Documentation Tests to test javafxlibrary.keywords.MoveRobot related keywords -Library JavaFXLibrary +Resource ../resource.robot Suite Setup Setup all tests Suite Teardown Teardown all tests Test Setup Move To Top Left Corner @@ -151,10 +151,10 @@ Set Decoration Values Set Suite Variable ${R_DECORATION_WIDTH} ${RIGHT_WIDTH} Set Suite Variable ${T_DECORATION_HEIGHT} ${TOP_HEIGHT} Set Suite Variable ${B_DECORATION_HEIGHT} ${BOTTOM_HEIGHT} - + Verify String [Documentation] Verifies that string is equal in location [Arguments] ${query} ${string} ${target_node} Find ${query} ${text_label} Get Node Text ${target_node} - Should Be Equal As Strings ${string} ${text_label} \ No newline at end of file + Should Be Equal As Strings ${string} ${text_label} diff --git a/src/test/robotframework/acceptance/NodeLookupTest.robot b/src/test/robotframework/acceptance/NodeLookupTest.robot index 2a7abdc..0252b91 100644 --- a/src/test/robotframework/acceptance/NodeLookupTest.robot +++ b/src/test/robotframework/acceptance/NodeLookupTest.robot @@ -1,6 +1,6 @@ *** Settings *** Documentation Tests to test javafxlibrary.keywords.NodeLookup related keywords -Library JavaFXLibrary +Resource ../resource.robot Suite Setup Setup all tests Suite Teardown Teardown all tests Force Tags set-nodelookup @@ -53,4 +53,4 @@ Setup all tests Set Screenshot Directory ${OUTPUT_DIR}${/}report-images Teardown all tests - Close Javafx Application \ No newline at end of file + Close Javafx Application diff --git a/src/test/robotframework/acceptance/PointLocationTest.robot b/src/test/robotframework/acceptance/PointLocationTest.robot index a83b180..5908ca4 100644 --- a/src/test/robotframework/acceptance/PointLocationTest.robot +++ b/src/test/robotframework/acceptance/PointLocationTest.robot @@ -1,6 +1,6 @@ *** Settings *** Documentation Tests to test javafxlibrary.keywords.PointLocation and PointOffset related keywords -Library JavaFXLibrary +Resource ../resource.robot Suite Setup Setup all tests Suite Teardown Teardown all tests Force Tags set-pointlocation set-pointoffset @@ -235,10 +235,10 @@ Set Decoration Values Set Suite Variable ${R_DECORATION_WIDTH} ${RIGHT_WIDTH} Set Suite Variable ${T_DECORATION_HEIGHT} ${TOP_HEIGHT} Set Suite Variable ${B_DECORATION_HEIGHT} ${BOTTOM_HEIGHT} - + Verify String [Documentation] Verifies that string is equal in location [Arguments] ${query} ${string} ${target_node} Find ${query} ${text_label} Get Node Text ${target_node} - Should Be Equal As Strings ${string} ${text_label} \ No newline at end of file + Should Be Equal As Strings ${string} ${text_label} diff --git a/src/test/robotframework/acceptance/ScreenCapturingTest.robot b/src/test/robotframework/acceptance/ScreenCapturingTest.robot index 8954e3a..3d93f52 100644 --- a/src/test/robotframework/acceptance/ScreenCapturingTest.robot +++ b/src/test/robotframework/acceptance/ScreenCapturingTest.robot @@ -1,6 +1,6 @@ *** Settings *** Documentation Tests to test javafxlibrary.keywords.ScreenCapturing related keywords -Library JavaFXLibrary +Resource ../resource.robot Suite Setup Setup all tests Suite Teardown Teardown all tests Force Tags set-screencapturing @@ -100,4 +100,4 @@ Setup all tests Set Screenshot Directory ${OUTPUT_DIR}${/}report-images Teardown all tests - Close Javafx Application \ No newline at end of file + Close Javafx Application diff --git a/src/test/robotframework/acceptance/ScrollRobotTest.robot b/src/test/robotframework/acceptance/ScrollRobotTest.robot index 50acaa7..8196a3e 100644 --- a/src/test/robotframework/acceptance/ScrollRobotTest.robot +++ b/src/test/robotframework/acceptance/ScrollRobotTest.robot @@ -1,6 +1,6 @@ *** Settings *** Documentation Tests to test javafxlibrary.keywords.ScrollRobot related keywords -Library JavaFXLibrary +Resource ../resource.robot Suite Setup Setup all tests Suite Teardown Teardown all tests Force Tags set-scrollrobot @@ -92,10 +92,10 @@ Count Distance [Arguments] ${WHEEL_TICKS} ${DISTANCE} Evaluate ${WHEEL_TICKS} * ${SCROLL_LENGTH} [Return] ${DISTANCE} - + Verify String [Documentation] Verifies that string is equal in location [Arguments] ${query} ${string} ${target_node} Find ${query} ${text_label} Get Node Text ${target_node} - Should Be Equal As Strings ${string} ${text_label} \ No newline at end of file + Should Be Equal As Strings ${string} ${text_label} diff --git a/src/test/robotframework/acceptance/ScrollRobotTest2.robot b/src/test/robotframework/acceptance/ScrollRobotTest2.robot index 90893ca..31429ec 100644 --- a/src/test/robotframework/acceptance/ScrollRobotTest2.robot +++ b/src/test/robotframework/acceptance/ScrollRobotTest2.robot @@ -1,6 +1,6 @@ *** Settings *** Documentation Tests to test javafxlibrary.keywords.ScrollRobot related keywords -Library JavaFXLibrary +Resource ../resource.robot Suite Setup Setup all tests Suite Teardown Teardown all tests Force Tags set-scrollrobot @@ -83,4 +83,4 @@ Verify String Should Not Match [Arguments] ${query} ${string} ${target_node} Find ${query} ${text_label} Get Node Text ${target_node} - Should Not Be Equal As Strings ${string} ${text_label} \ No newline at end of file + Should Not Be Equal As Strings ${string} ${text_label} diff --git a/src/test/robotframework/acceptance/SwingApplicationWrapperTest.robot b/src/test/robotframework/acceptance/SwingApplicationWrapperTest.robot index 09855e5..9873cc5 100644 --- a/src/test/robotframework/acceptance/SwingApplicationWrapperTest.robot +++ b/src/test/robotframework/acceptance/SwingApplicationWrapperTest.robot @@ -1,6 +1,6 @@ *** Settings *** Documentation Tests for handling Swing embedded JavaFX nodes -Library JavaFXLibrary +Resource ../resource.robot Force Tags set-embedded *** Testcases *** diff --git a/src/test/robotframework/acceptance/WindowLookupTest.robot b/src/test/robotframework/acceptance/WindowLookupTest.robot index a7be7ab..84bd362 100644 --- a/src/test/robotframework/acceptance/WindowLookupTest.robot +++ b/src/test/robotframework/acceptance/WindowLookupTest.robot @@ -1,6 +1,6 @@ *** Settings *** Documentation Tests to test javafxlibrary.keywords.WindowLookup related keywords -Library JavaFXLibrary +Resource ../resource.robot Suite Setup Setup all tests Suite Teardown Teardown all tests Force Tags set-windowlookup @@ -109,4 +109,4 @@ Setup all tests Set Screenshot Directory ${OUTPUT_DIR}${/}report-images Teardown all tests - Close Javafx Application \ No newline at end of file + Close Javafx Application diff --git a/src/test/robotframework/acceptance/WindowManagementTest.robot b/src/test/robotframework/acceptance/WindowManagementTest.robot index 7bd84b2..4fbefc8 100644 --- a/src/test/robotframework/acceptance/WindowManagementTest.robot +++ b/src/test/robotframework/acceptance/WindowManagementTest.robot @@ -1,6 +1,6 @@ *** Settings *** Documentation Tests for Window Management -Library JavaFXLibrary +Resource ../resource.robot Suite Setup Setup all tests Suite Teardown Teardown all tests Force Tags set-windowmanagement @@ -89,4 +89,4 @@ Get Employee Data [Return] ${DATA} Teardown all tests - Close Javafx Application \ No newline at end of file + Close Javafx Application diff --git a/src/test/robotframework/acceptance/WindowTargetingTest.robot b/src/test/robotframework/acceptance/WindowTargetingTest.robot index 2b11315..dddc3c1 100644 --- a/src/test/robotframework/acceptance/WindowTargetingTest.robot +++ b/src/test/robotframework/acceptance/WindowTargetingTest.robot @@ -1,6 +1,6 @@ *** Settings *** Documentation Tests to test javafxlibrary.keywords.WindowTargeting related keywords -Library JavaFXLibrary +Resource ../resource.robot Suite Setup Setup all tests Suite Teardown Teardown all tests Force Tags set-windowtargeting diff --git a/src/test/robotframework/resource.robot b/src/test/robotframework/resource.robot new file mode 100644 index 0000000..993c036 --- /dev/null +++ b/src/test/robotframework/resource.robot @@ -0,0 +1,3 @@ +*** Settings *** +Library JavaFXLibrary +Library Remote http://javafxcompile:8270/ WITH NAME RemoteJavaFXLibrary From 515b547f7b0b2a424d71d7691dd566e91d7dff8c Mon Sep 17 00:00:00 2001 From: Pasi Saikkonen Date: Fri, 24 Aug 2018 17:16:59 +0300 Subject: [PATCH 02/95] Adjustments to the README --- README.md | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 014eab3..fb3a4a6 100644 --- a/README.md +++ b/README.md @@ -77,25 +77,21 @@ java -cp "target/javafxlibrary-.jar" org.robotframework.RobotFramework ``` -## JavaFXLibrary Dockerized environment over remote library -Requirements: +## Remote library demo with Docker +### Requirements: * VNC viewer e.g. https://www.realvnc.com/en/connect/download/viewer/ * Docker CE: https://docs.docker.com/install/ * Docker-compose: https://docs.docker.com/compose/install/ * VNC port: vnc://localhost:5900 -Build & Start Dockerized Environment: -``` -docker-compose up -d robot-framework javafxcompile -``` -Take VNC connecion to: vnc://:5900 -
Password is: 1234 -
Right click a mouse in VNC desktop and open shell. -
Execute in shell: -``` -robot -d /robot/results /robot/acceptance -``` -FYI: remote server is running in different container than tests just GUIs are forwarded to VNC container +### Running the demo +1. Build & Start Dockerized Environment: `docker-compose up -d robot-framework javafxcompile` +2. Take VNC connection to: vnc://:5900 +3. Password is: 1234 +4. Open shell by right clicking in VNC desktop and selecting Applications > Shells > Bash +5. Execute tests: `robot --include smoke -d /robot/results /robot/acceptance` + +Remote server and tests run in separate containers, and their GUIs are forwarded to the VNC container. ## Known issues From 8281072d13423a8f7a551e5270cb1d9cd7b0c78f Mon Sep 17 00:00:00 2001 From: Pasi Saikkonen Date: Fri, 24 Aug 2018 17:24:27 +0300 Subject: [PATCH 03/95] Import the library dynamically Each test suite calls Import JavaFXLibrary keyword which imports the local jar library on Jython and the Remote library with Docker containers address on Python. --- src/main/java/JavaFXLibrary.java | 2 +- src/test/robotframework/acceptance/0_ClickRobotTest.robot | 1 + .../robotframework/acceptance/BoundsLocationTest.robot | 1 + src/test/robotframework/acceptance/DatePickerTest.robot | 1 + src/test/robotframework/acceptance/DragRobotTest.robot | 1 + src/test/robotframework/acceptance/FindTest.robot | 8 ++++++-- .../robotframework/acceptance/KeyboardRobotTest.robot | 1 + src/test/robotframework/acceptance/MenuAppTest.robot | 1 + src/test/robotframework/acceptance/MiscTests.robot | 6 +++++- src/test/robotframework/acceptance/MoveRobotTest.robot | 1 + src/test/robotframework/acceptance/NodeLookupTest.robot | 1 + .../robotframework/acceptance/PointLocationTest.robot | 1 + .../robotframework/acceptance/ScreenCapturingTest.robot | 1 + src/test/robotframework/acceptance/ScrollRobotTest.robot | 1 + src/test/robotframework/acceptance/ScrollRobotTest2.robot | 1 + .../acceptance/SwingApplicationWrapperTest.robot | 3 ++- src/test/robotframework/acceptance/WindowLookupTest.robot | 1 + .../robotframework/acceptance/WindowManagementTest.robot | 1 + .../robotframework/acceptance/WindowTargetingTest.robot | 1 + src/test/robotframework/resource.robot | 7 ++++--- 20 files changed, 33 insertions(+), 8 deletions(-) diff --git a/src/main/java/JavaFXLibrary.java b/src/main/java/JavaFXLibrary.java index 8eeee84..bb12fd0 100644 --- a/src/main/java/JavaFXLibrary.java +++ b/src/main/java/JavaFXLibrary.java @@ -82,7 +82,7 @@ public Object runKeyword(String keywordName, Object[] args) { try { // timeout + 100 ms so that underlying timeout has a chance to expire first - WaitForAsyncUtils.waitFor(getWaitUntilTimeout(TimeUnit.MILLISECONDS) + 100, TimeUnit.MILLISECONDS, () -> { + WaitForAsyncUtils.waitFor(getWaitUntilTimeout(TimeUnit.MILLISECONDS) + 500, TimeUnit.MILLISECONDS, () -> { try { retval.set(super.runKeyword(keywordName, finalArgs)); diff --git a/src/test/robotframework/acceptance/0_ClickRobotTest.robot b/src/test/robotframework/acceptance/0_ClickRobotTest.robot index 14521e0..0c65bf0 100644 --- a/src/test/robotframework/acceptance/0_ClickRobotTest.robot +++ b/src/test/robotframework/acceptance/0_ClickRobotTest.robot @@ -256,6 +256,7 @@ Click On Unsupported Type *** Keywords *** Setup all tests + Import JavaFXLibrary Launch Javafx Application ${TEST_APPLICATION} Set Screenshot Directory ${OUTPUT_DIR}${/}report-images Set Scene Values diff --git a/src/test/robotframework/acceptance/BoundsLocationTest.robot b/src/test/robotframework/acceptance/BoundsLocationTest.robot index 77753a3..a0d8db0 100644 --- a/src/test/robotframework/acceptance/BoundsLocationTest.robot +++ b/src/test/robotframework/acceptance/BoundsLocationTest.robot @@ -83,6 +83,7 @@ Get Bounds Of Id That Does Not Exist *** Keywords *** Setup all tests + Import JavaFXLibrary Set Timeout 1 Launch Javafx Application ${TEST_APPLICATION} Set Screenshot Directory ${OUTPUT_DIR}${/}report-images diff --git a/src/test/robotframework/acceptance/DatePickerTest.robot b/src/test/robotframework/acceptance/DatePickerTest.robot index 7fe2abb..b6500c2 100644 --- a/src/test/robotframework/acceptance/DatePickerTest.robot +++ b/src/test/robotframework/acceptance/DatePickerTest.robot @@ -32,6 +32,7 @@ Select JavaFX Release Date *** Keywords *** Setup all tests + Import JavaFXLibrary Set Timeout 0 Launch Javafx Application ${TEST_APPLICATION} Set Screenshot Directory ${OUTPUT_DIR}${/}report-images diff --git a/src/test/robotframework/acceptance/DragRobotTest.robot b/src/test/robotframework/acceptance/DragRobotTest.robot index f876f6b..cd53059 100644 --- a/src/test/robotframework/acceptance/DragRobotTest.robot +++ b/src/test/robotframework/acceptance/DragRobotTest.robot @@ -242,6 +242,7 @@ Drag From + Drop To Using XPath Query *** Keywords *** Setup all tests + Import JavaFXLibrary Set Timeout 0 Launch Javafx Application ${TEST_APPLICATION} Set Screenshot Directory ${OUTPUT_DIR}${/}report-images diff --git a/src/test/robotframework/acceptance/FindTest.robot b/src/test/robotframework/acceptance/FindTest.robot index 7fac8f4..a6a819f 100644 --- a/src/test/robotframework/acceptance/FindTest.robot +++ b/src/test/robotframework/acceptance/FindTest.robot @@ -1,8 +1,8 @@ *** Settings *** Documentation Tests to test javafxlibrary.keywords.AdditionalKeywords.Find related keywords -Resource ../resource.robot +Resource ../resource.robot +Suite Setup Setup All Tests Suite Teardown Teardown all tests -Suite Setup Set Timeout 0 Force Tags set-find *** Variables *** @@ -280,6 +280,10 @@ Change Current Application Launch Javafx Application ${APPLICATION} Set Screenshot Directory ${OUTPUT_DIR}${/}report-images +Setup All Tests + Import JavaFXLibrary + Set Timeout 0 + Teardown all tests Close Javafx Application diff --git a/src/test/robotframework/acceptance/KeyboardRobotTest.robot b/src/test/robotframework/acceptance/KeyboardRobotTest.robot index 684bd00..c317410 100644 --- a/src/test/robotframework/acceptance/KeyboardRobotTest.robot +++ b/src/test/robotframework/acceptance/KeyboardRobotTest.robot @@ -80,6 +80,7 @@ Write special characters *** Keywords *** Setup all tests + Import JavaFXLibrary Set Timeout 0 Launch Javafx Application ${TEST_APPLICATION} Set Screenshot Directory ${OUTPUT_DIR}${/}report-images diff --git a/src/test/robotframework/acceptance/MenuAppTest.robot b/src/test/robotframework/acceptance/MenuAppTest.robot index ffd1736..513cfec 100644 --- a/src/test/robotframework/acceptance/MenuAppTest.robot +++ b/src/test/robotframework/acceptance/MenuAppTest.robot @@ -82,6 +82,7 @@ Combined *** Keywords *** Setup all tests + Import JavaFXLibrary Launch Javafx Application ${TEST_APPLICATION} Set Screenshot Directory ${OUTPUT_DIR}${/}report-images diff --git a/src/test/robotframework/acceptance/MiscTests.robot b/src/test/robotframework/acceptance/MiscTests.robot index 7d9f597..3ca0091 100644 --- a/src/test/robotframework/acceptance/MiscTests.robot +++ b/src/test/robotframework/acceptance/MiscTests.robot @@ -3,7 +3,7 @@ Documentation Tests for AdditionalKeywords Resource ../resource.robot Library Collections Library String -Suite Setup Set Timeout 0 +Suite Setup Setup All Tests Suite Teardown Close Javafx Application *** Variables *** @@ -298,6 +298,10 @@ Set Test Application [Arguments] ${APPLICATION} Run Keyword Unless '${CURRENT_APPLICATION}' == '${APPLICATION}' Change Current Application ${APPLICATION} +Setup All Tests + Import JavaFXLibrary + Set Timeout 0 + Change Current Application [Arguments] ${APPLICATION} Run Keyword Unless '${CURRENT_APPLICATION}' == 'NOT SET' Close Javafx Application diff --git a/src/test/robotframework/acceptance/MoveRobotTest.robot b/src/test/robotframework/acceptance/MoveRobotTest.robot index e33a251..a23fe70 100644 --- a/src/test/robotframework/acceptance/MoveRobotTest.robot +++ b/src/test/robotframework/acceptance/MoveRobotTest.robot @@ -86,6 +86,7 @@ Move To Window *** Keywords *** Setup all tests + Import JavaFXLibrary Set Timeout 0 Launch Javafx Application ${TEST_APPLICATION} Set Screenshot Directory ${OUTPUT_DIR}${/}report-images diff --git a/src/test/robotframework/acceptance/NodeLookupTest.robot b/src/test/robotframework/acceptance/NodeLookupTest.robot index 0252b91..5d4f7a8 100644 --- a/src/test/robotframework/acceptance/NodeLookupTest.robot +++ b/src/test/robotframework/acceptance/NodeLookupTest.robot @@ -49,6 +49,7 @@ Root Node Of Node That Does Not Exist *** Keywords *** Setup all tests + Import JavaFXLibrary Launch Javafx Application ${TEST_APPLICATION} Set Screenshot Directory ${OUTPUT_DIR}${/}report-images diff --git a/src/test/robotframework/acceptance/PointLocationTest.robot b/src/test/robotframework/acceptance/PointLocationTest.robot index a20c33a..4df508e 100644 --- a/src/test/robotframework/acceptance/PointLocationTest.robot +++ b/src/test/robotframework/acceptance/PointLocationTest.robot @@ -170,6 +170,7 @@ Set New Target Position *** Keywords *** Setup all tests + Import JavaFXLibrary Set Timeout 0 Launch Javafx Application ${TEST_APPLICATION} Set Screenshot Directory ${OUTPUT_DIR}${/}report-images diff --git a/src/test/robotframework/acceptance/ScreenCapturingTest.robot b/src/test/robotframework/acceptance/ScreenCapturingTest.robot index 5490c9c..83d3530 100644 --- a/src/test/robotframework/acceptance/ScreenCapturingTest.robot +++ b/src/test/robotframework/acceptance/ScreenCapturingTest.robot @@ -96,6 +96,7 @@ Try To Compare Different Size Images *** Keywords *** Setup all tests + Import JavaFXLibrary Set Timeout 0 Launch Javafx Application ${TEST_APPLICATION} Set Screenshot Directory ${OUTPUT_DIR}${/}report-images diff --git a/src/test/robotframework/acceptance/ScrollRobotTest.robot b/src/test/robotframework/acceptance/ScrollRobotTest.robot index b270b72..495c336 100644 --- a/src/test/robotframework/acceptance/ScrollRobotTest.robot +++ b/src/test/robotframework/acceptance/ScrollRobotTest.robot @@ -66,6 +66,7 @@ Scroll Right *** Keywords *** Setup all tests + Import JavaFXLibrary Launch Javafx Application ${TEST_APPLICATION} Set Screenshot Directory ${OUTPUT_DIR}${/}report-images Set Variables diff --git a/src/test/robotframework/acceptance/ScrollRobotTest2.robot b/src/test/robotframework/acceptance/ScrollRobotTest2.robot index 05dcecc..67ea133 100644 --- a/src/test/robotframework/acceptance/ScrollRobotTest2.robot +++ b/src/test/robotframework/acceptance/ScrollRobotTest2.robot @@ -56,6 +56,7 @@ Scroll Left Once *** Keywords *** Setup all tests + Import JavaFXLibrary Launch Javafx Application ${TEST_APPLICATION} Set Screenshot Directory ${OUTPUT_DIR}${/}report-images Move To id=scrollPane diff --git a/src/test/robotframework/acceptance/SwingApplicationWrapperTest.robot b/src/test/robotframework/acceptance/SwingApplicationWrapperTest.robot index 9873cc5..9d0475e 100644 --- a/src/test/robotframework/acceptance/SwingApplicationWrapperTest.robot +++ b/src/test/robotframework/acceptance/SwingApplicationWrapperTest.robot @@ -1,7 +1,8 @@ *** Settings *** Documentation Tests for handling Swing embedded JavaFX nodes -Resource ../resource.robot +Resource ../resource.robot Force Tags set-embedded +Suite Setup Import JavaFXLibrary *** Testcases *** Swing Embedded JavaFX Click Test diff --git a/src/test/robotframework/acceptance/WindowLookupTest.robot b/src/test/robotframework/acceptance/WindowLookupTest.robot index 90b911b..42df7e2 100644 --- a/src/test/robotframework/acceptance/WindowLookupTest.robot +++ b/src/test/robotframework/acceptance/WindowLookupTest.robot @@ -102,6 +102,7 @@ Activate window Click On ${window_node} Setup all tests + Import JavaFXLibrary Launch Javafx Application ${TEST_APPLICATION} Set Screenshot Directory ${OUTPUT_DIR}${/}report-images diff --git a/src/test/robotframework/acceptance/WindowManagementTest.robot b/src/test/robotframework/acceptance/WindowManagementTest.robot index 4fbefc8..20f9642 100644 --- a/src/test/robotframework/acceptance/WindowManagementTest.robot +++ b/src/test/robotframework/acceptance/WindowManagementTest.robot @@ -61,6 +61,7 @@ Find All From Node *** Keywords *** Setup all tests + Import JavaFXLibrary Launch Javafx Application ${TEST_APPLICATION} Set Screenshot Directory ${OUTPUT_DIR}${/}report-images diff --git a/src/test/robotframework/acceptance/WindowTargetingTest.robot b/src/test/robotframework/acceptance/WindowTargetingTest.robot index dddc3c1..b8c2848 100644 --- a/src/test/robotframework/acceptance/WindowTargetingTest.robot +++ b/src/test/robotframework/acceptance/WindowTargetingTest.robot @@ -55,6 +55,7 @@ Target Window By Node *** Keywords *** Setup all tests + Import JavaFXLibrary Launch Javafx Application ${TEST_APPLICATION} Set Screenshot Directory ${OUTPUT_DIR}${/}report-images diff --git a/src/test/robotframework/resource.robot b/src/test/robotframework/resource.robot index 993c036..fdfd9c1 100644 --- a/src/test/robotframework/resource.robot +++ b/src/test/robotframework/resource.robot @@ -1,3 +1,4 @@ -*** Settings *** -Library JavaFXLibrary -Library Remote http://javafxcompile:8270/ WITH NAME RemoteJavaFXLibrary +*** Keywords *** +Import JavaFXLibrary + Run Keyword If sys.platform.startswith('java') Import Library JavaFXLibrary + ... ELSE Import Library Remote http://javafxcompile:8270/ WITH NAME RemoteJavaFXLibrary From 463670203c7151f854d2310dbee3dc266d6f6ad4 Mon Sep 17 00:00:00 2001 From: Pasi Saikkonen Date: Mon, 27 Aug 2018 11:10:55 +0300 Subject: [PATCH 04/95] Remove animations from TestPointLocation test application --- .../TestPointLocationController.java | 42 ------------------- 1 file changed, 42 deletions(-) diff --git a/src/main/java/javafxlibrary/testapps/controllers/TestPointLocationController.java b/src/main/java/javafxlibrary/testapps/controllers/TestPointLocationController.java index 5a35666..944524d 100644 --- a/src/main/java/javafxlibrary/testapps/controllers/TestPointLocationController.java +++ b/src/main/java/javafxlibrary/testapps/controllers/TestPointLocationController.java @@ -17,71 +17,29 @@ package javafxlibrary.testapps.controllers; -import javafx.animation.*; import javafx.fxml.FXML; import javafx.fxml.Initializable; import javafx.scene.control.Label; -import javafx.scene.effect.BoxBlur; import javafx.scene.input.MouseEvent; -import javafx.util.Duration; import java.net.URL; import java.util.ResourceBundle; public class TestPointLocationController implements Initializable { private @FXML Label locationLabel; - private SequentialTransition textTransition; - private BoxBlur blur; - private double blurAmount = 5.0; @Override public void initialize(URL location, ResourceBundle resources) { locationLabel.setText("- | -"); - textTransition = new SequentialTransition(); - textTransition.getChildren().addAll(zoomIn(), zoomOut()); - blur = new BoxBlur(5.0, 5.0, 1); } public void mouseListener(MouseEvent event) { int x = (int) event.getSceneX(); int y = (int) event.getSceneY(); locationLabel.setText(x + " | " + y); - if(textTransition.getStatus() != Animation.Status.RUNNING) - textTransition.play(); - locationLabel.setEffect(blur); - blurAmount = 5.0; - - AnimationTimer timer = new AnimationTimer() { - @Override - public void handle(long now) { - blurAmount -= 0.01; - locationLabel.setEffect(new BoxBlur(blurAmount, blurAmount, 1)); - if(blurAmount <= 0.0) { - stop(); - } - } - }; - - timer.start(); } public void mouseExitedListener() { locationLabel.setText("- | -"); } - - public ScaleTransition zoomIn() { - ScaleTransition scaleTransition = new ScaleTransition(Duration.millis(10), locationLabel); - scaleTransition.setToX(1.75f); - scaleTransition.setToY(1.75f); - scaleTransition.setCycleCount(1); - return scaleTransition; - } - - public ScaleTransition zoomOut() { - ScaleTransition scaleTransition = new ScaleTransition(Duration.millis(10), locationLabel); - scaleTransition.setToX(1f); - scaleTransition.setToY(1f); - scaleTransition.setCycleCount(1); - return scaleTransition; - } } From 36c2e3fef9746f09faccef712a606c3c62f9f68d Mon Sep 17 00:00:00 2001 From: Pasi Saikkonen Date: Mon, 27 Aug 2018 13:03:40 +0300 Subject: [PATCH 05/95] Enable unit tests --- Dockerfile_build | 2 +- Dockerfile_release | 2 +- pom.xml | 6 +++++ .../java/javafxlibrary/TestFxAdapterTest.java | 21 +++++++++++++--- .../HelperFunctionsTests/CallMethodTest.java | 25 +++++++------------ 5 files changed, 34 insertions(+), 22 deletions(-) diff --git a/Dockerfile_build b/Dockerfile_build index e226d39..9f21730 100644 --- a/Dockerfile_build +++ b/Dockerfile_build @@ -10,7 +10,7 @@ RUN apt-get -qq update && apt-get dist-upgrade -y && apt-get install -qq --no-i && mkdir code COPY . /code WORKDIR /code -RUN mvn package -Dmaven.test.skip=true +RUN mvn package # ENTRYPOINT java -jar /code/target/javafxlibrary-*-SNAPSHOT-jar-with-dependencies.jar FROM ubuntu:16.04 diff --git a/Dockerfile_release b/Dockerfile_release index cf9b761..094df9d 100644 --- a/Dockerfile_release +++ b/Dockerfile_release @@ -11,7 +11,7 @@ RUN apt-get -qq update && apt-get dist-upgrade -y && apt-get install -qq --no-i && mkdir code RUN wget latest https://github.com/eficode/JavaFXLibrary/releases Source code.zip && unzip WORKDIR /code -RUN mvn package -Dmaven.test.skip=true +RUN mvn package FROM ubuntu:16.04 RUN apt-get -qq update && apt-get dist-upgrade -y && apt-get install -qq --no-install-recommends --allow-unauthenticated -y \ diff --git a/pom.xml b/pom.xml index 7f30168..3bd8355 100644 --- a/pom.xml +++ b/pom.xml @@ -322,6 +322,12 @@ testfx-junit 4.0.13-alpha + + org.testfx + openjfx-monocle + 8u76-b04 + test + org.robotframework javalib-core diff --git a/src/test/java/javafxlibrary/TestFxAdapterTest.java b/src/test/java/javafxlibrary/TestFxAdapterTest.java index 0f6e0da..e701f64 100644 --- a/src/test/java/javafxlibrary/TestFxAdapterTest.java +++ b/src/test/java/javafxlibrary/TestFxAdapterTest.java @@ -17,12 +17,14 @@ package javafxlibrary; -import javafx.application.Platform; import javafxlibrary.utils.TestFxAdapter; import mockit.Mocked; import org.junit.Before; +import org.junit.BeforeClass; import org.testfx.api.FxRobotInterface; +import static junit.framework.TestCase.fail; + public abstract class TestFxAdapterTest { public FxRobotInterface getRobot() { return robot; @@ -31,11 +33,22 @@ public FxRobotInterface getRobot() { @Mocked private FxRobotInterface robot; + @BeforeClass + public static void setupTests() { + System.setProperty("testfx.robot", "glass"); + System.setProperty("testfx.headless", "true"); + System.setProperty("prism.order", "sw"); + System.setProperty("prism.text", "t2k"); + try { + org.testfx.api.FxToolkit.registerPrimaryStage(); + } catch (Exception e) { + e.printStackTrace(); + fail("Initialization failed"); + } + } + @Before public void initJfxToolkit() { - new javafx.embed.swing.JFXPanel(); TestFxAdapter.setRobot(robot); - Platform.setImplicitExit(false); } - } diff --git a/src/test/java/javafxlibrary/utils/HelperFunctionsTests/CallMethodTest.java b/src/test/java/javafxlibrary/utils/HelperFunctionsTests/CallMethodTest.java index 7f28967..bbc1d63 100644 --- a/src/test/java/javafxlibrary/utils/HelperFunctionsTests/CallMethodTest.java +++ b/src/test/java/javafxlibrary/utils/HelperFunctionsTests/CallMethodTest.java @@ -1,6 +1,6 @@ package javafxlibrary.utils.HelperFunctionsTests; -import javafx.application.Platform; +import javafx.scene.control.Button; import javafx.stage.Stage; import javafxlibrary.TestFxAdapterTest; import javafxlibrary.exceptions.JavaFXLibraryNonFatalException; @@ -54,27 +54,20 @@ public void callMethod_InSameThread_WithArgs_NoReturnValue() { @Test public void callMethod_InJavaFXThread_WithArgs() { - Stage stage = setupStageInJavaFXThread(); - stage.setTitle("Original title"); - Platform.runLater(() -> stage.show()); - waitForEventsInJavaFXThread(); - - Object[] arguments = {"Changed Title"}; - HelperFunctions.callMethod(stage, "setTitle", arguments, true); + Button button = new Button("Button"); + Object[] arguments = {"Changed"}; + HelperFunctions.callMethod(button, "setText", arguments, true); waitForEventsInJavaFXThread(); - - Assert.assertEquals("Changed Title", stage.getTitle()); - Platform.runLater(() -> stage.close()); + Assert.assertEquals("Changed", button.getText()); } @Test public void callMethod_InJavaFXThread_NoArgs() { - Stage stage = setupStageInJavaFXThread(); - Assert.assertFalse(stage.isShowing()); - HelperFunctions.callMethod(stage, "show", new Object[]{}, true); + Button button = new Button("Button"); + button.setOnAction((e) -> button.setText("Clicked")); + HelperFunctions.callMethod(button, "fire", new Object[]{}, true); waitForEventsInJavaFXThread(); - Assert.assertTrue(stage.isShowing()); - Platform.runLater(() -> stage.close()); + Assert.assertEquals("Clicked", button.getText()); } @Test From 6ef7323b8d7a342bfeeccb0c2158563b9bcfb2b9 Mon Sep 17 00:00:00 2001 From: Pasi Saikkonen Date: Mon, 27 Aug 2018 15:36:07 +0300 Subject: [PATCH 06/95] Fix exception handling in Wait For Events In Fx Application Thread Wait For Events In Fx Application Thread passed even if an exception due to exceeding the timeout was thrown. Exceptions in the anonymous thread are now handled with an UncaughtExceptionHandler, so the keyword will fail when the timeout is exceeded. --- .../AdditionalKeywords/ConvenienceKeywords.java | 10 ++++++++-- src/test/robotframework/acceptance/MiscTests.robot | 2 ++ .../robotframework/acceptance/NodeLookupTest.robot | 9 +++++---- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/main/java/javafxlibrary/keywords/AdditionalKeywords/ConvenienceKeywords.java b/src/main/java/javafxlibrary/keywords/AdditionalKeywords/ConvenienceKeywords.java index 9f79aaa..4461051 100644 --- a/src/main/java/javafxlibrary/keywords/AdditionalKeywords/ConvenienceKeywords.java +++ b/src/main/java/javafxlibrary/keywords/AdditionalKeywords/ConvenienceKeywords.java @@ -1144,8 +1144,9 @@ public static Object getProgressBarValue(Object locator) { + "``timeout`` is the maximum time in seconds that the events will be waited for. If the timeout is " + "exceeded the keyword will fail. Default timeout is 5 seconds.\n\n") @ArgumentNames({ "timeout=" }) - public static void waitForEventsInFxApplicationThread(int timeout) { + public static void waitForEventsInFxApplicationThread(int timeout) throws Throwable { + final Throwable[] threadException = new JavaFXLibraryNonFatalException[1]; try { Semaphore semaphore = new Semaphore(0); Platform.runLater(() -> semaphore.release()); @@ -1165,8 +1166,13 @@ public static void waitForEventsInFxApplicationThread(int timeout) { "Fx Application Thread: " + e.getMessage()); } }); + t.setUncaughtExceptionHandler((thread, e) -> threadException[0] = e); t.start(); semaphore.acquire(); + + if (threadException[0] != null) + throw threadException[0]; + } catch (InterruptedException e) { throw new JavaFXLibraryNonFatalException("Wait For Events in Fx Application Thread was interrupted: " + e.getMessage()); @@ -1174,7 +1180,7 @@ public static void waitForEventsInFxApplicationThread(int timeout) { } @RobotKeywordOverload - public static void waitForEventsInFxApplicationThread() { + public static void waitForEventsInFxApplicationThread() throws Throwable { waitForEventsInFxApplicationThread(HelperFunctions.getWaitUntilTimeout()); } } \ No newline at end of file diff --git a/src/test/robotframework/acceptance/MiscTests.robot b/src/test/robotframework/acceptance/MiscTests.robot index cbca977..30129b1 100644 --- a/src/test/robotframework/acceptance/MiscTests.robot +++ b/src/test/robotframework/acceptance/MiscTests.robot @@ -103,6 +103,7 @@ Set Node Visibility (Call Method With Argument Types That Require Casting) Wait For Events In Fx Application Thread [Tags] smoke demo-set Set Test Application javafxlibrary.testapps.TestBoundsLocation + Set Timeout 3 ${node} Find id=red Call Object Method In Fx Application Thread ${node} changeFillAfterTwoSeconds Wait For Events In Fx Application Thread @@ -113,6 +114,7 @@ Wait For Events In Fx Application Thread Wait For Events In Fx Application Thread ${result} Find id=red Should End With ${result} fill=0xff0000ff] + Set Timeout 0 Find From Node [Tags] smoke diff --git a/src/test/robotframework/acceptance/NodeLookupTest.robot b/src/test/robotframework/acceptance/NodeLookupTest.robot index 2a7abdc..278c1dc 100644 --- a/src/test/robotframework/acceptance/NodeLookupTest.robot +++ b/src/test/robotframework/acceptance/NodeLookupTest.robot @@ -43,14 +43,15 @@ Root Node Of XPath Query Should Be Equal ${ROOT_NODE} ${TARGET} Root Node Of Node That Does Not Exist - [Tags] smoke + [Tags] smoke negative ${MSG} Run Keyword And Expect Error * Get Root Node Of id=non-existent-node-id Should Contain ${MSG} Unable to find any node with query: "id=non-existent-node-id" *** Keywords *** Setup all tests - Launch Javafx Application ${TEST_APPLICATION} - Set Screenshot Directory ${OUTPUT_DIR}${/}report-images + Launch Javafx Application ${TEST_APPLICATION} + Set Screenshot Directory ${OUTPUT_DIR}${/}report-images + Set Timeout 1 Teardown all tests - Close Javafx Application \ No newline at end of file + Close Javafx Application From 5df43ce2ba9ddcc8f154c303f87fc61b6079b2e3 Mon Sep 17 00:00:00 2001 From: Pasi Saikkonen Date: Mon, 27 Aug 2018 16:20:07 +0300 Subject: [PATCH 07/95] Remove awaitility from dependencies --- pom.xml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/pom.xml b/pom.xml index b959089..f913053 100644 --- a/pom.xml +++ b/pom.xml @@ -337,11 +337,6 @@ hamcrest-all 1.3 - - org.awaitility - awaitility - 3.0.0 - com.google.guava guava From f3a4d9643fef69adf8b5236da0586f284980ffbe Mon Sep 17 00:00:00 2001 From: Pasi Saikkonen Date: Mon, 27 Aug 2018 16:25:10 +0300 Subject: [PATCH 08/95] Remove known issues from readme Removed issue can now be found under Github repositorys issues tab --- README.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/README.md b/README.md index 644b8ec..0210fa7 100644 --- a/README.md +++ b/README.md @@ -76,7 +76,3 @@ Linux/OSX command line: java -cp "target/javafxlibrary-.jar" org.robotframework.RobotFramework --include smoke src/test/robotframework/ ``` - -## Known issues - -* If the remote library server and tests are running on the same machine, the server must be restarted between test executions. If the server is not restarted, test applications will launch behind other windows, causing tests to fail when robot is trying to interact with them. From c63d86f6629af095329033e7fa396bd3a6d1323e Mon Sep 17 00:00:00 2001 From: Sami Pesonen Date: Tue, 28 Aug 2018 10:25:56 +0300 Subject: [PATCH 09/95] 0.5.0-SNAPSHOT --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index f913053..94500a8 100644 --- a/pom.xml +++ b/pom.xml @@ -21,7 +21,7 @@ org.robotframework javafxlibrary jar - 0.5.0 + 0.5.0-SNAPSHOT UTF-8 From dfa345527974870b082ef715d4d1f3dd3cb410ab Mon Sep 17 00:00:00 2001 From: Pasi Saikkonen Date: Tue, 28 Aug 2018 11:12:30 +0300 Subject: [PATCH 10/95] Make all convenience keywords non-static --- .../AdditionalKeywords/ConvenienceKeywords.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/javafxlibrary/keywords/AdditionalKeywords/ConvenienceKeywords.java b/src/main/java/javafxlibrary/keywords/AdditionalKeywords/ConvenienceKeywords.java index 4461051..b38c79e 100644 --- a/src/main/java/javafxlibrary/keywords/AdditionalKeywords/ConvenienceKeywords.java +++ b/src/main/java/javafxlibrary/keywords/AdditionalKeywords/ConvenienceKeywords.java @@ -893,7 +893,7 @@ public Double getScrollBarValue(Object locator){ + "``locator`` is either a _query_ or _Object:Node_ for identifying the CheckBox element, see " + "`3. Locating or specifying UI elements`. \n\n") @ArgumentNames({ "locator" }) - public static Boolean getCheckBoxSelection(Object locator) { + public Boolean getCheckBoxSelection(Object locator) { try { CheckBox box = (CheckBox) objectToNode(locator); @@ -908,7 +908,7 @@ public static Boolean getCheckBoxSelection(Object locator) { + "``locator`` is either a _query_ or _Object:Node_ for identifying the RadioButton element, see " + "`3. Locating or specifying UI elements`. \n\n") @ArgumentNames({ "locator" }) - public static Object getSelectedRadioButton(Object locator) { + public Object getSelectedRadioButton(Object locator) { try{ RadioButton rb = (RadioButton)objectToNode(locator); @@ -1130,7 +1130,7 @@ public void selectContextMenuItem(String item){ + "``locator`` is either a _query_ or _Object:Node_ for identifying the ToggleButton element, see " + " `3. Locating or specifying UI elements`. \n\n") @ArgumentNames({ "locator" }) - public static Object getProgressBarValue(Object locator) { + public Object getProgressBarValue(Object locator) { try{ ProgressBar pb = (ProgressBar) objectToNode(locator); return mapObject(pb.getProgress()); @@ -1144,7 +1144,7 @@ public static Object getProgressBarValue(Object locator) { + "``timeout`` is the maximum time in seconds that the events will be waited for. If the timeout is " + "exceeded the keyword will fail. Default timeout is 5 seconds.\n\n") @ArgumentNames({ "timeout=" }) - public static void waitForEventsInFxApplicationThread(int timeout) throws Throwable { + public void waitForEventsInFxApplicationThread(int timeout) { final Throwable[] threadException = new JavaFXLibraryNonFatalException[1]; try { @@ -1171,7 +1171,7 @@ public static void waitForEventsInFxApplicationThread(int timeout) throws Throwa semaphore.acquire(); if (threadException[0] != null) - throw threadException[0]; + throw new JavaFXLibraryNonFatalException(threadException[0].getMessage()); } catch (InterruptedException e) { throw new JavaFXLibraryNonFatalException("Wait For Events in Fx Application Thread was interrupted: " @@ -1180,7 +1180,7 @@ public static void waitForEventsInFxApplicationThread(int timeout) throws Throwa } @RobotKeywordOverload - public static void waitForEventsInFxApplicationThread() throws Throwable { + public void waitForEventsInFxApplicationThread() { waitForEventsInFxApplicationThread(HelperFunctions.getWaitUntilTimeout()); } } \ No newline at end of file From 1abb22d3887cc65e0749e5a0712a353b809f87fa Mon Sep 17 00:00:00 2001 From: Pasi Saikkonen Date: Tue, 28 Aug 2018 11:22:38 +0300 Subject: [PATCH 11/95] Rearrange ConvenienceKeyword unit tests - Changed test directory structure to keywords/AdditionalKeywordsTests/ConvenienceKeywords - Renamed ConvenienceKeywordsTest to DeprecatedFindKeywordsTest - Added unit tests for waitForEventsInFxApplicationThread --- .../DeprecatedFindKeywordsTest.java} | 31 ++++---- ...aitForEventsInFxApplicationThreadTest.java | 72 +++++++++++++++++++ 2 files changed, 86 insertions(+), 17 deletions(-) rename src/test/java/javafxlibrary/keywords/{AdditionalKeywords/ConvenienceKeywordsTest.java => AdditionalKeywordsTests/ConvenienceKeywords/DeprecatedFindKeywordsTest.java} (77%) create mode 100644 src/test/java/javafxlibrary/keywords/AdditionalKeywordsTests/ConvenienceKeywords/WaitForEventsInFxApplicationThreadTest.java diff --git a/src/test/java/javafxlibrary/keywords/AdditionalKeywords/ConvenienceKeywordsTest.java b/src/test/java/javafxlibrary/keywords/AdditionalKeywordsTests/ConvenienceKeywords/DeprecatedFindKeywordsTest.java similarity index 77% rename from src/test/java/javafxlibrary/keywords/AdditionalKeywords/ConvenienceKeywordsTest.java rename to src/test/java/javafxlibrary/keywords/AdditionalKeywordsTests/ConvenienceKeywords/DeprecatedFindKeywordsTest.java index d804050..515bedc 100644 --- a/src/test/java/javafxlibrary/keywords/AdditionalKeywords/ConvenienceKeywordsTest.java +++ b/src/test/java/javafxlibrary/keywords/AdditionalKeywordsTests/ConvenienceKeywords/DeprecatedFindKeywordsTest.java @@ -15,30 +15,36 @@ * limitations under the License. */ -package javafxlibrary.keywords.AdditionalKeywords; +package javafxlibrary.keywords.AdditionalKeywordsTests.ConvenienceKeywords; import java.util.List; import com.google.common.collect.ImmutableSet; import javafx.css.PseudoClass; import javafx.scene.control.Button; import javafxlibrary.TestFxAdapterTest; -import javafxlibrary.exceptions.JavaFXLibraryNonFatalException; +import javafxlibrary.keywords.AdditionalKeywords.ConvenienceKeywords; import javafxlibrary.utils.HelperFunctions; import mockit.Expectations; import mockit.Mocked; import org.junit.Assert; import org.junit.Before; +import org.junit.BeforeClass; import org.junit.Test; import org.testfx.service.query.NodeQuery; -public class ConvenienceKeywordsTest extends TestFxAdapterTest { +public class DeprecatedFindKeywordsTest extends TestFxAdapterTest { @Mocked NodeQuery rootQuery; private Button button; private Button button2; - private ConvenienceKeywords keywords = new ConvenienceKeywords(); + private static ConvenienceKeywords keywords; + + @BeforeClass + public static void setupAllTests() { + keywords = new ConvenienceKeywords(); + } @Before public void setup() { @@ -57,7 +63,6 @@ public void setup() { @Test public void findAllWithPseudoClass() { expectTwoButtonsFromNodeQuery(); - List allWithPseudoClass = keywords.findAllWithPseudoClass("rootId", "selected"); Assert.assertEquals(HelperFunctions.mapObject(button), allWithPseudoClass.get(0)); } @@ -65,12 +70,8 @@ public void findAllWithPseudoClass() { @Test public void findNoPseudoClasses() { expectTwoButtonsFromNodeQuery(); - try { - List hits = keywords.findAllWithPseudoClass("rootId", "something"); - Assert.assertEquals(0, hits.size()); - } catch (JavaFXLibraryNonFatalException e) { - - } + List hits = keywords.findAllWithPseudoClass("rootId", "something"); + Assert.assertEquals(0, hits.size()); } @Test @@ -81,12 +82,8 @@ public void findNoNodes() { result = ImmutableSet.of(); } }; - try { - List hits = keywords.findAllWithPseudoClass("rootId", "something"); - Assert.assertEquals(0, hits.size()); - } catch (JavaFXLibraryNonFatalException e) { - - } + List hits = keywords.findAllWithPseudoClass("rootId", "something"); + Assert.assertEquals(0, hits.size()); } private void expectTwoButtonsFromNodeQuery() { diff --git a/src/test/java/javafxlibrary/keywords/AdditionalKeywordsTests/ConvenienceKeywords/WaitForEventsInFxApplicationThreadTest.java b/src/test/java/javafxlibrary/keywords/AdditionalKeywordsTests/ConvenienceKeywords/WaitForEventsInFxApplicationThreadTest.java new file mode 100644 index 0000000..aca3d8e --- /dev/null +++ b/src/test/java/javafxlibrary/keywords/AdditionalKeywordsTests/ConvenienceKeywords/WaitForEventsInFxApplicationThreadTest.java @@ -0,0 +1,72 @@ +/* + * Copyright 2017-2018 Eficode Oy + * Copyright 2018- Robot Framework Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package javafxlibrary.keywords.AdditionalKeywordsTests.ConvenienceKeywords; + +import javafx.application.Platform; +import javafx.scene.control.Button; +import javafxlibrary.TestFxAdapterTest; +import javafxlibrary.exceptions.JavaFXLibraryNonFatalException; +import javafxlibrary.keywords.AdditionalKeywords.ConvenienceKeywords; +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; + +public class WaitForEventsInFxApplicationThreadTest extends TestFxAdapterTest { + + @Rule + public ExpectedException thrown = ExpectedException.none(); + + private static ConvenienceKeywords keywords; + + @BeforeClass + public static void setupTests() { + keywords = new ConvenienceKeywords(); + } + + @Test + public void waitForEventsInFxApplicationThread() { + Button b = createDelayedButton(2000); + Platform.runLater(() -> b.fire()); + keywords.waitForEventsInFxApplicationThread(2); + Assert.assertEquals("ChangedText", b.getText()); + } + + @Test + public void waitForEventsInFxApplicationThread_TimeoutExceeded() { + thrown.expect(JavaFXLibraryNonFatalException.class); + thrown.expectMessage("Events did not finish within the given timeout of 1 seconds."); + Button b = createDelayedButton(3000); + Platform.runLater(() -> b.fire()); + keywords.waitForEventsInFxApplicationThread(1); + } + + private Button createDelayedButton(int timeout) { + Button b = new Button("OriginalText"); + b.setOnAction((e) -> { + try { + Thread.sleep(timeout); + b.setText("ChangedText"); + } catch (InterruptedException ie) { + ie.printStackTrace(); + } + }); + return b; + } +} From 290d4eb4f408a2438f4649a6418793dafe554500 Mon Sep 17 00:00:00 2001 From: "Hoisko Sakari.M 10802213" Date: Tue, 28 Aug 2018 11:45:43 +0300 Subject: [PATCH 12/95] Fix to jar name in dockerfile --- Dockerfile_build | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile_build b/Dockerfile_build index 9f21730..e889d28 100644 --- a/Dockerfile_build +++ b/Dockerfile_build @@ -18,6 +18,6 @@ RUN apt-get -qq update && apt-get dist-upgrade -y && apt-get install -qq --no-i openjdk-8-jre \ openjfx \ && rm -rf /var/lib/apt/lists/* -COPY --from=builder /code/target/javafxlibrary-*-SNAPSHOT-jar-with-dependencies.jar . +COPY --from=builder /code/target/javafxlibrary-*-jar-with-dependencies.jar . EXPOSE 8270 -ENTRYPOINT java -jar javafxlibrary-*-SNAPSHOT-jar-with-dependencies.jar +ENTRYPOINT java -jar javafxlibrary-*-jar-with-dependencies.jar From ebefad6e16a7dc782e34f6a589e461565d2dd886 Mon Sep 17 00:00:00 2001 From: Pasi Saikkonen Date: Tue, 28 Aug 2018 12:16:14 +0300 Subject: [PATCH 13/95] Rename BeforeClass methods Setup method of WaitForEventsInFxApplicationThreadTest had the same name as its super class TestFxAdapterTest, effectively hiding the setup method of its base class. Unit tests then failed, because initialization of the JavaFXToolkit is done in TestFxAdapterTest. --- .../ConvenienceKeywords/DeprecatedFindKeywordsTest.java | 2 +- .../WaitForEventsInFxApplicationThreadTest.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/java/javafxlibrary/keywords/AdditionalKeywordsTests/ConvenienceKeywords/DeprecatedFindKeywordsTest.java b/src/test/java/javafxlibrary/keywords/AdditionalKeywordsTests/ConvenienceKeywords/DeprecatedFindKeywordsTest.java index 515bedc..02ddebf 100644 --- a/src/test/java/javafxlibrary/keywords/AdditionalKeywordsTests/ConvenienceKeywords/DeprecatedFindKeywordsTest.java +++ b/src/test/java/javafxlibrary/keywords/AdditionalKeywordsTests/ConvenienceKeywords/DeprecatedFindKeywordsTest.java @@ -42,7 +42,7 @@ public class DeprecatedFindKeywordsTest extends TestFxAdapterTest { private static ConvenienceKeywords keywords; @BeforeClass - public static void setupAllTests() { + public static void setupKeywords() { keywords = new ConvenienceKeywords(); } diff --git a/src/test/java/javafxlibrary/keywords/AdditionalKeywordsTests/ConvenienceKeywords/WaitForEventsInFxApplicationThreadTest.java b/src/test/java/javafxlibrary/keywords/AdditionalKeywordsTests/ConvenienceKeywords/WaitForEventsInFxApplicationThreadTest.java index aca3d8e..7844cce 100644 --- a/src/test/java/javafxlibrary/keywords/AdditionalKeywordsTests/ConvenienceKeywords/WaitForEventsInFxApplicationThreadTest.java +++ b/src/test/java/javafxlibrary/keywords/AdditionalKeywordsTests/ConvenienceKeywords/WaitForEventsInFxApplicationThreadTest.java @@ -36,7 +36,7 @@ public class WaitForEventsInFxApplicationThreadTest extends TestFxAdapterTest { private static ConvenienceKeywords keywords; @BeforeClass - public static void setupTests() { + public static void setupKeywords() { keywords = new ConvenienceKeywords(); } From 4a3e27ce2abb257c26c42e76fab9971eead4f900 Mon Sep 17 00:00:00 2001 From: Pasi Saikkonen Date: Tue, 28 Aug 2018 13:19:15 +0300 Subject: [PATCH 14/95] Close test application when test fails Test applications were left open when any of previous keywords failed, causing other test suites dealing with window indexes to fail as well. Random failures in test cases occurred when the embedded window couldn't update fast enough. Each call to text value shouls be is now wrapped with Wait Until Keyword Succeeds to make tests more reliable on slower environments. --- .../SwingApplicationWrapperTest.robot | 30 ++++++++++--------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/src/test/robotframework/acceptance/SwingApplicationWrapperTest.robot b/src/test/robotframework/acceptance/SwingApplicationWrapperTest.robot index 9d0475e..b7463ba 100644 --- a/src/test/robotframework/acceptance/SwingApplicationWrapperTest.robot +++ b/src/test/robotframework/acceptance/SwingApplicationWrapperTest.robot @@ -3,37 +3,39 @@ Documentation Tests for handling Swing embedded JavaFX nodes Resource ../resource.robot Force Tags set-embedded Suite Setup Import JavaFXLibrary +Test Teardown Close Test Application *** Testcases *** Swing Embedded JavaFX Click Test - [Tags] smoke demo-set - Launch Swing Application javafxlibrary.testapps.SwingApplication - Wait Until Keyword Succeeds 15 sec 250ms Find css=.button failIfNotFound=True - ${colors} Create List 0xdc143cff 0x00fa9aff 0xee82eeff 0xffff00ff 0x00ffffff - Text Value Should Be Swing Embedded JavaFX - :FOR ${I} IN RANGE 0 5 - \ Click On css=.button - \ Text Value Should Be @{colors}[${i}] - Close Swing Application + [Tags] smoke demo-set + Launch Swing Application javafxlibrary.testapps.SwingApplication + Wait Until Keyword Succeeds 15 sec 250ms Find css=.button failIfNotFound=True + ${colors} Create List 0xdc143cff 0x00fa9aff 0xee82eeff 0xffff00ff 0x00ffffff + Text Value Should Be Swing Embedded JavaFX + :FOR ${I} IN RANGE 0 5 + \ Click On css=.button + \ Wait Until Keyword Succeeds 3 sec 250ms Text Value Should Be @{colors}[${i}] Swing Embedded JavaFX Type Test [Tags] smoke Launch Swing Application javafxlibrary.testapps.SwingApplication Wait Until Keyword Succeeds 15 sec 250ms Find id=textField failIfNotFound=True Write To id=textField JavaFXLibrary - Text Value Should Be JavaFXLibrary - Close Swing Application + Wait Until Keyword Succeeds 3 sec 250ms Text Value Should Be JavaFXLibrary Launch Swing Application Using External Wrapper Class [Tags] smoke Launch Javafx Application javafxlibrary.testapps.SwingApplicationWrapper - Wait Until Keyword Succeeds 15 sec 250ms Find id=textField failIfNotFound=True + Wait Until Keyword Succeeds 15 sec 250ms Find id=textField failIfNotFound=True Write To id=textField JavaFXLibrary - Text Value Should Be JavaFXLibrary - Close Javafx Application + Wait Until Keyword Succeeds 3 sec 250ms Text Value Should Be JavaFXLibrary *** Keywords *** Text Value Should Be [Arguments] ${value} ${text} Get Node Text id=textValue Should Be Equal ${text} ${value} + +Close Test Application + Run Keyword If '${TEST NAME}' == 'Launch Swing Application Using External Wrapper Class' Close Javafx Application + ... ELSE Close Swing Application From 5e6eefa7255ac72714dd16b320b317eb752f6ec7 Mon Sep 17 00:00:00 2001 From: Pasi Saikkonen Date: Tue, 28 Aug 2018 14:52:51 +0300 Subject: [PATCH 15/95] Prevent logging the same message multiple times in runKeyword --- src/main/java/JavaFXLibrary.java | 6 ++- .../java/javafxlibrary/utils/RobotLog.java | 43 ++++++++++++++++--- 2 files changed, 43 insertions(+), 6 deletions(-) diff --git a/src/main/java/JavaFXLibrary.java b/src/main/java/JavaFXLibrary.java index 2949350..740f7c6 100644 --- a/src/main/java/JavaFXLibrary.java +++ b/src/main/java/JavaFXLibrary.java @@ -81,6 +81,7 @@ public Object runKeyword(String keywordName, Object[] args) { AtomicReference retExcep = new AtomicReference<>(); try { + RobotLog.ignoreDuplicates(); // timeout + 500 ms so that underlying timeout has a chance to expire first WaitForAsyncUtils.waitFor(getWaitUntilTimeout(TimeUnit.MILLISECONDS) + 500, TimeUnit.MILLISECONDS, () -> { @@ -100,6 +101,7 @@ public Object runKeyword(String keywordName, Object[] args) { } }); } catch (TimeoutException te) { + RobotLog.reset(); RuntimeException e = retExcep.get(); runOnFailure.runOnFailure(); @@ -113,10 +115,12 @@ public Object runKeyword(String keywordName, Object[] args) { RobotLog.trace("JavaFXLibrary: Caught JavaFXLibrary RUNTIME exception: \n" + Throwables.getStackTraceAsString(e)); throw e; } - } catch (JavaFXLibraryTimeoutException jfxte){ + } catch (JavaFXLibraryTimeoutException jfxte) { + RobotLog.reset(); RobotLog.trace("JavaFXLibrary: Caught JavaFXLibrary TIMEOUT exception: \n" + Throwables.getStackTraceAsString(jfxte)); throw jfxte; } + RobotLog.reset(); return retval.get(); } diff --git a/src/main/java/javafxlibrary/utils/RobotLog.java b/src/main/java/javafxlibrary/utils/RobotLog.java index be20c59..1ca9948 100644 --- a/src/main/java/javafxlibrary/utils/RobotLog.java +++ b/src/main/java/javafxlibrary/utils/RobotLog.java @@ -1,24 +1,57 @@ package javafxlibrary.utils; +import java.util.LinkedList; + public class RobotLog { + private static boolean ignoreDuplicates = false; + private static LinkedList loggedMessages = new LinkedList<>(); + + + public static void ignoreDuplicates() { + ignoreDuplicates = true; + } + + public static void reset() { + ignoreDuplicates = false; + loggedMessages.clear(); + } + public static void info(String message) { - System.out.println("*INFO* " + message); + if (shouldLogMessage(message)) + System.out.println("*INFO* " + message); } public static void debug(String message) { - System.out.println("*DEBUG* " + message); + if (shouldLogMessage(message)) + System.out.println("*DEBUG* " + message); } public static void trace(String message) { - System.out.println("*TRACE* " + message); + if (shouldLogMessage(message)) + System.out.println("*TRACE* " + message); } public static void warn(String message) { - System.out.println("*WARN* " + message); + if (shouldLogMessage(message)) + System.out.println("*WARN* " + message); } public static void error(String message) { - System.out.println("*ERROR* " + message); + if (shouldLogMessage(message)) + System.out.println("*ERROR* " + message); + } + + private static boolean shouldLogMessage(String message) { + if (ignoreDuplicates) { + if (loggedMessages.contains(message)) { + return false; + } else { + loggedMessages.add(message); + return true; + } + } else { + return true; + } } } From a06268d10ff540775af7f4aa789420b276cb1e1f Mon Sep 17 00:00:00 2001 From: "Hoisko Sakari.M 10802213" Date: Tue, 28 Aug 2018 15:42:49 +0300 Subject: [PATCH 16/95] Added local execution support, use test.sh script with local/remote/all parameters to execution --- Dockerfile_build | 5 ++- docker-compose.yml | 5 +++ docker/robot-javafx-demo/Dockerfile | 3 ++ docker/robot-javafx-demo/test.sh | 59 +++++++++++++++++++++++++++++ entrypoint_build.sh | 4 ++ 5 files changed, 74 insertions(+), 2 deletions(-) create mode 100644 docker/robot-javafx-demo/test.sh create mode 100644 entrypoint_build.sh diff --git a/Dockerfile_build b/Dockerfile_build index e889d28..502511e 100644 --- a/Dockerfile_build +++ b/Dockerfile_build @@ -18,6 +18,7 @@ RUN apt-get -qq update && apt-get dist-upgrade -y && apt-get install -qq --no-i openjdk-8-jre \ openjfx \ && rm -rf /var/lib/apt/lists/* -COPY --from=builder /code/target/javafxlibrary-*-jar-with-dependencies.jar . +COPY --from=builder /code/target/javafxlibrary-*-jar-with-dependencies.jar /. EXPOSE 8270 -ENTRYPOINT java -jar javafxlibrary-*-jar-with-dependencies.jar +COPY entrypoint_build.sh /. +ENTRYPOINT /entrypoint_build.sh diff --git a/docker-compose.yml b/docker-compose.yml index 493ae8a..3a05fbe 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -9,6 +9,8 @@ services: volumes: - './src/test/robotframework/:/robot' - screen-thing:/tmp/.X11-unix + - './src/:/src' # ScreenCapturingTest.robot require this. + - javafxbinaryshare:/javafxbinary networks: - testapp @@ -20,8 +22,10 @@ services: networks: - testapp volumes: + - './src/test/robotframework/:/robot' # Screen capures are saved to here "hack until remote usage copy photos to results folder" - './src/:/src' # ScreenCapturingTest.robot require this. - screen-thing:/tmp/.X11-unix + - javafxbinaryshare:/javafxbinary environment: - DISPLAY=:20.0 @@ -44,3 +48,4 @@ networks: testapp: volumes: screen-thing: + javafxbinaryshare: diff --git a/docker/robot-javafx-demo/Dockerfile b/docker/robot-javafx-demo/Dockerfile index 4dd923c..eafe4ac 100644 --- a/docker/robot-javafx-demo/Dockerfile +++ b/docker/robot-javafx-demo/Dockerfile @@ -17,6 +17,8 @@ RUN apt-get -qq update && apt-get dist-upgrade -y && apt-get install -qq --no-i wget \ xvfb \ xorg \ + openjdk-8-jre \ + openjfx \ && apt-get clean && rm -rf /var/lib/apt/lists/* RUN pip install --no-cache-dir \ @@ -25,6 +27,7 @@ RUN pip install --no-cache-dir \ RUN mkdir ~/.vnc RUN x11vnc -storepasswd 1234 ~/.vnc/passwd COPY entrypoint.sh /entrypoint.sh +COPY test.sh /bin/test.sh EXPOSE 5900 ENTRYPOINT ["x11vnc", "-create", "-forever", "-env", "FD_PROG=/entrypoint.sh", "-env", "X11VNC_CREATE_GEOM=${1:-1024x768x16}", "-usepw"] diff --git a/docker/robot-javafx-demo/test.sh b/docker/robot-javafx-demo/test.sh new file mode 100644 index 0000000..780e9dd --- /dev/null +++ b/docker/robot-javafx-demo/test.sh @@ -0,0 +1,59 @@ +#!/bin/bash +EXIT_VALUE=0 + +function local() { + echo "INFO: Local execution:" + file=$(ls -1 /javafxbinary/javafxlibrary-*-jar-with-dependencies.jar) + java -cp "${file}" org.robotframework.RobotFramework -d /robot/results/local --include smoke $@ /robot/acceptance +# $@ #just to testing script + if [[ "$?" != "0" ]]; then + EXIT_VALUE=$((EXIT_VALUE+1)) + fi +} + +function remote() { + echo "INFO: Remote execution:" + robot -d /robot/results/remote --include smoke $@ /robot/acceptance +# $@ #just to testing script + if [[ "$?" != "0" ]]; then + EXIT_VALUE=$((EXIT_VALUE+2)) + fi +} + + +case $1 in + local | LOCAL ) + shift + local $@ + ;; + remote | REMOTE | demo | DEMO) + shift + remote $@ + ;; + "" | all | ALL ) + echo "INFO: All execution:" + shift + local $@ + remote $@ + ;; + * ) + echo "ERROR:$@ is not supported parameter" + EXIT_VALUE=$((EXIT_VALUE+4)) + ;; +esac +echo "*************************************************" +case ${EXIT_VALUE} in + 0 ) + echo "INFO: All fine, tests PASS" + ;; + 1 ) + echo "ERROR: Local library tests fail" + ;; + 2 ) + echo "ERROR: Remote library tests fail" + ;; + 3 ) + echo "ERROR: Local and Remote library tests fails" + ;; +esac +exit ${EXIT_VALUE} diff --git a/entrypoint_build.sh b/entrypoint_build.sh new file mode 100644 index 0000000..5b31278 --- /dev/null +++ b/entrypoint_build.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash +rm -rvf /javafxbinary/* +cp -vf /javafxlibrary-*-jar-with-dependencies.jar /javafxbinary/. +java -jar /javafxlibrary-*-jar-with-dependencies.jar From 6c753808a52aceefc52f4cdd935600d26c5d0381 Mon Sep 17 00:00:00 2001 From: "Hoisko Sakari.M 10802213" Date: Tue, 28 Aug 2018 16:31:16 +0300 Subject: [PATCH 17/95] Added suppor to robot parameters --- README.md | 14 ++++++++++---- docker/robot-javafx-demo/test.sh | 6 +++++- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index b44344a..de0c324 100644 --- a/README.md +++ b/README.md @@ -84,11 +84,17 @@ java -cp "target/javafxlibrary-.jar" org.robotframework.RobotFramework * Docker-compose: https://docs.docker.com/compose/install/ * VNC port: vnc://localhost:5900 -### Running the demo +### Running the demo with testing env 1. Build & Start Dockerized Environment: `docker-compose up -d robot-framework javafxcompile` 2. Take VNC connection to: vnc://:5900 3. Password is: 1234 4. Open shell by right clicking in VNC desktop and selecting Applications > Shells > Bash -5. Execute tests: `robot --include smoke -d /robot/results /robot/acceptance` - -Remote server and tests run in separate containers, and their GUIs are forwarded to the VNC container. +5. Execute tests: `test.sh` + +FYI: +Single testcase execution in locale and remote (replace spaces with _ ):
+`test.sh all '--include tag_name' '-t test_case_name'`
+Single suite execution in locale and remote (replace spaces with _ ):
+`test.sh all '--include tag_name' '-s suite_name'` +
+NOTE: smoke tag is default included. diff --git a/docker/robot-javafx-demo/test.sh b/docker/robot-javafx-demo/test.sh index 780e9dd..b7572bc 100644 --- a/docker/robot-javafx-demo/test.sh +++ b/docker/robot-javafx-demo/test.sh @@ -2,9 +2,10 @@ EXIT_VALUE=0 function local() { + echo "**********************" echo "INFO: Local execution:" file=$(ls -1 /javafxbinary/javafxlibrary-*-jar-with-dependencies.jar) - java -cp "${file}" org.robotframework.RobotFramework -d /robot/results/local --include smoke $@ /robot/acceptance + java -cp ${file} org.robotframework.RobotFramework -d /robot/results/local --include smoke $@ /robot/acceptance # $@ #just to testing script if [[ "$?" != "0" ]]; then EXIT_VALUE=$((EXIT_VALUE+1)) @@ -12,6 +13,7 @@ function local() { } function remote() { + echo "***********************" echo "INFO: Remote execution:" robot -d /robot/results/remote --include smoke $@ /robot/acceptance # $@ #just to testing script @@ -38,6 +40,8 @@ case $1 in ;; * ) echo "ERROR:$@ is not supported parameter" + echo "Supported parameters: local, remote, all, demo ...and same with capitals" + echo "From README.md more info about usage" EXIT_VALUE=$((EXIT_VALUE+4)) ;; esac From 67e0c906b3e2f1e190e27e526d47da309ee230be Mon Sep 17 00:00:00 2001 From: "Hoisko Sakari.M 10802213" Date: Tue, 28 Aug 2018 17:07:42 +0300 Subject: [PATCH 18/95] Added needed privialedges to run --- Dockerfile_build | 6 +++--- docker/robot-javafx-demo/Dockerfile | 3 +-- entrypoint_build.sh | 1 + 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Dockerfile_build b/Dockerfile_build index 502511e..c472fa7 100644 --- a/Dockerfile_build +++ b/Dockerfile_build @@ -14,11 +14,11 @@ RUN mvn package # ENTRYPOINT java -jar /code/target/javafxlibrary-*-SNAPSHOT-jar-with-dependencies.jar FROM ubuntu:16.04 +COPY --from=builder /code/target/javafxlibrary-*-SNAPSHOT-jar-with-dependencies.jar /. +COPY entrypoint_build.sh /. RUN apt-get -qq update && apt-get dist-upgrade -y && apt-get install -qq --no-install-recommends --allow-unauthenticated -y \ openjdk-8-jre \ openjfx \ - && rm -rf /var/lib/apt/lists/* -COPY --from=builder /code/target/javafxlibrary-*-jar-with-dependencies.jar /. + && rm -rf /var/lib/apt/lists/* && chmod 555 /javafxlibrary-*-jar-with-dependencies.jar /entrypoint_build.sh EXPOSE 8270 -COPY entrypoint_build.sh /. ENTRYPOINT /entrypoint_build.sh diff --git a/docker/robot-javafx-demo/Dockerfile b/docker/robot-javafx-demo/Dockerfile index eafe4ac..69d6234 100644 --- a/docker/robot-javafx-demo/Dockerfile +++ b/docker/robot-javafx-demo/Dockerfile @@ -24,10 +24,9 @@ RUN apt-get -qq update && apt-get dist-upgrade -y && apt-get install -qq --no-i RUN pip install --no-cache-dir \ robotframework -RUN mkdir ~/.vnc -RUN x11vnc -storepasswd 1234 ~/.vnc/passwd COPY entrypoint.sh /entrypoint.sh COPY test.sh /bin/test.sh +RUN mkdir ~/.vnc && x11vnc -storepasswd 1234 ~/.vnc/passwd && chmod 555 /entrypoint.sh /bin/test.sh EXPOSE 5900 ENTRYPOINT ["x11vnc", "-create", "-forever", "-env", "FD_PROG=/entrypoint.sh", "-env", "X11VNC_CREATE_GEOM=${1:-1024x768x16}", "-usepw"] diff --git a/entrypoint_build.sh b/entrypoint_build.sh index 5b31278..1c61959 100644 --- a/entrypoint_build.sh +++ b/entrypoint_build.sh @@ -1,4 +1,5 @@ #!/usr/bin/env bash rm -rvf /javafxbinary/* cp -vf /javafxlibrary-*-jar-with-dependencies.jar /javafxbinary/. +chmod 555 /javafxbinary/javafxlibrary-*-jar-with-dependencies.jar java -jar /javafxlibrary-*-jar-with-dependencies.jar From 145c71afa8b25bd68b81bfe62185ceac3f685e8a Mon Sep 17 00:00:00 2001 From: "Hoisko Sakari.M 10802213" Date: Thu, 30 Aug 2018 10:22:55 +0300 Subject: [PATCH 19/95] Taked noVNC to use, just browser needed to remote desctop connection --- README.md | 18 ++++++++---------- docker-compose.yml | 7 +++++-- docker/robot-javafx-demo/Dockerfile | 13 +++++++------ 3 files changed, 20 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index de0c324..4ce8b0f 100644 --- a/README.md +++ b/README.md @@ -79,22 +79,20 @@ java -cp "target/javafxlibrary-.jar" org.robotframework.RobotFramework ## Remote library demo with Docker ### Requirements: -* VNC viewer e.g. https://www.realvnc.com/en/connect/download/viewer/ * Docker CE: https://docs.docker.com/install/ * Docker-compose: https://docs.docker.com/compose/install/ -* VNC port: vnc://localhost:5900 +* Port 80 is free in your machine ### Running the demo with testing env 1. Build & Start Dockerized Environment: `docker-compose up -d robot-framework javafxcompile` -2. Take VNC connection to: vnc://:5900 -3. Password is: 1234 -4. Open shell by right clicking in VNC desktop and selecting Applications > Shells > Bash -5. Execute tests: `test.sh` +2. Open browser to +3. Open xterm from start menu > System tools > xterm +4. Execute tests in xterm window: `test.sh` FYI: -Single testcase execution in locale and remote (replace spaces with _ ):
-`test.sh all '--include tag_name' '-t test_case_name'`
-Single suite execution in locale and remote (replace spaces with _ ):
-`test.sh all '--include tag_name' '-s suite_name'` +Single testcase execution in locale|remote|all (replace spaces in testcase name with _ ):
+`test.sh locale '--include tag_name' '-t test_case_name'`
+Single suite execution in locale and remote (replace spacesin test suite name with _ ):
+`test.sh remote '--include tag_name' '-s suite_name'`
NOTE: smoke tag is default included. diff --git a/docker-compose.yml b/docker-compose.yml index 3a05fbe..495f717 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,7 +5,8 @@ services: build: context: ./docker/robot-javafx-demo ports: - - '5900:5900' + #- '5900:5900' + - '80:80' volumes: - './src/test/robotframework/:/robot' - screen-thing:/tmp/.X11-unix @@ -13,6 +14,8 @@ services: - javafxbinaryshare:/javafxbinary networks: - testapp + environment: + - RESOLUTION=1027x768 javafxcompile: build: @@ -27,7 +30,7 @@ services: - screen-thing:/tmp/.X11-unix - javafxbinaryshare:/javafxbinary environment: - - DISPLAY=:20.0 + - DISPLAY=:1 # javafxrelease: # build: diff --git a/docker/robot-javafx-demo/Dockerfile b/docker/robot-javafx-demo/Dockerfile index 69d6234..9326a61 100644 --- a/docker/robot-javafx-demo/Dockerfile +++ b/docker/robot-javafx-demo/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:16.04 +FROM dorowu/ubuntu-desktop-lxde-vnc ENV DEBIAN_FRONTEND noninteractive @@ -24,9 +24,10 @@ RUN apt-get -qq update && apt-get dist-upgrade -y && apt-get install -qq --no-i RUN pip install --no-cache-dir \ robotframework -COPY entrypoint.sh /entrypoint.sh +#COPY entrypoint.sh /entrypoint.sh COPY test.sh /bin/test.sh -RUN mkdir ~/.vnc && x11vnc -storepasswd 1234 ~/.vnc/passwd && chmod 555 /entrypoint.sh /bin/test.sh -EXPOSE 5900 - -ENTRYPOINT ["x11vnc", "-create", "-forever", "-env", "FD_PROG=/entrypoint.sh", "-env", "X11VNC_CREATE_GEOM=${1:-1024x768x16}", "-usepw"] +RUN chmod 555 /bin/test.sh +#RUN mkdir ~/.vnc && x11vnc -storepasswd 1234 ~/.vnc/passwd && chmod 555 /entrypoint.sh /bin/test.sh +EXPOSE 5900 6080 +#ENTRYPOINT ["x11vnc", "-create", "-forever", "-env", "FD_PROG=/entrypoint.sh", "-env", "X11VNC_CREATE_GEOM=${1:-1024x768x16}", "-usepw"] +ENTRYPOINT ["/startup.sh"] From b6f612e359852fd8099a53038095a7e6dfdde55d Mon Sep 17 00:00:00 2001 From: Pasi Saikkonen Date: Thu, 30 Aug 2018 12:18:59 +0300 Subject: [PATCH 20/95] Use /RPC2 as remote library path --- README.md | 6 +++--- src/main/java/JavaFXLibrary.java | 2 +- src/test/robotframework/resource.robot | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index de0c324..96e7932 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ See keyword [documentation](https://eficode.github.io/JavaFXLibrary/javafxlibrar Import the library: ``` ***Settings*** -Library Remote http://localhost:8270/ WITH NAME JavaFXLibrary +Library Remote http://127.0.0.1:8270 WITH NAME JavaFXLibrary ``` Now the keywords can be used as usual: ``` @@ -46,8 +46,8 @@ In case of duplicate keywords(multiple keywords found with same name) use e.g. ` If you need to use the Remote library multiple times in a test suite, or just want to give it a more descriptive name, you can import it using the WITH NAME syntax. ``` ***Settings*** -Library Remote http://localhost:8270/ WITH NAME client1 -Library Remote http://localhost:8272/ WITH NAME client2 +Library Remote http://127.0.0.1:8270 WITH NAME client1 +Library Remote http://127.0.0.1:8270 WITH NAME client2 ``` Now the keywords can be used as `client1.List Windows` and `client2.List Windows` diff --git a/src/main/java/JavaFXLibrary.java b/src/main/java/JavaFXLibrary.java index 740f7c6..da646a5 100644 --- a/src/main/java/JavaFXLibrary.java +++ b/src/main/java/JavaFXLibrary.java @@ -155,7 +155,7 @@ public static void main(String[] args) throws Exception { JavaFXLibraryRemoteServer.configureLogging(); System.out.println("-------------------- JavaFXLibrary --------------------- "); RemoteServer server = new JavaFXLibraryRemoteServer(); - server.putLibrary("/", new JavaFXLibrary()); + server.putLibrary("/RPC2", new JavaFXLibrary()); int port = 8270; InetAddress ipAddr = InetAddress.getLocalHost(); diff --git a/src/test/robotframework/resource.robot b/src/test/robotframework/resource.robot index fdfd9c1..21f8b48 100644 --- a/src/test/robotframework/resource.robot +++ b/src/test/robotframework/resource.robot @@ -1,4 +1,4 @@ *** Keywords *** Import JavaFXLibrary Run Keyword If sys.platform.startswith('java') Import Library JavaFXLibrary - ... ELSE Import Library Remote http://javafxcompile:8270/ WITH NAME RemoteJavaFXLibrary + ... ELSE Import Library Remote http://javafxcompile:8270 WITH NAME RemoteJavaFXLibrary From a47aefe33056be548b04fcf3bc399962a5179d27 Mon Sep 17 00:00:00 2001 From: Pasi Saikkonen Date: Thu, 30 Aug 2018 12:45:36 +0300 Subject: [PATCH 21/95] Remove test case Load image from URL --- .../acceptance/ScreenCapturingTest.robot | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/src/test/robotframework/acceptance/ScreenCapturingTest.robot b/src/test/robotframework/acceptance/ScreenCapturingTest.robot index 83d3530..9218bd4 100644 --- a/src/test/robotframework/acceptance/ScreenCapturingTest.robot +++ b/src/test/robotframework/acceptance/ScreenCapturingTest.robot @@ -41,19 +41,14 @@ Capture Bounds ${IMAGE2} Load Image ${COMPARISON}bounds.png Images Should Match ${IMAGE1} ${IMAGE2} ${99} -Load Image From URL - [Tags] smoke - ${IMAGE} Load Image From Url http://i.imgur.com/A99VNbK.png - ${TARGET} Load Image ${COMPARISON}url.png - Save And Load Image With Path - [Tags] smoke - ${NODE} Find id=rectangleContainer - ${IMAGE1} Capture Image ${NODE} - Save Image As ${IMAGE1} ${TEMPDIR}${/}image.png - Log html=true - ${IMAGE2} Load Image ${TEMPDIR}${/}image.png - Images Should Match ${IMAGE1} ${IMAGE2} + [Tags] smoke + ${NODE} Find id=rectangleContainer + ${IMAGE1} Capture Image ${NODE} + Save Image As ${IMAGE1} ${TEMPDIR}${/}image.png + Log html=true + ${IMAGE2} Load Image ${TEMPDIR}${/}image.png + Images Should Match ${IMAGE1} ${IMAGE2} Images Should Match [Tags] smoke From fee292e66bd5b16872222a5482d59990d2e79bb3 Mon Sep 17 00:00:00 2001 From: Pasi Saikkonen Date: Thu, 30 Aug 2018 12:54:13 +0300 Subject: [PATCH 22/95] Update readme and library documentation --- README.md | 100 ++++++++----------------- src/main/java/libdoc-documentation.txt | 6 +- 2 files changed, 36 insertions(+), 70 deletions(-) diff --git a/README.md b/README.md index 96e7932..e508052 100644 --- a/README.md +++ b/README.md @@ -1,100 +1,66 @@ # JavaFXLibrary -[Robot Framework](http://robotframework.org) library for testing and connecting to a JavaFX java process and using [TestFX](https://github.com/TestFX/TestFX). +[TestFX](https://github.com/TestFX/TestFX) based [Robot Framework](http://robotframework.org) library for testing JavaFX Applications. -This library allows you to use robot/pybot (Python version of Robot Framework) to run test cases over remote library interface although it also works if you are running with jybot (Jython version of Robot Framework). This means that you can use your other pure Python libraries in your test cases that will not work when runnin with Jython. +JavaFXLibrary works with both Jython (local and remote use) and Python (remote only) versions of Robot Framework. This means JavaFXLibrary can be used with Jython incompatible test libraries too by importing it as a remote library. JavaFXLibrary is tested to work with Robot Framework 3.0.2 or later. -You can connect to applications running on your local machine or even on a different machine. - - ## Keyword documentation See keyword [documentation](https://eficode.github.io/JavaFXLibrary/javafxlibrary.html). -## Installation - -1. Download latest JavaFXLibrary and documentation from https://github.com/robotframework/JavaFXLibrary/releases/ -2. Copy(if needed) JAR to desired location and run from command line using - ``` - java -jar javafxlibrary-.jar - - ``` -3. JavaFXLibrary in RemoteServer mode should now be running in port [8270](http://localhost:8270) -4. Optionally JAR can be launched with port number as an optional argument: - ``` - java -jar javafxlibrary-.jar 1234 - ``` -5. JavaFXLibrary in RemoteServer mode should now be running in port [1234](http://localhost:1234) - -## Usage in Robot suite settings - -Import the library: +## Taking the library into use +### As a local library +1. Download JavaFXLibrary jar file from [releases](https://github.com/eficode/JavaFXLibrary/releases/) +2. Import JavaFXLibrary in test settings: ``` -***Settings*** -Library Remote http://127.0.0.1:8270 WITH NAME JavaFXLibrary +*** Settings *** +Library JavaFXLibrary ``` -Now the keywords can be used as usual: +3. Add library jar to Jython [module search path](http://robotframework.org/robotframework/3.0b1/RobotFrameworkUserGuide.html#configuring-where-to-search-libraries-and-other-extensions) and run your tests: ``` -Launch Javafx Application javafxlibrary.testapps.TestClickRobot +jython -J-cp javafxlibrary-.jar -m robot.run tests.robot ``` -In case of duplicate keywords(multiple keywords found with same name) use e.g. `JavaFXLibrary.'Keyword Name'` to get rid of warnings. - -## Using multiple remote libraries - -If you need to use the Remote library multiple times in a test suite, or just want to give it a more descriptive name, you can import it using the WITH NAME syntax. +### As a remote library +1. Download JavaFXLibrary jar file from [releases](https://github.com/eficode/JavaFXLibrary/releases/) +2. Start JavaFXLibrary as a remote library: `java -jar javafxlibrary-.jar` + - Remote library starts in port [8270](http://localhost:8270) by default. + - Port number can also be defined in the start command: `java -jar javafxlibrary-.jar 1234` +3. Import JavaFXLibrary in test settings: ``` -***Settings*** -Library Remote http://127.0.0.1:8270 WITH NAME client1 -Library Remote http://127.0.0.1:8270 WITH NAME client2 +*** Settings *** +Library Remote http://127.0.0.1:8270 WITH NAME JavaFXLibrary ``` +4. Run your tests: `robot tests.robot` -Now the keywords can be used as `client1.List Windows` and `client2.List Windows` - -## JavaFX UI objects +## Identifying JavaFX UI objects +[Scenic View](http://fxexperience.com/scenic-view/) is a tool that allows you to inspect the JavaFX application scenegraph. This can be useful especially when you do not have access to the source code. -With [Scenic View](http://fxexperience.com/scenic-view/) you can see all your JavaFX applications UI objects. -See [keyword documentation](#keyword-documentation) for additional info how to use them with keywords. +See [keyword documentation](https://eficode.github.io/JavaFXLibrary/javafxlibrary.html#3.%20Locating%20JavaFX%20Nodes) for detailed information about handling UI elements with the library. ## JavaFXLibrary demo -This can be also used as JavaFXLibrary demo. +Library's acceptance test suite can be used as a JavaFXLibrary demo. Running the test suite requires [Maven](https://maven.apache.org) installation. -Generic way with Maven (in repository root): -``` -mvn verify -``` - -Windows command line: -``` -java -cp "target\javafxlibrary-.jar" org.robotframework.RobotFramework --include smoke src\test\robotframework/ -``` +### Running the demo locally +- Clone the repository: `git clone https://github.com/eficode/JavaFXLibrary.git` +- Run acceptance tests (in repository root): `mvn verify` -Linux/OSX command line: -``` -java -cp "target/javafxlibrary-.jar" org.robotframework.RobotFramework --include smoke src/test/robotframework/ - -``` - -## Remote library demo with Docker -### Requirements: +### Running the demo using Docker +#### Requirements: * VNC viewer e.g. https://www.realvnc.com/en/connect/download/viewer/ * Docker CE: https://docs.docker.com/install/ * Docker-compose: https://docs.docker.com/compose/install/ * VNC port: vnc://localhost:5900 -### Running the demo with testing env -1. Build & Start Dockerized Environment: `docker-compose up -d robot-framework javafxcompile` +#### Running the tests +1. Build & start the Dockerized environment: `docker-compose up -d robot-framework javafxcompile` 2. Take VNC connection to: vnc://:5900 3. Password is: 1234 4. Open shell by right clicking in VNC desktop and selecting Applications > Shells > Bash 5. Execute tests: `test.sh` -FYI: -Single testcase execution in locale and remote (replace spaces with _ ):
-`test.sh all '--include tag_name' '-t test_case_name'`
-Single suite execution in locale and remote (replace spaces with _ ):
-`test.sh all '--include tag_name' '-s suite_name'` -
-NOTE: smoke tag is default included. +Executing _test.sh_ runs the acceptance suite twice: first using JavaFXLibrary as a local Robot Framework library on Jython, and after that using the library in remote mode executing the same tests on python version of Robot Framework. + +If you want the suite to run only once, you can define which type of library to use by including **local** or **remote** as an argument. For example command `test.sh remote` will execute the suite only in remote mode. \ No newline at end of file diff --git a/src/main/java/libdoc-documentation.txt b/src/main/java/libdoc-documentation.txt index c028004..875630b 100644 --- a/src/main/java/libdoc-documentation.txt +++ b/src/main/java/libdoc-documentation.txt @@ -33,12 +33,12 @@ This will start the remote server listening on port 1234. JavaFXLibrary can be taken into use as remote library in settings table as follows: | *Settings* | *Value* | -| Library | Remote | http://localhost:8270/ | WITH NAME | JavaFXLibrary | +| Library | Remote | http://localhost:8270 | WITH NAME | JavaFXLibrary | Multiple JavaFXLibraries in remote mode: | *Settings* | *Value* | -| Library | Remote | ip_address:8270/ | WITH NAME | my_application | -| Library | Remote | ip_address:8271/ | WITH NAME | my_other_application | +| Library | Remote | ip_address:8270 | WITH NAME | my_application | +| Library | Remote | ip_address:8271 | WITH NAME | my_other_application | From 6f29e4f64d5147fecdf94496c1475852f17da60a Mon Sep 17 00:00:00 2001 From: "Hoisko Sakari.M 10802213" Date: Thu, 30 Aug 2018 13:33:56 +0300 Subject: [PATCH 23/95] Minor modifications --- docker-compose.yml | 2 +- docker/robot-javafx-demo/Dockerfile | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 495f717..331e340 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -15,7 +15,7 @@ services: networks: - testapp environment: - - RESOLUTION=1027x768 + - RESOLUTION=1920x1080 javafxcompile: build: diff --git a/docker/robot-javafx-demo/Dockerfile b/docker/robot-javafx-demo/Dockerfile index 9326a61..24c0aa3 100644 --- a/docker/robot-javafx-demo/Dockerfile +++ b/docker/robot-javafx-demo/Dockerfile @@ -21,13 +21,14 @@ RUN apt-get -qq update && apt-get dist-upgrade -y && apt-get install -qq --no-i openjfx \ && apt-get clean && rm -rf /var/lib/apt/lists/* +COPY test.sh /bin/test.sh RUN pip install --no-cache-dir \ - robotframework + robotframework && chmod 555 /bin/test.sh +# JUST VNC #COPY entrypoint.sh /entrypoint.sh -COPY test.sh /bin/test.sh -RUN chmod 555 /bin/test.sh #RUN mkdir ~/.vnc && x11vnc -storepasswd 1234 ~/.vnc/passwd && chmod 555 /entrypoint.sh /bin/test.sh -EXPOSE 5900 6080 #ENTRYPOINT ["x11vnc", "-create", "-forever", "-env", "FD_PROG=/entrypoint.sh", "-env", "X11VNC_CREATE_GEOM=${1:-1024x768x16}", "-usepw"] + +EXPOSE 5900 80 ENTRYPOINT ["/startup.sh"] From 6e28bc3fc4990f0ba84a234c79570a78ee6b4aaa Mon Sep 17 00:00:00 2001 From: Pasi Saikkonen Date: Thu, 30 Aug 2018 16:30:57 +0300 Subject: [PATCH 24/95] Move ScreenCapturingTests images --- .../controllers/ImageDemoController.java | 8 ++++---- .../acceptance/ScreenCapturingTest.robot | 19 ++++++++++++------ .../resources/screencapturingtest}/bounds.png | Bin .../resources/screencapturingtest}/node.png | Bin .../screencapturingtest}/node_colored.png | Bin .../screencapturingtest}/node_desaturated.png | Bin .../screencapturingtest}/node_modified.png | Bin .../screencapturingtest}/screen_region.png | Bin .../resources/screencapturingtest}/url.png | Bin .../screencapturingtest}/url_cropped.png | Bin 10 files changed, 17 insertions(+), 10 deletions(-) rename src/{main/resources/ScreenCapturing/comparison => test/robotframework/resources/screencapturingtest}/bounds.png (100%) rename src/{main/resources/ScreenCapturing/comparison => test/robotframework/resources/screencapturingtest}/node.png (100%) rename src/{main/resources/ScreenCapturing/comparison => test/robotframework/resources/screencapturingtest}/node_colored.png (100%) rename src/{main/resources/ScreenCapturing/comparison => test/robotframework/resources/screencapturingtest}/node_desaturated.png (100%) rename src/{main/resources/ScreenCapturing/comparison => test/robotframework/resources/screencapturingtest}/node_modified.png (100%) rename src/{main/resources/ScreenCapturing/comparison => test/robotframework/resources/screencapturingtest}/screen_region.png (100%) rename src/{main/resources/ScreenCapturing/comparison => test/robotframework/resources/screencapturingtest}/url.png (100%) rename src/{main/resources/ScreenCapturing/comparison => test/robotframework/resources/screencapturingtest}/url_cropped.png (100%) diff --git a/src/main/java/javafxlibrary/testapps/controllers/ImageDemoController.java b/src/main/java/javafxlibrary/testapps/controllers/ImageDemoController.java index 113e731..268548e 100644 --- a/src/main/java/javafxlibrary/testapps/controllers/ImageDemoController.java +++ b/src/main/java/javafxlibrary/testapps/controllers/ImageDemoController.java @@ -32,15 +32,15 @@ public class ImageDemoController implements Initializable { private @FXML TextField search; private @FXML VBox rowWrapper; - private List files; + //private List files; private List imageFiles; private List images; @Override public void initialize(URL location, ResourceBundle resources) { - File folder = new File("src/main/resources/ScreenCapturing/comparison"); - files = Arrays.asList(folder.listFiles()); - imageFiles = new ArrayList<>(files); + //File folder = new File("src/main/resources/ScreenCapturing/comparison"); + //files = Arrays.asList(folder.listFiles()); + imageFiles = new ArrayList<>(/*files*/); imageFiles.add(new File("src/main/resources/fxml/javafxlibrary/ui/uiresources/ejlogo.png")); images = new ArrayList<>(); Collections.shuffle(imageFiles); diff --git a/src/test/robotframework/acceptance/ScreenCapturingTest.robot b/src/test/robotframework/acceptance/ScreenCapturingTest.robot index 83d3530..a61b8c8 100644 --- a/src/test/robotframework/acceptance/ScreenCapturingTest.robot +++ b/src/test/robotframework/acceptance/ScreenCapturingTest.robot @@ -1,13 +1,14 @@ *** Settings *** -Documentation Tests to test javafxlibrary.keywords.ScreenCapturing related keywords -Resource ../resource.robot -Suite Setup Setup all tests -Suite Teardown Teardown all tests -Force Tags set-screencapturing +Documentation Tests to test javafxlibrary.keywords.ScreenCapturing related keywords +Library String +Resource ../resource.robot +Suite Setup Setup all tests +Suite Teardown Teardown all tests +Force Tags set-screencapturing *** Variables *** ${TEST_APPLICATION} javafxlibrary.testapps.TestScreenCapturing -${COMPARISON} src/main/resources/screencapturing/comparison/ +${COMPARISON} ${EMPTY} *** Test Cases *** Capture Node @@ -100,6 +101,12 @@ Setup all tests Set Timeout 0 Launch Javafx Application ${TEST_APPLICATION} Set Screenshot Directory ${OUTPUT_DIR}${/}report-images + Set comparison path Teardown all tests Close Javafx Application + +Set comparison path + ${dir_path} Fetch From Left ${CURDIR} acceptance + ${comparison_path} Catenate SEPARATOR= ${dir_path} resources/screencapturingtest/ + Set Suite Variable ${COMPARISON} ${comparison_path} diff --git a/src/main/resources/ScreenCapturing/comparison/bounds.png b/src/test/robotframework/resources/screencapturingtest/bounds.png similarity index 100% rename from src/main/resources/ScreenCapturing/comparison/bounds.png rename to src/test/robotframework/resources/screencapturingtest/bounds.png diff --git a/src/main/resources/ScreenCapturing/comparison/node.png b/src/test/robotframework/resources/screencapturingtest/node.png similarity index 100% rename from src/main/resources/ScreenCapturing/comparison/node.png rename to src/test/robotframework/resources/screencapturingtest/node.png diff --git a/src/main/resources/ScreenCapturing/comparison/node_colored.png b/src/test/robotframework/resources/screencapturingtest/node_colored.png similarity index 100% rename from src/main/resources/ScreenCapturing/comparison/node_colored.png rename to src/test/robotframework/resources/screencapturingtest/node_colored.png diff --git a/src/main/resources/ScreenCapturing/comparison/node_desaturated.png b/src/test/robotframework/resources/screencapturingtest/node_desaturated.png similarity index 100% rename from src/main/resources/ScreenCapturing/comparison/node_desaturated.png rename to src/test/robotframework/resources/screencapturingtest/node_desaturated.png diff --git a/src/main/resources/ScreenCapturing/comparison/node_modified.png b/src/test/robotframework/resources/screencapturingtest/node_modified.png similarity index 100% rename from src/main/resources/ScreenCapturing/comparison/node_modified.png rename to src/test/robotframework/resources/screencapturingtest/node_modified.png diff --git a/src/main/resources/ScreenCapturing/comparison/screen_region.png b/src/test/robotframework/resources/screencapturingtest/screen_region.png similarity index 100% rename from src/main/resources/ScreenCapturing/comparison/screen_region.png rename to src/test/robotframework/resources/screencapturingtest/screen_region.png diff --git a/src/main/resources/ScreenCapturing/comparison/url.png b/src/test/robotframework/resources/screencapturingtest/url.png similarity index 100% rename from src/main/resources/ScreenCapturing/comparison/url.png rename to src/test/robotframework/resources/screencapturingtest/url.png diff --git a/src/main/resources/ScreenCapturing/comparison/url_cropped.png b/src/test/robotframework/resources/screencapturingtest/url_cropped.png similarity index 100% rename from src/main/resources/ScreenCapturing/comparison/url_cropped.png rename to src/test/robotframework/resources/screencapturingtest/url_cropped.png From 88902d43bdbb38f4d431ee7a6d93cb954b926e22 Mon Sep 17 00:00:00 2001 From: Pasi Saikkonen Date: Thu, 30 Aug 2018 17:01:12 +0300 Subject: [PATCH 25/95] Update readme --- README.md | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index e508052..fc81a4a 100644 --- a/README.md +++ b/README.md @@ -49,17 +49,15 @@ Library's acceptance test suite can be used as a JavaFXLibrary demo. Running the ### Running the demo using Docker #### Requirements: -* VNC viewer e.g. https://www.realvnc.com/en/connect/download/viewer/ * Docker CE: https://docs.docker.com/install/ * Docker-compose: https://docs.docker.com/compose/install/ -* VNC port: vnc://localhost:5900 +* Port 80 is free in your machine #### Running the tests 1. Build & start the Dockerized environment: `docker-compose up -d robot-framework javafxcompile` -2. Take VNC connection to: vnc://:5900 -3. Password is: 1234 -4. Open shell by right clicking in VNC desktop and selecting Applications > Shells > Bash -5. Execute tests: `test.sh` +2. Open browser to +3. Open xterm from Start menu > System tools > xterm +4. Execute tests: `test.sh` Executing _test.sh_ runs the acceptance suite twice: first using JavaFXLibrary as a local Robot Framework library on Jython, and after that using the library in remote mode executing the same tests on python version of Robot Framework. From 17edace00b7d920a77159fe71dc3dfe84447318c Mon Sep 17 00:00:00 2001 From: Pasi Saikkonen Date: Fri, 31 Aug 2018 16:10:45 +0300 Subject: [PATCH 26/95] Embed images in log.html Images are now embedded into the output log file with base64 encoding. This fixes visibility problems caused by incorrect paths when files are moved between systems and enables logging images without transferring any files on remote mode (Closes #5 and closes #6). Also added keyword Set Image Logging which allows users to toggle image logging on and off. When logging is set to off, automatic captures on library keywords failing will not be taken at all. As an example use case all tests containing 'negative' tag now have image logging disabled in library's acceptance test suite. --- .../AdditionalKeywords/RunOnFailure.java | 6 ++- .../keywords/Keywords/ScreenCapturing.java | 37 +++++++++++++++---- .../javafxlibrary/utils/TestFxAdapter.java | 2 + .../acceptance/0_ClickRobotTest.robot | 17 ++++++--- .../acceptance/BoundsLocationTest.robot | 12 +++--- .../acceptance/DatePickerTest.robot | 17 ++++++--- .../acceptance/DragRobotTest.robot | 12 +++--- .../robotframework/acceptance/FindTest.robot | 2 + .../acceptance/KeyboardRobotTest.robot | 12 +++--- .../acceptance/MenuAppTest.robot | 12 +++--- .../robotframework/acceptance/MiscTests.robot | 4 +- .../acceptance/MoveRobotTest.robot | 19 ++++++---- .../acceptance/NodeLookupTest.robot | 12 +++--- .../acceptance/PointLocationTest.robot | 12 +++--- .../acceptance/ScreenCapturingTest.robot | 2 + .../acceptance/ScrollRobotTest.robot | 12 +++--- .../acceptance/ScrollRobotTest2.robot | 12 +++--- .../SwingApplicationWrapperTest.robot | 7 +++- .../acceptance/WindowLookupTest.robot | 12 +++--- .../acceptance/WindowManagementTest.robot | 12 +++--- .../acceptance/WindowTargetingTest.robot | 12 +++--- src/test/robotframework/resource.robot | 7 ++++ 22 files changed, 168 insertions(+), 84 deletions(-) diff --git a/src/main/java/javafxlibrary/keywords/AdditionalKeywords/RunOnFailure.java b/src/main/java/javafxlibrary/keywords/AdditionalKeywords/RunOnFailure.java index 674b6de..d6e6d0a 100644 --- a/src/main/java/javafxlibrary/keywords/AdditionalKeywords/RunOnFailure.java +++ b/src/main/java/javafxlibrary/keywords/AdditionalKeywords/RunOnFailure.java @@ -57,12 +57,16 @@ public void runOnFailure() { if (robot == null) { RobotLog.error("FxRobot not initialized, launch test application with the library"); - } else { + } else if (TestFxAdapter.logImages) { RobotLog.info("JavaFxLibrary keyword has failed! Below a screenshot from erroneous situation:"); if (robot.targetWindow() != null) { new ScreenCapturing().captureImage(robot.targetWindow()); } else new ScreenCapturing().captureImage(Screen.getPrimary().getBounds()); + } else { + RobotLog.info("JavaFXLibrary keyword has failed!"); + RobotLog.info("Not taking a screenshot since Set Image Logging is set to off. To enable screenshots " + + "on failed keywords, use keyword 'Set Image Logging ON'"); } runningOnFailureRoutine = false; diff --git a/src/main/java/javafxlibrary/keywords/Keywords/ScreenCapturing.java b/src/main/java/javafxlibrary/keywords/Keywords/ScreenCapturing.java index 809947c..5036f13 100644 --- a/src/main/java/javafxlibrary/keywords/Keywords/ScreenCapturing.java +++ b/src/main/java/javafxlibrary/keywords/Keywords/ScreenCapturing.java @@ -22,6 +22,7 @@ import javafxlibrary.exceptions.JavaFXLibraryNonFatalException; import javafxlibrary.utils.RobotLog; import javafxlibrary.utils.TestFxAdapter; +import org.apache.commons.io.IOUtils; import org.robotframework.javalib.annotation.ArgumentNames; import org.robotframework.javalib.annotation.RobotKeyword; import org.robotframework.javalib.annotation.RobotKeywordOverload; @@ -29,19 +30,35 @@ import javafx.scene.image.Image; import javax.imageio.ImageIO; import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; import java.net.URL; import java.nio.file.Path; import java.nio.file.Paths; import java.time.ZonedDateTime; import java.time.format.DateTimeFormatter; +import java.util.Base64; + import static javafxlibrary.utils.HelperFunctions.*; @RobotKeywords public class ScreenCapturing extends TestFxAdapter { + @RobotKeyword + @ArgumentNames({ "value" }) + public void setImageLogging(String value) { + if (value.toLowerCase().equals("on")) + TestFxAdapter.logImages = true; + else if (value.toLowerCase().equals("off")) + TestFxAdapter.logImages = false; + else + throw new JavaFXLibraryNonFatalException("Value \"" + value + "\" is not supported! Value must be either " + + "\"ON\" or \"OFF\""); + } + @RobotKeywordOverload public Object captureImage(Object locator){ - return captureImage(locator, true); + return captureImage(locator, TestFxAdapter.logImages); } @RobotKeyword("Returns a screenshot of the given locator.\n\n" @@ -56,7 +73,7 @@ public Object captureImage(Object locator){ + "| ${capture}= | Capture Image | \\#id | logImage=False |\n" ) @ArgumentNames({"locator", "logImage=True"}) public Object captureImage(Object locator, boolean logImage){ - if(locator == null) + if (locator == null) throw new JavaFXLibraryNonFatalException("Unable to capture image, given locator was null!"); RobotLog.info("Capturing screenshot from locator: \"" + locator + "\""); @@ -67,18 +84,24 @@ public Object captureImage(Object locator, boolean logImage){ image = robot.capture(targetBounds).getImage(); Path path = createNewImageFileNameWithPath(); robotContext.getCaptureSupport().saveImage(image, path); + File imageFile = path.toFile(); + /* TODO: Copy and resize image to a temporary file and embed that instead + Add path to the original file in logs in case greater resolution is needed */ + byte[] imageBytes = IOUtils.toByteArray(new FileInputStream(imageFile)); + String encodedImage = Base64.getEncoder().encodeToString(imageBytes); - if(logImage) { + if (logImage) { Double printSize = ( targetBounds.getWidth() > 800 ) ? 800 : targetBounds.getWidth(); - System.out.println("*HTML* "); + System.out.println("*HTML* "); } - return mapObject(image); + } catch (IOException e) { + throw new JavaFXLibraryNonFatalException("Unable to take capture : \"" + locator + "\"", e); } catch (Exception e) { - if(e instanceof JavaFXLibraryNonFatalException) + if (e instanceof JavaFXLibraryNonFatalException) throw e; - throw new JavaFXLibraryNonFatalException("Unable to take capture : \"" + locator.toString() + "\"", e); + throw new JavaFXLibraryNonFatalException("Unable to take capture : \"" + locator + "\"", e); } } diff --git a/src/main/java/javafxlibrary/utils/TestFxAdapter.java b/src/main/java/javafxlibrary/utils/TestFxAdapter.java index 69c3b01..9a093cd 100644 --- a/src/main/java/javafxlibrary/utils/TestFxAdapter.java +++ b/src/main/java/javafxlibrary/utils/TestFxAdapter.java @@ -44,6 +44,8 @@ public static void setRobotContext(FxRobotContext context) { // TODO: consider adding support for multiple sessions private static Session activeSession = null; + protected static boolean logImages = true; + // internal book keeping for objects public static HashMap objectMap = new HashMap(); diff --git a/src/test/robotframework/acceptance/0_ClickRobotTest.robot b/src/test/robotframework/acceptance/0_ClickRobotTest.robot index 0c65bf0..99d9b32 100644 --- a/src/test/robotframework/acceptance/0_ClickRobotTest.robot +++ b/src/test/robotframework/acceptance/0_ClickRobotTest.robot @@ -1,10 +1,11 @@ *** Settings *** -Documentation Tests to test javafxlibrary.keywords.ClickRobot related keywords -Resource ../resource.robot -Suite Setup Setup all tests -Suite Teardown Teardown all tests -Test Setup Reset Counters -Force tags set-clickrobot +Documentation Tests to test javafxlibrary.keywords.ClickRobot related keywords +Resource ../resource.robot +Suite Setup Setup all tests +Suite Teardown Teardown all tests +Test Setup Setup test case +Test Teardown Enable Image Logging +Force tags set-clickrobot *** Variables *** ${TEST_APPLICATION} javafxlibrary.testapps.TestClickRobot @@ -263,6 +264,10 @@ Setup all tests Set Window Values Set Timeout 1 +Setup test case + Reset Counters + Disable Image Logging For Negative Tests + Teardown all tests Close Javafx Application diff --git a/src/test/robotframework/acceptance/BoundsLocationTest.robot b/src/test/robotframework/acceptance/BoundsLocationTest.robot index a0d8db0..50d0109 100644 --- a/src/test/robotframework/acceptance/BoundsLocationTest.robot +++ b/src/test/robotframework/acceptance/BoundsLocationTest.robot @@ -1,9 +1,11 @@ *** Settings *** -Documentation Tests to test javafxlibrary.keywords.BoundsLocation related keywords -Resource ../resource.robot -Suite Setup Setup all tests -Suite Teardown Teardown all tests -Force Tags set-boundslocation +Documentation Tests to test javafxlibrary.keywords.BoundsLocation related keywords +Resource ../resource.robot +Suite Setup Setup all tests +Suite Teardown Teardown all tests +Test Setup Disable Image Logging For Negative Tests +Test Teardown Enable Image Logging +Force Tags set-boundslocation *** Variables *** ${TEST_APPLICATION} javafxlibrary.testapps.TestBoundsLocation diff --git a/src/test/robotframework/acceptance/DatePickerTest.robot b/src/test/robotframework/acceptance/DatePickerTest.robot index b6500c2..8acaf5a 100644 --- a/src/test/robotframework/acceptance/DatePickerTest.robot +++ b/src/test/robotframework/acceptance/DatePickerTest.robot @@ -1,10 +1,11 @@ *** Settings *** -Documentation Tests to test DatePicker related keywords -Resource ../resource.robot -Suite Setup Setup all tests -Suite Teardown Teardown all tests -Test Teardown Clear Text Input css=.text-field -Force Tags set-datepicker +Documentation Tests to test DatePicker related keywords +Resource ../resource.robot +Suite Setup Setup all tests +Suite Teardown Teardown all tests +Test Setup Disable Image Logging For Negative Tests +Test Teardown Teardown test case +Force Tags set-datepicker *** Variables *** ${TEST_APPLICATION} javafxlibrary.testapps.DatePickerApp @@ -40,6 +41,10 @@ Setup all tests Teardown all tests Close Javafx Application +Teardown test case + Clear Text Input css=.text-field + Enable Image Logging + Set Year [Arguments] ${year} ${time_labels} Find All css=.spinner-label diff --git a/src/test/robotframework/acceptance/DragRobotTest.robot b/src/test/robotframework/acceptance/DragRobotTest.robot index cd53059..ebba3e2 100644 --- a/src/test/robotframework/acceptance/DragRobotTest.robot +++ b/src/test/robotframework/acceptance/DragRobotTest.robot @@ -1,9 +1,11 @@ *** Settings *** -Documentation Tests to test javafxlibrary.keywords.DragRobot related keywords -Resource ../resource.robot -Suite Setup Setup all tests -Suite Teardown Teardown all tests -Force tags set-dragrobot +Documentation Tests to test javafxlibrary.keywords.DragRobot related keywords +Resource ../resource.robot +Suite Setup Setup all tests +Suite Teardown Teardown all tests +Test Setup Disable Image Logging For Negative Tests +Test Teardown Enable Image Logging +Force tags set-dragrobot *** Variables *** ${TEST_APPLICATION} javafxlibrary.testapps.TestDragRobot diff --git a/src/test/robotframework/acceptance/FindTest.robot b/src/test/robotframework/acceptance/FindTest.robot index a6a819f..004bed6 100644 --- a/src/test/robotframework/acceptance/FindTest.robot +++ b/src/test/robotframework/acceptance/FindTest.robot @@ -3,6 +3,8 @@ Documentation Tests to test javafxlibrary.keywords.AdditionalKeywords.Find Resource ../resource.robot Suite Setup Setup All Tests Suite Teardown Teardown all tests +Test Setup Disable Image Logging For Negative Tests +Test Teardown Enable Image Logging Force Tags set-find *** Variables *** diff --git a/src/test/robotframework/acceptance/KeyboardRobotTest.robot b/src/test/robotframework/acceptance/KeyboardRobotTest.robot index c317410..fc5cde6 100644 --- a/src/test/robotframework/acceptance/KeyboardRobotTest.robot +++ b/src/test/robotframework/acceptance/KeyboardRobotTest.robot @@ -1,9 +1,11 @@ *** Settings *** -Documentation Tests to test javafxlibrary.keywords.KeyboardRobot related keywords -Resource ../resource.robot -Suite Setup Setup all tests -Suite Teardown Teardown all tests -Force Tags set-keyboardrobot +Documentation Tests to test javafxlibrary.keywords.KeyboardRobot related keywords +Resource ../resource.robot +Suite Setup Setup all tests +Suite Teardown Teardown all tests +Test Setup Disable Image Logging For Negative Tests +Test Teardown Enable Image Logging +Force Tags set-keyboardrobot *** Variables *** ${TEST_APPLICATION} javafxlibrary.testapps.TestKeyboardRobot diff --git a/src/test/robotframework/acceptance/MenuAppTest.robot b/src/test/robotframework/acceptance/MenuAppTest.robot index 513cfec..be0205d 100644 --- a/src/test/robotframework/acceptance/MenuAppTest.robot +++ b/src/test/robotframework/acceptance/MenuAppTest.robot @@ -1,9 +1,11 @@ *** Settings *** -Documentation Tests to test javafxlibrary keywords -Resource ../resource.robot -Suite Setup Setup all tests -Suite Teardown Teardown all tests -Force Tags set-menuapp +Documentation Tests to test javafxlibrary keywords +Resource ../resource.robot +Suite Setup Setup all tests +Suite Teardown Teardown all tests +Test Setup Disable Image Logging For Negative Tests +Test Teardown Enable Image Logging +Force Tags set-menuapp *** Variables *** ${TEST_APPLICATION} javafxlibrary.testapps.MenuApp diff --git a/src/test/robotframework/acceptance/MiscTests.robot b/src/test/robotframework/acceptance/MiscTests.robot index 96260c9..4f7897e 100644 --- a/src/test/robotframework/acceptance/MiscTests.robot +++ b/src/test/robotframework/acceptance/MiscTests.robot @@ -5,6 +5,8 @@ Library Collections Library String Suite Setup Setup All Tests Suite Teardown Close Javafx Application +Test Setup Disable Image Logging For Negative Tests +Test Teardown Enable Image Logging *** Variables *** ${CURRENT_APPLICATION} NOT SET @@ -88,7 +90,7 @@ Change Node Fill Using Call Method In JavaFX Application Thread Should End With ${after_reset} ffff00ff Set Node Visibility (Call Method With Argument Types That Require Casting) - [Tags] smoke demo-set + [Tags] smoke demo-set negative Set Test Application javafxlibrary.testapps.TestBoundsLocation ${node} Find id=yellow Node Should Be Visible ${node} diff --git a/src/test/robotframework/acceptance/MoveRobotTest.robot b/src/test/robotframework/acceptance/MoveRobotTest.robot index a23fe70..4701fc2 100644 --- a/src/test/robotframework/acceptance/MoveRobotTest.robot +++ b/src/test/robotframework/acceptance/MoveRobotTest.robot @@ -1,10 +1,11 @@ *** Settings *** -Documentation Tests to test javafxlibrary.keywords.MoveRobot related keywords -Resource ../resource.robot -Suite Setup Setup all tests -Suite Teardown Teardown all tests -Test Setup Move To Top Left Corner -Force Tags set-moverobot +Documentation Tests to test javafxlibrary.keywords.MoveRobot related keywords +Resource ../resource.robot +Suite Setup Setup all tests +Suite Teardown Teardown all tests +Test Setup Setup test case +Test Teardown Enable Image Logging +Force Tags set-moverobot *** Variables *** ${TEST_APPLICATION} javafxlibrary.testapps.TestPointLocation @@ -22,7 +23,7 @@ Move By Verify String id=locationLabel 75 | 75 Move To Coordinates - [Tags] smoke demo-set + [Tags] smoke demo-set negative ${X} Evaluate ${SCENE_MINX} + ${200} ${Y} Evaluate ${SCENE_MINY} + ${200} Move To Coordinates ${X} ${Y} @@ -93,6 +94,10 @@ Setup all tests Set Scene Bounds Values Set Decoration Values +Setup test case + Move To Top Left Corner + Disable Image Logging For Negative Tests + Teardown all tests Close Javafx Application diff --git a/src/test/robotframework/acceptance/NodeLookupTest.robot b/src/test/robotframework/acceptance/NodeLookupTest.robot index 626fe49..d7b5e46 100644 --- a/src/test/robotframework/acceptance/NodeLookupTest.robot +++ b/src/test/robotframework/acceptance/NodeLookupTest.robot @@ -1,9 +1,11 @@ *** Settings *** -Documentation Tests to test javafxlibrary.keywords.NodeLookup related keywords -Resource ../resource.robot -Suite Setup Setup all tests -Suite Teardown Teardown all tests -Force Tags set-nodelookup +Documentation Tests to test javafxlibrary.keywords.NodeLookup related keywords +Resource ../resource.robot +Suite Setup Setup all tests +Suite Teardown Teardown all tests +Test Setup Disable Image Logging For Negative Tests +Test Teardown Enable Image Logging +Force Tags set-nodelookup *** Variables *** ${TEST_APPLICATION} javafxlibrary.testapps.TestClickRobot diff --git a/src/test/robotframework/acceptance/PointLocationTest.robot b/src/test/robotframework/acceptance/PointLocationTest.robot index 4df508e..251f9af 100644 --- a/src/test/robotframework/acceptance/PointLocationTest.robot +++ b/src/test/robotframework/acceptance/PointLocationTest.robot @@ -1,9 +1,11 @@ *** Settings *** -Documentation Tests to test javafxlibrary.keywords.PointLocation and PointOffset related keywords -Resource ../resource.robot -Suite Setup Setup all tests -Suite Teardown Teardown all tests -Force Tags set-pointlocation set-pointoffset +Documentation Tests to test javafxlibrary.keywords.PointLocation and PointOffset related keywords +Resource ../resource.robot +Suite Setup Setup all tests +Suite Teardown Teardown all tests +Test Setup Disable Image Logging For Negative Tests +Test Teardown Enable Image Logging +Force Tags set-pointlocation set-pointoffset *** Variables *** ${TEST_APPLICATION} javafxlibrary.testapps.TestPointLocation diff --git a/src/test/robotframework/acceptance/ScreenCapturingTest.robot b/src/test/robotframework/acceptance/ScreenCapturingTest.robot index 852f520..e2ae9ab 100644 --- a/src/test/robotframework/acceptance/ScreenCapturingTest.robot +++ b/src/test/robotframework/acceptance/ScreenCapturingTest.robot @@ -4,6 +4,8 @@ Library String Resource ../resource.robot Suite Setup Setup all tests Suite Teardown Teardown all tests +Test Setup Disable Image Logging For Negative Tests +Test Teardown Enable Image Logging Force Tags set-screencapturing *** Variables *** diff --git a/src/test/robotframework/acceptance/ScrollRobotTest.robot b/src/test/robotframework/acceptance/ScrollRobotTest.robot index 495c336..c7e6fd2 100644 --- a/src/test/robotframework/acceptance/ScrollRobotTest.robot +++ b/src/test/robotframework/acceptance/ScrollRobotTest.robot @@ -1,9 +1,11 @@ *** Settings *** -Documentation Tests to test javafxlibrary.keywords.ScrollRobot related keywords -Resource ../resource.robot -Suite Setup Setup all tests -Suite Teardown Teardown all tests -Force Tags set-scrollrobot +Documentation Tests to test javafxlibrary.keywords.ScrollRobot related keywords +Resource ../resource.robot +Suite Setup Setup all tests +Suite Teardown Teardown all tests +Test Setup Disable Image Logging For Negative Tests +Test Teardown Enable Image Logging +Force Tags set-scrollrobot *** Variables *** ${TEST_APPLICATION} javafxlibrary.testapps.TestScrollRobot diff --git a/src/test/robotframework/acceptance/ScrollRobotTest2.robot b/src/test/robotframework/acceptance/ScrollRobotTest2.robot index 67ea133..c5f3918 100644 --- a/src/test/robotframework/acceptance/ScrollRobotTest2.robot +++ b/src/test/robotframework/acceptance/ScrollRobotTest2.robot @@ -1,9 +1,11 @@ *** Settings *** -Documentation Tests to test javafxlibrary.keywords.ScrollRobot related keywords -Resource ../resource.robot -Suite Setup Setup all tests -Suite Teardown Teardown all tests -Force Tags set-scrollrobot +Documentation Tests to test javafxlibrary.keywords.ScrollRobot related keywords +Resource ../resource.robot +Suite Setup Setup all tests +Suite Teardown Teardown all tests +Test Setup Disable Image Logging For Negative Tests +Test Teardown Enable Image Logging +Force Tags set-scrollrobot *** Variables *** ${TEST_APPLICATION} javafxlibrary.testapps.TestScrollRobot2 diff --git a/src/test/robotframework/acceptance/SwingApplicationWrapperTest.robot b/src/test/robotframework/acceptance/SwingApplicationWrapperTest.robot index b7463ba..3b70479 100644 --- a/src/test/robotframework/acceptance/SwingApplicationWrapperTest.robot +++ b/src/test/robotframework/acceptance/SwingApplicationWrapperTest.robot @@ -3,7 +3,8 @@ Documentation Tests for handling Swing embedded JavaFX nodes Resource ../resource.robot Force Tags set-embedded Suite Setup Import JavaFXLibrary -Test Teardown Close Test Application +Test Setup Disable Image Logging For Negative Tests +Test Teardown Teardown Test Case *** Testcases *** Swing Embedded JavaFX Click Test @@ -31,6 +32,10 @@ Launch Swing Application Using External Wrapper Class Wait Until Keyword Succeeds 3 sec 250ms Text Value Should Be JavaFXLibrary *** Keywords *** +Teardown Test Case + Close Test Application + Enable Image Logging + Text Value Should Be [Arguments] ${value} ${text} Get Node Text id=textValue diff --git a/src/test/robotframework/acceptance/WindowLookupTest.robot b/src/test/robotframework/acceptance/WindowLookupTest.robot index 42df7e2..ed3c4da 100644 --- a/src/test/robotframework/acceptance/WindowLookupTest.robot +++ b/src/test/robotframework/acceptance/WindowLookupTest.robot @@ -1,9 +1,11 @@ *** Settings *** -Documentation Tests to test javafxlibrary.keywords.WindowLookup related keywords -Resource ../resource.robot -Suite Setup Setup all tests -Suite Teardown Teardown all tests -Force Tags set-windowlookup +Documentation Tests to test javafxlibrary.keywords.WindowLookup related keywords +Resource ../resource.robot +Suite Setup Setup all tests +Suite Teardown Teardown all tests +Test Setup Disable Image Logging For Negative Tests +Test Teardown Enable Image Logging +Force Tags set-windowlookup *** Variables *** ${TEST_APPLICATION} javafxlibrary.testapps.TestMultipleWindows diff --git a/src/test/robotframework/acceptance/WindowManagementTest.robot b/src/test/robotframework/acceptance/WindowManagementTest.robot index 20f9642..64271fd 100644 --- a/src/test/robotframework/acceptance/WindowManagementTest.robot +++ b/src/test/robotframework/acceptance/WindowManagementTest.robot @@ -1,9 +1,11 @@ *** Settings *** -Documentation Tests for Window Management -Resource ../resource.robot -Suite Setup Setup all tests -Suite Teardown Teardown all tests -Force Tags set-windowmanagement +Documentation Tests for Window Management +Resource ../resource.robot +Suite Setup Setup all tests +Suite Teardown Teardown all tests +Test Setup Disable Image Logging For Negative Tests +Test Teardown Enable Image Logging +Force Tags set-windowmanagement *** Variables *** ${TEST_APPLICATION} javafxlibrary.testapps.TestWindowManagement diff --git a/src/test/robotframework/acceptance/WindowTargetingTest.robot b/src/test/robotframework/acceptance/WindowTargetingTest.robot index b8c2848..1ac719b 100644 --- a/src/test/robotframework/acceptance/WindowTargetingTest.robot +++ b/src/test/robotframework/acceptance/WindowTargetingTest.robot @@ -1,9 +1,11 @@ *** Settings *** -Documentation Tests to test javafxlibrary.keywords.WindowTargeting related keywords -Resource ../resource.robot -Suite Setup Setup all tests -Suite Teardown Teardown all tests -Force Tags set-windowtargeting +Documentation Tests to test javafxlibrary.keywords.WindowTargeting related keywords +Resource ../resource.robot +Suite Setup Setup all tests +Suite Teardown Teardown all tests +Test Setup Disable Image Logging For Negative Tests +Test Teardown Enable Image Logging +Force Tags set-windowtargeting *** Variables *** ${TEST_APPLICATION} javafxlibrary.testapps.TestMultipleWindows diff --git a/src/test/robotframework/resource.robot b/src/test/robotframework/resource.robot index 21f8b48..0a60748 100644 --- a/src/test/robotframework/resource.robot +++ b/src/test/robotframework/resource.robot @@ -2,3 +2,10 @@ Import JavaFXLibrary Run Keyword If sys.platform.startswith('java') Import Library JavaFXLibrary ... ELSE Import Library Remote http://javafxcompile:8270 WITH NAME RemoteJavaFXLibrary + +Disable Image Logging For Negative Tests + :FOR ${tag} IN @{TEST TAGS} + \ Run Keyword If '${tag}' == 'negative' Set Image Logging OFF + +Enable Image Logging + Set Image Logging ON From a4cb559b94b92bd7f8611576e56470b77c572c13 Mon Sep 17 00:00:00 2001 From: Pasi Saikkonen Date: Fri, 31 Aug 2018 17:58:15 +0300 Subject: [PATCH 27/95] Resize images wider than 800px before embedding --- .../keywords/Keywords/ScreenCapturing.java | 40 +++++++++++++++---- 1 file changed, 33 insertions(+), 7 deletions(-) diff --git a/src/main/java/javafxlibrary/keywords/Keywords/ScreenCapturing.java b/src/main/java/javafxlibrary/keywords/Keywords/ScreenCapturing.java index 5036f13..403c39d 100644 --- a/src/main/java/javafxlibrary/keywords/Keywords/ScreenCapturing.java +++ b/src/main/java/javafxlibrary/keywords/Keywords/ScreenCapturing.java @@ -32,6 +32,7 @@ import java.io.File; import java.io.FileInputStream; import java.io.IOException; +import java.net.MalformedURLException; import java.net.URL; import java.nio.file.Path; import java.nio.file.Paths; @@ -84,14 +85,22 @@ public Object captureImage(Object locator, boolean logImage){ image = robot.capture(targetBounds).getImage(); Path path = createNewImageFileNameWithPath(); robotContext.getCaptureSupport().saveImage(image, path); - File imageFile = path.toFile(); - /* TODO: Copy and resize image to a temporary file and embed that instead - Add path to the original file in logs in case greater resolution is needed */ - byte[] imageBytes = IOUtils.toByteArray(new FileInputStream(imageFile)); - String encodedImage = Base64.getEncoder().encodeToString(imageBytes); if (logImage) { - Double printSize = ( targetBounds.getWidth() > 800 ) ? 800 : targetBounds.getWidth(); + Image resizedImage = resizeImage(image, path); + Path tempPath = Paths.get(getCurrentSessionScreenshotDirectory(), "temp.png"); + robotContext.getCaptureSupport().saveImage(resizedImage, tempPath); + + File imageFile = tempPath.toFile(); + byte[] imageBytes = IOUtils.toByteArray(new FileInputStream(imageFile)); + String encodedImage = Base64.getEncoder().encodeToString(imageBytes); + + if (imageFile.delete()) + RobotLog.debug("Deleted temporary image file successfully."); + else + RobotLog.debug("Could not delete the file: " + imageFile.toString()); + + Double printSize = targetBounds.getWidth() > 800 ? 800 : targetBounds.getWidth(); System.out.println("*HTML* "); } return mapObject(image); @@ -159,11 +168,28 @@ private Path createNewImageFileNameWithPath(){ File errDir = new File(errorImageFilePath); if(!errDir.exists()) errDir.mkdirs(); - return Paths.get( errorImageFilePath, errorImageFilename); + return Paths.get(errorImageFilePath, errorImageFilename); } private static String formatErrorTimestamp(ZonedDateTime dateTime, String dateTimePattern) { DateTimeFormatter formatter = DateTimeFormatter.ofPattern(dateTimePattern); return dateTime.format(formatter); } + + private static Image resizeImage(Image image, Path path) { + double width = image.getWidth(); + double height = image.getHeight(); + + if (width < 800) + return image; + + RobotLog.info("Full resolution image can be found at " + path); + double multiplier = width / 800; + try { + String url = path.toUri().toURL().toString(); + return new Image(url, width / multiplier, height / multiplier, true, false); + } catch (MalformedURLException e) { + throw new JavaFXLibraryNonFatalException("Unable to log the screenshot: image resizing failed!"); + } + } } \ No newline at end of file From 537a5c7ab6d76d0366ce0f55c9d22ce92fffb916 Mon Sep 17 00:00:00 2001 From: Pasi Saikkonen Date: Fri, 31 Aug 2018 18:24:42 +0300 Subject: [PATCH 28/95] Add documentation for Set Image Logging --- .../javafxlibrary/keywords/Keywords/ScreenCapturing.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/javafxlibrary/keywords/Keywords/ScreenCapturing.java b/src/main/java/javafxlibrary/keywords/Keywords/ScreenCapturing.java index 403c39d..ae9bde0 100644 --- a/src/main/java/javafxlibrary/keywords/Keywords/ScreenCapturing.java +++ b/src/main/java/javafxlibrary/keywords/Keywords/ScreenCapturing.java @@ -45,7 +45,10 @@ @RobotKeywords public class ScreenCapturing extends TestFxAdapter { - @RobotKeyword + @RobotKeyword("Sets whether to log images into the log.html file or not.\n\n" + + "Argument ``value`` is a string. Accepted values are \"on\" and \"off\". They can be given in uppercase as well. \n\n" + + "\nExample:\n" + + "| Set Image Logging | OFF |\n") @ArgumentNames({ "value" }) public void setImageLogging(String value) { if (value.toLowerCase().equals("on")) From 65a97a652e9495d0b3793d1d073f226082b674fe Mon Sep 17 00:00:00 2001 From: Pasi Saikkonen Date: Mon, 3 Sep 2018 10:37:50 +0300 Subject: [PATCH 29/95] TestFX 4.0.13-alpha > 4.0.14-alpha --- pom.xml | 4 ++-- .../java/javafxlibrary/keywords/Keywords/KeyboardRobot.java | 3 --- src/main/java/javafxlibrary/keywords/Keywords/MouseRobot.java | 3 --- 3 files changed, 2 insertions(+), 8 deletions(-) diff --git a/pom.xml b/pom.xml index eb95e68..cf3150e 100644 --- a/pom.xml +++ b/pom.xml @@ -315,12 +315,12 @@ org.testfx testfx-core - 4.0.13-alpha + 4.0.14-alpha org.testfx testfx-junit - 4.0.13-alpha + 4.0.14-alpha org.testfx diff --git a/src/main/java/javafxlibrary/keywords/Keywords/KeyboardRobot.java b/src/main/java/javafxlibrary/keywords/Keywords/KeyboardRobot.java index f1779d7..ab6c70c 100644 --- a/src/main/java/javafxlibrary/keywords/Keywords/KeyboardRobot.java +++ b/src/main/java/javafxlibrary/keywords/Keywords/KeyboardRobot.java @@ -27,7 +27,6 @@ import org.robotframework.javalib.annotation.RobotKeywords; import org.testfx.api.FxRobot; import org.testfx.api.FxRobotInterface; -import org.testfx.api.annotation.Unstable; import java.awt.*; import java.awt.datatransfer.Clipboard; import java.awt.datatransfer.StringSelection; @@ -65,7 +64,6 @@ public FxRobotInterface press(String... keys) { + "| Release | CONTROL | SHIFT | G | \n" + "Note: passing in an empty list will release all pressed keys.\n\n") @ArgumentNames({ "*keys" }) - @Unstable(reason = "could be renamed to accept empty arrays") public FxRobotInterface release(String... keys) { try { RobotLog.info("Releasing keys: " + Arrays.asList(keys)); @@ -145,7 +143,6 @@ public FxRobotInterface eraseText(int amount) { } @RobotKeyword("Closes the current window, same as ALT + F4 in Windows \n\n") - @Unstable(reason = "maybe extract this into a new class") public FxRobotInterface closeCurrentWindow() { try { if (isMac()) { diff --git a/src/main/java/javafxlibrary/keywords/Keywords/MouseRobot.java b/src/main/java/javafxlibrary/keywords/Keywords/MouseRobot.java index 27773a1..0802bd1 100644 --- a/src/main/java/javafxlibrary/keywords/Keywords/MouseRobot.java +++ b/src/main/java/javafxlibrary/keywords/Keywords/MouseRobot.java @@ -25,7 +25,6 @@ import org.robotframework.javalib.annotation.RobotKeyword; import org.robotframework.javalib.annotation.RobotKeywords; import org.testfx.api.FxRobotInterface; -import org.testfx.api.annotation.Unstable; import java.util.Arrays; @@ -37,7 +36,6 @@ public class MouseRobot extends TestFxAdapter { + "\nExample: \n" + "| Press Mouse Button | PRIMARY | \n") @ArgumentNames({ "*buttons" }) - @Unstable(reason = "could be renamed to accept empty arrays") public FxRobotInterface pressMouseButton(String... buttons) { try { @@ -55,7 +53,6 @@ public FxRobotInterface pressMouseButton(String... buttons) { + "\nExample: \n" + "| Release Mouse Button | SECONDARY | \n") @ArgumentNames({ "*buttons" }) - @Unstable(reason = "could be renamed to accept empty arrays") public FxRobotInterface releaseMouseButton(String... buttons) { try { RobotLog.info("Releasing mouse buttons: \"" + Arrays.asList(buttons) + "\""); From b1b13a1e50f1144323f908f8ce69d88316ad019d Mon Sep 17 00:00:00 2001 From: Pasi Saikkonen Date: Mon, 3 Sep 2018 13:24:08 +0300 Subject: [PATCH 30/95] Reduce the size of images --- .../keywords/Keywords/ScreenCapturing.java | 27 ++++++++++++------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/src/main/java/javafxlibrary/keywords/Keywords/ScreenCapturing.java b/src/main/java/javafxlibrary/keywords/Keywords/ScreenCapturing.java index ae9bde0..d830b34 100644 --- a/src/main/java/javafxlibrary/keywords/Keywords/ScreenCapturing.java +++ b/src/main/java/javafxlibrary/keywords/Keywords/ScreenCapturing.java @@ -29,9 +29,8 @@ import org.robotframework.javalib.annotation.RobotKeywords; import javafx.scene.image.Image; import javax.imageio.ImageIO; -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; +import java.awt.image.BufferedImage; +import java.io.*; import java.net.MalformedURLException; import java.net.URL; import java.nio.file.Path; @@ -94,14 +93,10 @@ public Object captureImage(Object locator, boolean logImage){ Path tempPath = Paths.get(getCurrentSessionScreenshotDirectory(), "temp.png"); robotContext.getCaptureSupport().saveImage(resizedImage, tempPath); - File imageFile = tempPath.toFile(); + File imageFile = convertToJpeg(tempPath); byte[] imageBytes = IOUtils.toByteArray(new FileInputStream(imageFile)); String encodedImage = Base64.getEncoder().encodeToString(imageBytes); - - if (imageFile.delete()) - RobotLog.debug("Deleted temporary image file successfully."); - else - RobotLog.debug("Could not delete the file: " + imageFile.toString()); + imageFile.delete(); Double printSize = targetBounds.getWidth() > 800 ? 800 : targetBounds.getWidth(); System.out.println("*HTML* "); @@ -190,9 +185,21 @@ private static Image resizeImage(Image image, Path path) { double multiplier = width / 800; try { String url = path.toUri().toURL().toString(); - return new Image(url, width / multiplier, height / multiplier, true, false); + return new Image(url, width / multiplier, height / multiplier, true, true); } catch (MalformedURLException e) { throw new JavaFXLibraryNonFatalException("Unable to log the screenshot: image resizing failed!"); } } + + private File convertToJpeg(Path path) throws IOException { + BufferedImage bufferedImage; + bufferedImage = ImageIO.read(path.toFile()); + BufferedImage newBufferedImage = new BufferedImage(bufferedImage.getWidth(), + bufferedImage.getHeight(), BufferedImage.TYPE_INT_RGB); + newBufferedImage.createGraphics().drawImage(bufferedImage, 0, 0, java.awt.Color.WHITE, null); + path.toFile().delete(); + Path tempPathJpeg = Paths.get(getCurrentSessionScreenshotDirectory(), "temp.jpg"); + ImageIO.write(newBufferedImage, "jpg", tempPathJpeg.toFile()); + return tempPathJpeg.toFile(); + } } \ No newline at end of file From 3db7eb9a042d3ac8ee489076bacc97895c300089 Mon Sep 17 00:00:00 2001 From: Pasi Saikkonen Date: Mon, 3 Sep 2018 16:21:09 +0300 Subject: [PATCH 31/95] Handle EmptyNodeQueryExceptions in Finder --- .../java/javafxlibrary/utils/finder/Finder.java | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/main/java/javafxlibrary/utils/finder/Finder.java b/src/main/java/javafxlibrary/utils/finder/Finder.java index a7e6a82..e7687d3 100644 --- a/src/main/java/javafxlibrary/utils/finder/Finder.java +++ b/src/main/java/javafxlibrary/utils/finder/Finder.java @@ -23,6 +23,7 @@ import javafxlibrary.utils.RobotLog; import javafxlibrary.utils.TestFxAdapter; import org.testfx.api.FxRobotInterface; +import org.testfx.service.query.EmptyNodeQueryException; import java.util.*; @@ -141,13 +142,21 @@ private Set findAll(Parent root, int queryIndex) { private Node executeFind(Parent root, Query query) { RobotLog.debug("Executing find with root: " + root + " and query: " + query.getQuery()); - FindOperation findOperation = new FindOperation(root, query, false); - return (Node) findOperation.executeLookup(); + try { + FindOperation findOperation = new FindOperation(root, query, false); + return (Node) findOperation.executeLookup(); + } catch (EmptyNodeQueryException e) { + return null; + } } private Set executeFindAll(Parent root, Query query) { RobotLog.debug("Executing find all with root: " + root + " and query: " + query.getQuery()); - FindOperation findOperation = new FindOperation(root, query, true); - return new LinkedHashSet<>((Set)findOperation.executeLookup()); + try { + FindOperation findOperation = new FindOperation(root, query, true); + return new LinkedHashSet<>((Set)findOperation.executeLookup()); + } catch (EmptyNodeQueryException e) { + return Collections.emptySet(); + } } } From a70be776503f8078512bffe29c10523722e520ca Mon Sep 17 00:00:00 2001 From: Pasi Saikkonen Date: Wed, 5 Sep 2018 17:23:08 +0300 Subject: [PATCH 32/95] Enable finding non labeled text nodes --- .../utils/finder/FindOperation.java | 4 +- .../robotframework/acceptance/FindTest.robot | 62 ++++++++++++++++++- 2 files changed, 63 insertions(+), 3 deletions(-) diff --git a/src/main/java/javafxlibrary/utils/finder/FindOperation.java b/src/main/java/javafxlibrary/utils/finder/FindOperation.java index 464d451..0e91c85 100644 --- a/src/main/java/javafxlibrary/utils/finder/FindOperation.java +++ b/src/main/java/javafxlibrary/utils/finder/FindOperation.java @@ -25,8 +25,8 @@ import javafxlibrary.matchers.InstanceOfMatcher; import javafxlibrary.utils.TestFxAdapter; import org.testfx.api.FxRobotInterface; -import org.testfx.matcher.control.LabeledMatchers; import org.testfx.service.query.NodeQuery; +import org.testfx.util.NodeQueryUtils; import java.util.*; @@ -77,7 +77,7 @@ private Object executeLookup(FindPrefix prefix, String lookupQuery) { NodeQuery classLookupResults = classLookup(root, lookupQuery); return findAll ? classLookupResults.queryAll() : classLookupResults.query(); case TEXT: - NodeQuery textLookupResults = robot.from(root).lookup(LabeledMatchers.hasText(lookupQuery)); + NodeQuery textLookupResults = robot.from(root).lookup(NodeQueryUtils.hasText(lookupQuery)); return findAll ? textLookupResults.queryAll() : textLookupResults.query(); case XPATH: XPathFinder xPathFinder = new XPathFinder(); diff --git a/src/test/robotframework/acceptance/FindTest.robot b/src/test/robotframework/acceptance/FindTest.robot index a6a819f..a88a3b4 100644 --- a/src/test/robotframework/acceptance/FindTest.robot +++ b/src/test/robotframework/acceptance/FindTest.robot @@ -144,7 +144,18 @@ Find All With Pseudo Class Length Should Be ${hovered} 3 Should Contain ${hovered} ${node} -# TODO: Add test for text= prefix when next TestFX version comes out (4.0.14-alpha) +Find Text Node With Text + [Tags] smoke + Set Test App ${BOUNDS_APP} + ${result} Find text="300x150" + Parents Should Be Equal ${result} id=darkblue + +Find All Text Nodes With Text + [Tags] smoke + Set Test App ${BOUNDS_APP} + @{result} Find All text="75x75" + Length Should Be ${result} 6 + Get Length ${result} Nothing Is Found [Tags] smoke negative @@ -194,6 +205,45 @@ Previous Query Returns Nothing In Chained Selector With Find All When failIfNotF ${msg} Run Keyword And Expect Error * Find All css=VBox css=ZBox Pane id=lime true Should Be Equal ${msg} Unable to find anything with query: "css=VBox css=ZBox Pane id=lime" +Find Labeled Node With Text + [Tags] smoke + Set Test App javafxlibrary.testapps.TestWindowManagement + ${target} Find id=navigationDialog + ${result} Find text="Dialog Example" + Should Be Equal ${result} ${target} + +Find All Labeled Nodes With Text + [Tags] smoke + Set Test App javafxlibrary.testapps.TestWindowManagement + Open Dialog In Window Management App + Write To id=nameField labeled text + Write To id=phoneField labeled text + Click On text="Add" + ${result} Find All text="labeled text" + # Lookup returns textareas and their text as separate nodes + Length Should Be ${result} 4 + +Find TextInputControl Node With Text + [Tags] smoke + Set Test App javafxlibrary.testapps.TestWindowManagement + Open Dialog In Window Management App + Write To id=nameField Text input + ${result} Find text="Text input" + ${target} Find id=nameField + Click On text="Add" + Should Be Equal ${result} ${target} + +Find All TextInputControl Nodes With Text + [Tags] smoke + Set Test App javafxlibrary.testapps.TestWindowManagement + Open Dialog In Window Management App + Write To id=nameField Finder test + Write To id=phoneField Finder test + ${result} Find All text="Finder test" + Click On text="Add" + # Lookup returns textareas and their text as separate nodes + Length Should Be ${result} 4 + Find From Another Window [Tags] smoke Set Test App ${WINDOW_APP} @@ -280,6 +330,16 @@ Change Current Application Launch Javafx Application ${APPLICATION} Set Screenshot Directory ${OUTPUT_DIR}${/}report-images +Parents Should Be Equal + [Arguments] ${node1} ${node2} + ${parent1} Get Node Parent ${node1} + ${parent2} Get Node Parent ${node2} + Should Be Equal ${parent1} ${parent2} + +Open Dialog In Window Management App + Click On id=navigationDialog + Click On id=addEmployeeButton + Setup All Tests Import JavaFXLibrary Set Timeout 0 From 86f8cabde71719e38dcfacbdfaff5a4c59662da1 Mon Sep 17 00:00:00 2001 From: Juho Lehtonen Date: Thu, 20 Sep 2018 14:31:20 +0300 Subject: [PATCH 33/95] Optimized docker env --- AUTHORS.txt | 3 ++- docker-compose.yml | 5 +---- docker/robot-javafx-demo/Dockerfile | 12 ------------ 3 files changed, 3 insertions(+), 17 deletions(-) diff --git a/AUTHORS.txt b/AUTHORS.txt index 2a85cf4..e294876 100644 --- a/AUTHORS.txt +++ b/AUTHORS.txt @@ -5,4 +5,5 @@ Pasi Saikkonen 2017 - Other contributors: Tatu Lahtela Find All With Pseudo Class and Find Class keywords -Sakari Hoisko Dockerized linux env with X +Sakari Hoisko Dockerized linux env with X +Juho Lehtonen Optimized docker environment. diff --git a/docker-compose.yml b/docker-compose.yml index 331e340..6c63797 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,12 +5,10 @@ services: build: context: ./docker/robot-javafx-demo ports: - #- '5900:5900' - '80:80' volumes: - './src/test/robotframework/:/robot' - screen-thing:/tmp/.X11-unix - - './src/:/src' # ScreenCapturingTest.robot require this. - javafxbinaryshare:/javafxbinary networks: - testapp @@ -25,8 +23,7 @@ services: networks: - testapp volumes: - - './src/test/robotframework/:/robot' # Screen capures are saved to here "hack until remote usage copy photos to results folder" - - './src/:/src' # ScreenCapturingTest.robot require this. + - './src/test/robotframework/:/robot' # Required for executing tests from robot-framework container - screen-thing:/tmp/.X11-unix - javafxbinaryshare:/javafxbinary environment: diff --git a/docker/robot-javafx-demo/Dockerfile b/docker/robot-javafx-demo/Dockerfile index 24c0aa3..fe1dbac 100644 --- a/docker/robot-javafx-demo/Dockerfile +++ b/docker/robot-javafx-demo/Dockerfile @@ -3,20 +3,12 @@ FROM dorowu/ubuntu-desktop-lxde-vnc ENV DEBIAN_FRONTEND noninteractive RUN apt-get -qq update && apt-get dist-upgrade -y && apt-get install -qq --no-install-recommends --allow-unauthenticated -y \ - dbus \ openssh-client \ - x11vnc \ - xvfb \ - bash \ xterm \ - fluxbox \ python-pip \ git \ - nano \ python-setuptools \ wget \ - xvfb \ - xorg \ openjdk-8-jre \ openjfx \ && apt-get clean && rm -rf /var/lib/apt/lists/* @@ -25,10 +17,6 @@ COPY test.sh /bin/test.sh RUN pip install --no-cache-dir \ robotframework && chmod 555 /bin/test.sh -# JUST VNC -#COPY entrypoint.sh /entrypoint.sh -#RUN mkdir ~/.vnc && x11vnc -storepasswd 1234 ~/.vnc/passwd && chmod 555 /entrypoint.sh /bin/test.sh -#ENTRYPOINT ["x11vnc", "-create", "-forever", "-env", "FD_PROG=/entrypoint.sh", "-env", "X11VNC_CREATE_GEOM=${1:-1024x768x16}", "-usepw"] EXPOSE 5900 80 ENTRYPOINT ["/startup.sh"] From 5bed94dc2d850a83abd782f056f16238ff572377 Mon Sep 17 00:00:00 2001 From: Ext Haavisto Jukka Date: Wed, 10 Oct 2018 10:10:10 +0300 Subject: [PATCH 34/95] updated documentation --- src/main/java/libdoc-documentation.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/libdoc-documentation.txt b/src/main/java/libdoc-documentation.txt index 875630b..20d20f0 100644 --- a/src/main/java/libdoc-documentation.txt +++ b/src/main/java/libdoc-documentation.txt @@ -148,7 +148,7 @@ with complex data structures. == 5. Used ENUMs == | [https://github.com/TestFX/TestFX/blob/master/subprojects/testfx-core/src/main/java/org/testfx/robot/Motion.java|Motion] | DEFAULT, DIRECT, HORIZONTAL_FIRST, VERTICAL_FIRST | | [https://docs.oracle.com/javafx/2/api/javafx/scene/input/MouseButton.html|MouseButton] | MIDDLE, NONE, PRIMARY, SECONDARY | -| [https://docs.oracle.com/javafx/2/api/javafx/scene/input/KeyCode.html|KeyCode] | Check the link | +| [https://docs.oracle.com/javafx/2/api/javafx/scene/input/KeyCode.html|KeyCode] | Check the link 'KeyCode' on the left | | [https://docs.oracle.com/javase/7/docs/api/java/util/concurrent/TimeUnit.html|TimeUnit] | DAYS, HOURS, MICROSECONDS, MILLISECONDS, MINUTES, NANOSECONDS, SECONDS | | [https://docs.oracle.com/javafx/2/api/javafx/geometry/VerticalDirection.html|VerticalDirection] | UP, DOWN | | [https://docs.oracle.com/javafx/2/api/javafx/geometry/HorizontalDirection.html|HorizontalDirection] | LEFT, RIGHT | From dc9ca79180b11092f447198ee2e39508b54d917e Mon Sep 17 00:00:00 2001 From: Ext Haavisto Jukka Date: Fri, 12 Oct 2018 08:41:19 +0300 Subject: [PATCH 35/95] refactored image logging --- .../AdditionalKeywords/RunOnFailure.java | 15 +++---- .../keywords/Keywords/ScreenCapturing.java | 45 +++++++++++-------- .../java/javafxlibrary/utils/RobotLog.java | 5 +++ .../javafxlibrary/utils/TestFxAdapter.java | 2 +- .../acceptance/0_ClickRobotTest.robot | 2 +- .../acceptance/BoundsLocationTest.robot | 2 +- .../acceptance/DatePickerTest.robot | 2 +- .../acceptance/DragRobotTest.robot | 2 +- .../robotframework/acceptance/FindTest.robot | 2 +- .../acceptance/KeyboardRobotTest.robot | 2 +- .../acceptance/MenuAppTest.robot | 2 +- .../robotframework/acceptance/MiscTests.robot | 2 +- .../acceptance/MoveRobotTest.robot | 2 +- .../acceptance/NodeLookupTest.robot | 2 +- .../acceptance/PointLocationTest.robot | 2 +- .../acceptance/ScreenCapturingTest.robot | 2 +- .../acceptance/ScrollRobotTest.robot | 2 +- .../acceptance/ScrollRobotTest2.robot | 2 +- .../SwingApplicationWrapperTest.robot | 2 +- .../acceptance/WindowLookupTest.robot | 2 +- .../acceptance/WindowManagementTest.robot | 2 +- .../acceptance/WindowTargetingTest.robot | 2 +- src/test/robotframework/resource.robot | 6 +-- 23 files changed, 59 insertions(+), 50 deletions(-) diff --git a/src/main/java/javafxlibrary/keywords/AdditionalKeywords/RunOnFailure.java b/src/main/java/javafxlibrary/keywords/AdditionalKeywords/RunOnFailure.java index d6e6d0a..bd94c52 100644 --- a/src/main/java/javafxlibrary/keywords/AdditionalKeywords/RunOnFailure.java +++ b/src/main/java/javafxlibrary/keywords/AdditionalKeywords/RunOnFailure.java @@ -55,18 +55,15 @@ public void runOnFailure() { runningOnFailureRoutine = true; + RobotLog.info("JavaFXLibrary keyword has failed!"); if (robot == null) { RobotLog.error("FxRobot not initialized, launch test application with the library"); - } else if (TestFxAdapter.logImages) { - RobotLog.info("JavaFxLibrary keyword has failed! Below a screenshot from erroneous situation:"); - if (robot.targetWindow() != null) { - new ScreenCapturing().captureImage(robot.targetWindow()); - } else - new ScreenCapturing().captureImage(Screen.getPrimary().getBounds()); + } + + if (robot.targetWindow() != null) { + new ScreenCapturing().captureImage(robot.targetWindow()); } else { - RobotLog.info("JavaFXLibrary keyword has failed!"); - RobotLog.info("Not taking a screenshot since Set Image Logging is set to off. To enable screenshots " + - "on failed keywords, use keyword 'Set Image Logging ON'"); + new ScreenCapturing().captureImage(Screen.getPrimary().getBounds()); } runningOnFailureRoutine = false; diff --git a/src/main/java/javafxlibrary/keywords/Keywords/ScreenCapturing.java b/src/main/java/javafxlibrary/keywords/Keywords/ScreenCapturing.java index d830b34..d855160 100644 --- a/src/main/java/javafxlibrary/keywords/Keywords/ScreenCapturing.java +++ b/src/main/java/javafxlibrary/keywords/Keywords/ScreenCapturing.java @@ -44,24 +44,24 @@ @RobotKeywords public class ScreenCapturing extends TestFxAdapter { - @RobotKeyword("Sets whether to log images into the log.html file or not.\n\n" - + "Argument ``value`` is a string. Accepted values are \"on\" and \"off\". They can be given in uppercase as well. \n\n" + @RobotKeyword("Sets whether to embed log images directly into the log.html file or as a link to a file on local disk.\n\n" + + "Argument ``value`` is a string. Accepted values are ``embedded`` (initial value) and ``diskonly``. They can be given in uppercase as well. \n\n" + "\nExample:\n" - + "| Set Image Logging | OFF |\n") + + "| Set Image Logging | DISKONLY |\n") @ArgumentNames({ "value" }) public void setImageLogging(String value) { - if (value.toLowerCase().equals("on")) - TestFxAdapter.logImages = true; - else if (value.toLowerCase().equals("off")) - TestFxAdapter.logImages = false; + if (value.toLowerCase().equals("embedded")) + TestFxAdapter.logImages = "embedded"; + else if (value.toLowerCase().equals("diskonly")) + TestFxAdapter.logImages = "diskonly"; else throw new JavaFXLibraryNonFatalException("Value \"" + value + "\" is not supported! Value must be either " + - "\"ON\" or \"OFF\""); + "\"EMBEDDED\" or \"DISKONLY\""); } @RobotKeywordOverload public Object captureImage(Object locator){ - return captureImage(locator, TestFxAdapter.logImages); + return captureImage(locator, true); } @RobotKeyword("Returns a screenshot of the given locator.\n\n" @@ -89,17 +89,24 @@ public Object captureImage(Object locator, boolean logImage){ robotContext.getCaptureSupport().saveImage(image, path); if (logImage) { - Image resizedImage = resizeImage(image, path); - Path tempPath = Paths.get(getCurrentSessionScreenshotDirectory(), "temp.png"); - robotContext.getCaptureSupport().saveImage(resizedImage, tempPath); + Double printSize = targetBounds.getWidth() > 800 ? 800 : targetBounds.getWidth(); - File imageFile = convertToJpeg(tempPath); - byte[] imageBytes = IOUtils.toByteArray(new FileInputStream(imageFile)); - String encodedImage = Base64.getEncoder().encodeToString(imageBytes); - imageFile.delete(); + if(TestFxAdapter.logImages.toLowerCase().equals("embedded")) { + Image resizedImage = resizeImage(image, path); + Path tempPath = Paths.get(getCurrentSessionScreenshotDirectory(), "temp.png"); + robotContext.getCaptureSupport().saveImage(resizedImage, tempPath); - Double printSize = targetBounds.getWidth() > 800 ? 800 : targetBounds.getWidth(); - System.out.println("*HTML* "); + File imageFile = convertToJpeg(tempPath); + byte[] imageBytes = IOUtils.toByteArray(new FileInputStream(imageFile)); + String encodedImage = Base64.getEncoder().encodeToString(imageBytes); + imageFile.delete(); + + RobotLog.html(""); + + } else { + // diskonly option + RobotLog.html(""); + } } return mapObject(image); @@ -181,7 +188,7 @@ private static Image resizeImage(Image image, Path path) { if (width < 800) return image; - RobotLog.info("Full resolution image can be found at " + path); + RobotLog.html("Full resolution image can be found from " + path + "."); double multiplier = width / 800; try { String url = path.toUri().toURL().toString(); diff --git a/src/main/java/javafxlibrary/utils/RobotLog.java b/src/main/java/javafxlibrary/utils/RobotLog.java index 1ca9948..2149a5d 100644 --- a/src/main/java/javafxlibrary/utils/RobotLog.java +++ b/src/main/java/javafxlibrary/utils/RobotLog.java @@ -22,6 +22,11 @@ public static void info(String message) { System.out.println("*INFO* " + message); } + public static void html(String message) { + if (shouldLogMessage(message)) + System.out.println("*HTML* " + message); + } + public static void debug(String message) { if (shouldLogMessage(message)) System.out.println("*DEBUG* " + message); diff --git a/src/main/java/javafxlibrary/utils/TestFxAdapter.java b/src/main/java/javafxlibrary/utils/TestFxAdapter.java index 9a093cd..4ce01d9 100644 --- a/src/main/java/javafxlibrary/utils/TestFxAdapter.java +++ b/src/main/java/javafxlibrary/utils/TestFxAdapter.java @@ -44,7 +44,7 @@ public static void setRobotContext(FxRobotContext context) { // TODO: consider adding support for multiple sessions private static Session activeSession = null; - protected static boolean logImages = true; + protected static String logImages = "embedded"; // internal book keeping for objects public static HashMap objectMap = new HashMap(); diff --git a/src/test/robotframework/acceptance/0_ClickRobotTest.robot b/src/test/robotframework/acceptance/0_ClickRobotTest.robot index 99d9b32..7b46658 100644 --- a/src/test/robotframework/acceptance/0_ClickRobotTest.robot +++ b/src/test/robotframework/acceptance/0_ClickRobotTest.robot @@ -266,7 +266,7 @@ Setup all tests Setup test case Reset Counters - Disable Image Logging For Negative Tests + Disable Embedded Image Logging For Negative Tests Teardown all tests Close Javafx Application diff --git a/src/test/robotframework/acceptance/BoundsLocationTest.robot b/src/test/robotframework/acceptance/BoundsLocationTest.robot index 50d0109..9a5364b 100644 --- a/src/test/robotframework/acceptance/BoundsLocationTest.robot +++ b/src/test/robotframework/acceptance/BoundsLocationTest.robot @@ -3,7 +3,7 @@ Documentation Tests to test javafxlibrary.keywords.BoundsLocation related Resource ../resource.robot Suite Setup Setup all tests Suite Teardown Teardown all tests -Test Setup Disable Image Logging For Negative Tests +Test Setup Disable Embedded Image Logging For Negative Tests Test Teardown Enable Image Logging Force Tags set-boundslocation diff --git a/src/test/robotframework/acceptance/DatePickerTest.robot b/src/test/robotframework/acceptance/DatePickerTest.robot index 8acaf5a..54fd39e 100644 --- a/src/test/robotframework/acceptance/DatePickerTest.robot +++ b/src/test/robotframework/acceptance/DatePickerTest.robot @@ -3,7 +3,7 @@ Documentation Tests to test DatePicker related keywords Resource ../resource.robot Suite Setup Setup all tests Suite Teardown Teardown all tests -Test Setup Disable Image Logging For Negative Tests +Test Setup Disable Embedded Image Logging For Negative Tests Test Teardown Teardown test case Force Tags set-datepicker diff --git a/src/test/robotframework/acceptance/DragRobotTest.robot b/src/test/robotframework/acceptance/DragRobotTest.robot index ebba3e2..9ce1efe 100644 --- a/src/test/robotframework/acceptance/DragRobotTest.robot +++ b/src/test/robotframework/acceptance/DragRobotTest.robot @@ -3,7 +3,7 @@ Documentation Tests to test javafxlibrary.keywords.DragRobot related keywo Resource ../resource.robot Suite Setup Setup all tests Suite Teardown Teardown all tests -Test Setup Disable Image Logging For Negative Tests +Test Setup Disable Embedded Image Logging For Negative Tests Test Teardown Enable Image Logging Force tags set-dragrobot diff --git a/src/test/robotframework/acceptance/FindTest.robot b/src/test/robotframework/acceptance/FindTest.robot index e548471..dfcede7 100644 --- a/src/test/robotframework/acceptance/FindTest.robot +++ b/src/test/robotframework/acceptance/FindTest.robot @@ -3,7 +3,7 @@ Documentation Tests to test javafxlibrary.keywords.AdditionalKeywords.Find Resource ../resource.robot Suite Setup Setup All Tests Suite Teardown Teardown all tests -Test Setup Disable Image Logging For Negative Tests +Test Setup Disable Embedded Image Logging For Negative Tests Test Teardown Enable Image Logging Force Tags set-find diff --git a/src/test/robotframework/acceptance/KeyboardRobotTest.robot b/src/test/robotframework/acceptance/KeyboardRobotTest.robot index fc5cde6..4a2facc 100644 --- a/src/test/robotframework/acceptance/KeyboardRobotTest.robot +++ b/src/test/robotframework/acceptance/KeyboardRobotTest.robot @@ -3,7 +3,7 @@ Documentation Tests to test javafxlibrary.keywords.KeyboardRobot related k Resource ../resource.robot Suite Setup Setup all tests Suite Teardown Teardown all tests -Test Setup Disable Image Logging For Negative Tests +Test Setup Disable Embedded Image Logging For Negative Tests Test Teardown Enable Image Logging Force Tags set-keyboardrobot diff --git a/src/test/robotframework/acceptance/MenuAppTest.robot b/src/test/robotframework/acceptance/MenuAppTest.robot index be0205d..4facb62 100644 --- a/src/test/robotframework/acceptance/MenuAppTest.robot +++ b/src/test/robotframework/acceptance/MenuAppTest.robot @@ -3,7 +3,7 @@ Documentation Tests to test javafxlibrary keywords Resource ../resource.robot Suite Setup Setup all tests Suite Teardown Teardown all tests -Test Setup Disable Image Logging For Negative Tests +Test Setup Disable Embedded Image Logging For Negative Tests Test Teardown Enable Image Logging Force Tags set-menuapp diff --git a/src/test/robotframework/acceptance/MiscTests.robot b/src/test/robotframework/acceptance/MiscTests.robot index 4f7897e..20aaa9b 100644 --- a/src/test/robotframework/acceptance/MiscTests.robot +++ b/src/test/robotframework/acceptance/MiscTests.robot @@ -5,7 +5,7 @@ Library Collections Library String Suite Setup Setup All Tests Suite Teardown Close Javafx Application -Test Setup Disable Image Logging For Negative Tests +Test Setup Disable Embedded Image Logging For Negative Tests Test Teardown Enable Image Logging *** Variables *** diff --git a/src/test/robotframework/acceptance/MoveRobotTest.robot b/src/test/robotframework/acceptance/MoveRobotTest.robot index 4701fc2..6852c8b 100644 --- a/src/test/robotframework/acceptance/MoveRobotTest.robot +++ b/src/test/robotframework/acceptance/MoveRobotTest.robot @@ -96,7 +96,7 @@ Setup all tests Setup test case Move To Top Left Corner - Disable Image Logging For Negative Tests + Disable Embedded Image Logging For Negative Tests Teardown all tests Close Javafx Application diff --git a/src/test/robotframework/acceptance/NodeLookupTest.robot b/src/test/robotframework/acceptance/NodeLookupTest.robot index d7b5e46..6350eff 100644 --- a/src/test/robotframework/acceptance/NodeLookupTest.robot +++ b/src/test/robotframework/acceptance/NodeLookupTest.robot @@ -3,7 +3,7 @@ Documentation Tests to test javafxlibrary.keywords.NodeLookup related keyw Resource ../resource.robot Suite Setup Setup all tests Suite Teardown Teardown all tests -Test Setup Disable Image Logging For Negative Tests +Test Setup Disable Embedded Image Logging For Negative Tests Test Teardown Enable Image Logging Force Tags set-nodelookup diff --git a/src/test/robotframework/acceptance/PointLocationTest.robot b/src/test/robotframework/acceptance/PointLocationTest.robot index 251f9af..701c5aa 100644 --- a/src/test/robotframework/acceptance/PointLocationTest.robot +++ b/src/test/robotframework/acceptance/PointLocationTest.robot @@ -3,7 +3,7 @@ Documentation Tests to test javafxlibrary.keywords.PointLocation and Point Resource ../resource.robot Suite Setup Setup all tests Suite Teardown Teardown all tests -Test Setup Disable Image Logging For Negative Tests +Test Setup Disable Embedded Image Logging For Negative Tests Test Teardown Enable Image Logging Force Tags set-pointlocation set-pointoffset diff --git a/src/test/robotframework/acceptance/ScreenCapturingTest.robot b/src/test/robotframework/acceptance/ScreenCapturingTest.robot index e2ae9ab..b415c9d 100644 --- a/src/test/robotframework/acceptance/ScreenCapturingTest.robot +++ b/src/test/robotframework/acceptance/ScreenCapturingTest.robot @@ -4,7 +4,7 @@ Library String Resource ../resource.robot Suite Setup Setup all tests Suite Teardown Teardown all tests -Test Setup Disable Image Logging For Negative Tests +Test Setup Disable Embedded Image Logging For Negative Tests Test Teardown Enable Image Logging Force Tags set-screencapturing diff --git a/src/test/robotframework/acceptance/ScrollRobotTest.robot b/src/test/robotframework/acceptance/ScrollRobotTest.robot index c7e6fd2..f84cc8d 100644 --- a/src/test/robotframework/acceptance/ScrollRobotTest.robot +++ b/src/test/robotframework/acceptance/ScrollRobotTest.robot @@ -3,7 +3,7 @@ Documentation Tests to test javafxlibrary.keywords.ScrollRobot related key Resource ../resource.robot Suite Setup Setup all tests Suite Teardown Teardown all tests -Test Setup Disable Image Logging For Negative Tests +Test Setup Disable Embedded Image Logging For Negative Tests Test Teardown Enable Image Logging Force Tags set-scrollrobot diff --git a/src/test/robotframework/acceptance/ScrollRobotTest2.robot b/src/test/robotframework/acceptance/ScrollRobotTest2.robot index c5f3918..abe7f4c 100644 --- a/src/test/robotframework/acceptance/ScrollRobotTest2.robot +++ b/src/test/robotframework/acceptance/ScrollRobotTest2.robot @@ -3,7 +3,7 @@ Documentation Tests to test javafxlibrary.keywords.ScrollRobot related key Resource ../resource.robot Suite Setup Setup all tests Suite Teardown Teardown all tests -Test Setup Disable Image Logging For Negative Tests +Test Setup Disable Embedded Image Logging For Negative Tests Test Teardown Enable Image Logging Force Tags set-scrollrobot diff --git a/src/test/robotframework/acceptance/SwingApplicationWrapperTest.robot b/src/test/robotframework/acceptance/SwingApplicationWrapperTest.robot index 3b70479..430e053 100644 --- a/src/test/robotframework/acceptance/SwingApplicationWrapperTest.robot +++ b/src/test/robotframework/acceptance/SwingApplicationWrapperTest.robot @@ -3,7 +3,7 @@ Documentation Tests for handling Swing embedded JavaFX nodes Resource ../resource.robot Force Tags set-embedded Suite Setup Import JavaFXLibrary -Test Setup Disable Image Logging For Negative Tests +Test Setup Disable Embedded Image Logging For Negative Tests Test Teardown Teardown Test Case *** Testcases *** diff --git a/src/test/robotframework/acceptance/WindowLookupTest.robot b/src/test/robotframework/acceptance/WindowLookupTest.robot index ed3c4da..a0fb5fd 100644 --- a/src/test/robotframework/acceptance/WindowLookupTest.robot +++ b/src/test/robotframework/acceptance/WindowLookupTest.robot @@ -3,7 +3,7 @@ Documentation Tests to test javafxlibrary.keywords.WindowLookup related ke Resource ../resource.robot Suite Setup Setup all tests Suite Teardown Teardown all tests -Test Setup Disable Image Logging For Negative Tests +Test Setup Disable Embedded Image Logging For Negative Tests Test Teardown Enable Image Logging Force Tags set-windowlookup diff --git a/src/test/robotframework/acceptance/WindowManagementTest.robot b/src/test/robotframework/acceptance/WindowManagementTest.robot index 64271fd..5b22ecf 100644 --- a/src/test/robotframework/acceptance/WindowManagementTest.robot +++ b/src/test/robotframework/acceptance/WindowManagementTest.robot @@ -3,7 +3,7 @@ Documentation Tests for Window Management Resource ../resource.robot Suite Setup Setup all tests Suite Teardown Teardown all tests -Test Setup Disable Image Logging For Negative Tests +Test Setup Disable Embedded Image Logging For Negative Tests Test Teardown Enable Image Logging Force Tags set-windowmanagement diff --git a/src/test/robotframework/acceptance/WindowTargetingTest.robot b/src/test/robotframework/acceptance/WindowTargetingTest.robot index 1ac719b..1bd7b00 100644 --- a/src/test/robotframework/acceptance/WindowTargetingTest.robot +++ b/src/test/robotframework/acceptance/WindowTargetingTest.robot @@ -3,7 +3,7 @@ Documentation Tests to test javafxlibrary.keywords.WindowTargeting related Resource ../resource.robot Suite Setup Setup all tests Suite Teardown Teardown all tests -Test Setup Disable Image Logging For Negative Tests +Test Setup Disable Embedded Image Logging For Negative Tests Test Teardown Enable Image Logging Force Tags set-windowtargeting diff --git a/src/test/robotframework/resource.robot b/src/test/robotframework/resource.robot index 0a60748..2802640 100644 --- a/src/test/robotframework/resource.robot +++ b/src/test/robotframework/resource.robot @@ -3,9 +3,9 @@ Import JavaFXLibrary Run Keyword If sys.platform.startswith('java') Import Library JavaFXLibrary ... ELSE Import Library Remote http://javafxcompile:8270 WITH NAME RemoteJavaFXLibrary -Disable Image Logging For Negative Tests +Disable Embedded Image Logging For Negative Tests :FOR ${tag} IN @{TEST TAGS} - \ Run Keyword If '${tag}' == 'negative' Set Image Logging OFF + \ Run Keyword If '${tag}' == 'negative' Set Image Logging DISKONLY Enable Image Logging - Set Image Logging ON + Set Image Logging EMBEDDED From 647b36c4ad2048317ccec2e9452fd56fce1d1c35 Mon Sep 17 00:00:00 2001 From: Ext Haavisto Jukka Date: Fri, 12 Oct 2018 08:59:36 +0300 Subject: [PATCH 36/95] version to 0.5.1 --- docs/javafxlibrary.html | 2 +- pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/javafxlibrary.html b/docs/javafxlibrary.html index b5c22bd..de3aa26 100644 --- a/docs/javafxlibrary.html +++ b/docs/javafxlibrary.html @@ -547,7 +547,7 @@ jQuery.extend({highlight:function(e,t,n,r){if(e.nodeType===3){var i=e.data.match(t);if(i){var s=document.createElement(n||"span");s.className=r||"highlight";var o=e.splitText(i.index);o.splitText(i[0].length);var u=o.cloneNode(true);s.appendChild(u);o.parentNode.replaceChild(s,o);return 1}}else if(e.nodeType===1&&e.childNodes&&!/(script|style)/i.test(e.tagName)&&!(e.tagName===n.toUpperCase()&&e.className===r)){for(var a=0;a Codestin Search App diff --git a/pom.xml b/pom.xml index cf3150e..43341a4 100644 --- a/pom.xml +++ b/pom.xml @@ -21,7 +21,7 @@ org.robotframework javafxlibrary jar - 0.5.0-SNAPSHOT + 0.5.1 UTF-8 From b844b69c2acf1c4f421780c0ced30b223034c3c8 Mon Sep 17 00:00:00 2001 From: Ext Haavisto Jukka Date: Fri, 12 Oct 2018 12:13:39 +0300 Subject: [PATCH 37/95] 0.5.2-SNAPSHOT --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 43341a4..372bf1d 100644 --- a/pom.xml +++ b/pom.xml @@ -21,7 +21,7 @@ org.robotframework javafxlibrary jar - 0.5.1 + 0.5.2-SNAPSHOT UTF-8 From 7e50b03478a62f0df478240bfa0a438bd65ff67b Mon Sep 17 00:00:00 2001 From: Sami Pesonen Date: Fri, 12 Oct 2018 14:23:46 +0300 Subject: [PATCH 38/95] update README to have Maven Central link for releases --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index fc81a4a..e6b25a7 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ See keyword [documentation](https://eficode.github.io/JavaFXLibrary/javafxlibrar ## Taking the library into use ### As a local library -1. Download JavaFXLibrary jar file from [releases](https://github.com/eficode/JavaFXLibrary/releases/) +1. Download JavaFXLibrary jar file from [releases](https://github.com/eficode/JavaFXLibrary/releases/) or [Maven Central](https://search.maven.org/artifact/org.robotframework/javafxlibrary). 2. Import JavaFXLibrary in test settings: ``` *** Settings *** @@ -23,7 +23,7 @@ jython -J-cp javafxlibrary-.jar -m robot.run tests.robot ``` ### As a remote library -1. Download JavaFXLibrary jar file from [releases](https://github.com/eficode/JavaFXLibrary/releases/) +1. Download JavaFXLibrary jar file from [releases](https://github.com/eficode/JavaFXLibrary/releases/) or [Maven Central](https://search.maven.org/artifact/org.robotframework/javafxlibrary). 2. Start JavaFXLibrary as a remote library: `java -jar javafxlibrary-.jar` - Remote library starts in port [8270](http://localhost:8270) by default. - Port number can also be defined in the start command: `java -jar javafxlibrary-.jar 1234` From 5d5b945b2c97f286a33ae2668f40fdb6d98b7656 Mon Sep 17 00:00:00 2001 From: Pasi Saikkonen Date: Mon, 5 Nov 2018 17:12:35 +0200 Subject: [PATCH 39/95] Add instructions for enabling accessibility features on MacOS Mojave --- README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/README.md b/README.md index e6b25a7..dee4a32 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,16 @@ JavaFXLibrary is tested to work with Robot Framework 3.0.2 or later. See keyword [documentation](https://eficode.github.io/JavaFXLibrary/javafxlibrary.html). ## Taking the library into use +### On MacOS Mojave +MacOS Mojave introduced changes to security settings and disabled some of the features JavaFXLibrary uses by default. +To use JavaFXLibrary on MacOS Mojave you must enable the accessibility features for terminal in system preferences: +- Navigate to `Apple menu > System Preferences > Security & Privacy > Privacy > Accessibility`. +- Click the lock and enter your password to change these settings +- If terminal has requested accessibility features before, it should show in the list +- If not, add it by clicking :heavy_plus_sign: and selecting `Applications > Utilities > Terminal` +- Enable accessibility features by checking the box +- :white_check_mark: Terminal + ### As a local library 1. Download JavaFXLibrary jar file from [releases](https://github.com/eficode/JavaFXLibrary/releases/) or [Maven Central](https://search.maven.org/artifact/org.robotframework/javafxlibrary). 2. Import JavaFXLibrary in test settings: From e047c4c987be3a259da7d5b1a99e600cbde44ce7 Mon Sep 17 00:00:00 2001 From: Pasi Saikkonen Date: Mon, 5 Nov 2018 17:27:14 +0200 Subject: [PATCH 40/95] Adjust readme --- README.md | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index dee4a32..9d5acd1 100644 --- a/README.md +++ b/README.md @@ -10,16 +10,6 @@ JavaFXLibrary is tested to work with Robot Framework 3.0.2 or later. See keyword [documentation](https://eficode.github.io/JavaFXLibrary/javafxlibrary.html). ## Taking the library into use -### On MacOS Mojave -MacOS Mojave introduced changes to security settings and disabled some of the features JavaFXLibrary uses by default. -To use JavaFXLibrary on MacOS Mojave you must enable the accessibility features for terminal in system preferences: -- Navigate to `Apple menu > System Preferences > Security & Privacy > Privacy > Accessibility`. -- Click the lock and enter your password to change these settings -- If terminal has requested accessibility features before, it should show in the list -- If not, add it by clicking :heavy_plus_sign: and selecting `Applications > Utilities > Terminal` -- Enable accessibility features by checking the box -- :white_check_mark: Terminal - ### As a local library 1. Download JavaFXLibrary jar file from [releases](https://github.com/eficode/JavaFXLibrary/releases/) or [Maven Central](https://search.maven.org/artifact/org.robotframework/javafxlibrary). 2. Import JavaFXLibrary in test settings: @@ -44,6 +34,15 @@ Library Remote http://127.0.0.1:8270 WITH NAME JavaFXLibrary ``` 4. Run your tests: `robot tests.robot` +## Using JavaFXLibrary on macOS Mojave +MacOS Mojave introduced changes to security settings and disabled some of the features JavaFXLibrary uses by default. +To use JavaFXLibrary on macOS Mojave you must enable the accessibility features for terminal in system preferences: +- Navigate to `Apple menu > System Preferences > Security & Privacy > Privacy > Accessibility` +- Click the lock and enter your password to change these settings +- If terminal has requested accessibility features before it should show in the list +- If not, add it by clicking :heavy_plus_sign: and selecting `Applications > Utilities > Terminal` +- Enable accessibility features by checking the box: :white_check_mark: Terminal + ## Identifying JavaFX UI objects [Scenic View](http://fxexperience.com/scenic-view/) is a tool that allows you to inspect the JavaFX application scenegraph. This can be useful especially when you do not have access to the source code. From c4d819d32a3455bece2eab0e76dbd14acc9f699f Mon Sep 17 00:00:00 2001 From: Pasi Saikkonen Date: Fri, 9 Nov 2018 15:32:22 +0200 Subject: [PATCH 41/95] Get FxRobotContext from the active sessionRobot in TestFxAdapter --- pom.xml | 5 ----- .../keywords/AdditionalKeywords/Verifiers.java | 4 ++-- .../keywords/Keywords/ScreenCapturing.java | 6 +++--- src/main/java/javafxlibrary/utils/Session.java | 7 +++---- .../javafxlibrary/utils/TestFxAdapter.java | 18 +++++------------- 5 files changed, 13 insertions(+), 27 deletions(-) diff --git a/pom.xml b/pom.xml index 372bf1d..72ac47c 100644 --- a/pom.xml +++ b/pom.xml @@ -317,11 +317,6 @@ testfx-core 4.0.14-alpha - - org.testfx - testfx-junit - 4.0.14-alpha - org.testfx openjfx-monocle diff --git a/src/main/java/javafxlibrary/keywords/AdditionalKeywords/Verifiers.java b/src/main/java/javafxlibrary/keywords/AdditionalKeywords/Verifiers.java index f9b0c16..fa48610 100644 --- a/src/main/java/javafxlibrary/keywords/AdditionalKeywords/Verifiers.java +++ b/src/main/java/javafxlibrary/keywords/AdditionalKeywords/Verifiers.java @@ -252,7 +252,7 @@ public void imagesShouldMatch(Image image1, Image image2, double percentage) { throw new JavaFXLibraryNonFatalException("Images must be same size to compare: Image1 is " + (int)image1.getWidth() + "x" + (int)image1.getHeight() + " and Image2 is " + (int)image2.getWidth() + "x" + (int)image2.getHeight()); - PixelMatcherResult result = robotContext.getCaptureSupport().matchImages(image1, image2, new PixelMatcherRgb()); + PixelMatcherResult result = robotContext().getCaptureSupport().matchImages(image1, image2, new PixelMatcherRgb()); int sharedPixels = (int) (result.getMatchFactor() * 100); RobotLog.info("Matching pixels: " + sharedPixels + "%"); @@ -280,7 +280,7 @@ public void imagesShouldNotMatch(Image image1, Image image2, double percentage) throw new JavaFXLibraryNonFatalException("Images must be same size to compare: Image1 is " + (int)image1.getWidth() + "x" + (int)image1.getHeight() + " and Image2 is " + (int)image2.getWidth() + "x" + (int)image2.getHeight()); - PixelMatcherResult result = robotContext.getCaptureSupport().matchImages(image1, image2, new PixelMatcherRgb()); + PixelMatcherResult result = robotContext().getCaptureSupport().matchImages(image1, image2, new PixelMatcherRgb()); int nonSharedPixels = (int) (result.getNonMatchFactor() * 100); RobotLog.info("Matching pixels: " + nonSharedPixels + "%"); diff --git a/src/main/java/javafxlibrary/keywords/Keywords/ScreenCapturing.java b/src/main/java/javafxlibrary/keywords/Keywords/ScreenCapturing.java index d855160..ce546dd 100644 --- a/src/main/java/javafxlibrary/keywords/Keywords/ScreenCapturing.java +++ b/src/main/java/javafxlibrary/keywords/Keywords/ScreenCapturing.java @@ -86,7 +86,7 @@ public Object captureImage(Object locator, boolean logImage){ try { image = robot.capture(targetBounds).getImage(); Path path = createNewImageFileNameWithPath(); - robotContext.getCaptureSupport().saveImage(image, path); + robotContext().getCaptureSupport().saveImage(image, path); if (logImage) { Double printSize = targetBounds.getWidth() > 800 ? 800 : targetBounds.getWidth(); @@ -94,7 +94,7 @@ public Object captureImage(Object locator, boolean logImage){ if(TestFxAdapter.logImages.toLowerCase().equals("embedded")) { Image resizedImage = resizeImage(image, path); Path tempPath = Paths.get(getCurrentSessionScreenshotDirectory(), "temp.png"); - robotContext.getCaptureSupport().saveImage(resizedImage, tempPath); + robotContext().getCaptureSupport().saveImage(resizedImage, tempPath); File imageFile = convertToJpeg(tempPath); byte[] imageBytes = IOUtils.toByteArray(new FileInputStream(imageFile)); @@ -157,7 +157,7 @@ public Object loadImageFromUrl(String url) { public void saveImageAs(Image image, String path) { try { RobotLog.info("Saving image \"" + image + "\" to path \"" + path + "\""); - robotContext.getCaptureSupport().saveImage(image, Paths.get(path)); + robotContext().getCaptureSupport().saveImage(image, Paths.get(path)); } catch (Exception e) { if(e instanceof JavaFXLibraryNonFatalException) throw e; diff --git a/src/main/java/javafxlibrary/utils/Session.java b/src/main/java/javafxlibrary/utils/Session.java index 45b78a5..5554031 100644 --- a/src/main/java/javafxlibrary/utils/Session.java +++ b/src/main/java/javafxlibrary/utils/Session.java @@ -24,14 +24,13 @@ import javafxlibrary.exceptions.JavaFXLibraryNonFatalException; import org.testfx.api.FxRobot; import org.testfx.api.FxToolkit; -import org.testfx.framework.junit.ApplicationTest; import javax.swing.*; import java.awt.*; import java.awt.event.WindowEvent; import java.util.concurrent.TimeoutException; -public class Session extends ApplicationTest { +public class Session { public Stage primaryStage; public FxRobot sessionRobot; @@ -40,7 +39,7 @@ public class Session extends ApplicationTest { public String screenshotDirectory = null; public Session(String appName, String... appArgs) { - try{ + try { // start the client this.primaryStage = FxToolkit.registerPrimaryStage(); this.sessionApplication = FxToolkit.setupApplication((Class)Class.forName(appName), appArgs); @@ -88,7 +87,7 @@ public void closeApplication() { sessionRobot.release(new KeyCode[] {}); sessionRobot.release(new MouseButton[] {}); FxToolkit.cleanupApplication(sessionApplication); - } catch (Exception e){ + } catch (Exception e) { throw new JavaFXLibraryNonFatalException("Problem shutting down the application: " + e.getMessage(), e); } } diff --git a/src/main/java/javafxlibrary/utils/TestFxAdapter.java b/src/main/java/javafxlibrary/utils/TestFxAdapter.java index 4ce01d9..9d79ce7 100644 --- a/src/main/java/javafxlibrary/utils/TestFxAdapter.java +++ b/src/main/java/javafxlibrary/utils/TestFxAdapter.java @@ -35,12 +35,6 @@ public static void setRobot(FxRobotInterface robot) { } public static FxRobotInterface getRobot() { return robot; } - // current robot context - protected static FxRobotContext robotContext; - public static void setRobotContext(FxRobotContext context) { - TestFxAdapter.robotContext = context; - } - // TODO: consider adding support for multiple sessions private static Session activeSession = null; @@ -62,14 +56,12 @@ in their start method for the controller class to load properly */ } setRobot(activeSession.sessionRobot); - setRobotContext(activeSession.robotContext()); } public void createNewSession(Application application) { activeSession = new Session(application); setRobot(activeSession.sessionRobot); - setRobotContext(activeSession.robotContext()); } public void deleteSession() { @@ -95,17 +87,17 @@ public String getCurrentSessionScreenshotDirectory() { public void setCurrentSessionScreenshotDirectory(String dir){ - if(activeSession != null) { + if (activeSession != null) { File errDir = new File(dir); - if(!errDir.exists()) + if (!errDir.exists()) errDir.mkdirs(); activeSession.screenshotDirectory = dir; - } - else + } else { throw new JavaFXLibraryNonFatalException("Unable to set screenshot directory, no application is currently open!"); + } } public static FxRobotContext robotContext() { - return robotContext; + return activeSession.sessionRobot.robotContext(); } } From dbb7cc92893bf95681d737b207242967c04b6e7a Mon Sep 17 00:00:00 2001 From: Juho Saarinen Date: Tue, 13 Nov 2018 09:51:54 +0200 Subject: [PATCH 42/95] Prevent conflicts with Commons by shading it --- pom.xml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pom.xml b/pom.xml index 72ac47c..88db914 100644 --- a/pom.xml +++ b/pom.xml @@ -272,6 +272,10 @@ com.google.common shaded.com.google.common + + org.apache.commons + shaded.org.apache.commons + From e81d02bbc60c4c70e69cf1c434ac0f5089bdc084 Mon Sep 17 00:00:00 2001 From: Pasi Saikkonen Date: Fri, 16 Nov 2018 14:18:42 +0200 Subject: [PATCH 43/95] Add keyword Launch Swing Application In Separate Thread --- .../ApplicationLauncher.java | 36 ++++++++++++++----- .../javafxlibrary/utils/HelperFunctions.java | 22 ++++++++++++ 2 files changed, 50 insertions(+), 8 deletions(-) diff --git a/src/main/java/javafxlibrary/keywords/AdditionalKeywords/ApplicationLauncher.java b/src/main/java/javafxlibrary/keywords/AdditionalKeywords/ApplicationLauncher.java index 5485539..1e8c896 100644 --- a/src/main/java/javafxlibrary/keywords/AdditionalKeywords/ApplicationLauncher.java +++ b/src/main/java/javafxlibrary/keywords/AdditionalKeywords/ApplicationLauncher.java @@ -31,6 +31,7 @@ import java.net.URLClassLoader; import java.util.*; +import static javafxlibrary.utils.HelperFunctions.createThreadedWrapperApplication; import static javafxlibrary.utils.HelperFunctions.createWrapperApplication; import static javafxlibrary.utils.HelperFunctions.getMainClassFromJarFile; @@ -66,21 +67,40 @@ public void launchJavafxApplication(String appName, String... appArgs) { @ArgumentNames({"appName", "*args"}) public void launchSwingApplication(String appName, String... appArgs) { RobotLog.info("Starting application:" + appName); - Class c; + Class c = getMainClass(appName); + Application app = createWrapperApplication(c, appArgs); + createNewSession(app); + RobotLog.info("Application: " + appName + " started."); + } + + @RobotKeyword("Creates a wrapper application the same way as in `Launch Swing Application`, but starts it in a new " + + "thread. This is required when main method of the test application is blocked and execution does not " + + "return after calling it until the application gets closed. Be sure to set the library timeout with " + + "`Set Timeout` so that the test application will have enough time to load, as the test execution will " + + "continue instantly after calling the main method.\n\n" + + "``appName`` is the name of the application to launch. \n\n" + + "``appArgs`` is a list of arguments to be passed for the application. \n\n" + + "Example:\n" + + "| Launch Swing Application In Separate Thread | _javafxlibrary.testapps.SwingApplication |\n" + + "| Launch Swing Application In Separate Thread | _TestApplication.jar_ |\n") + @ArgumentNames({"appName", "*args"}) + public void launchSwingApplicationInSeparateThread(String appName, String... appArgs) { + RobotLog.info("Starting application:" + appName); + Class c = getMainClass(appName); + Application app = createThreadedWrapperApplication(c, appArgs); + createNewSession(app); + RobotLog.info("Application: " + appName + " started."); + } + private Class getMainClass(String appName) { try { if (appName.endsWith(".jar")) - c = getMainClassFromJarFile(appName); + return getMainClassFromJarFile(appName); else - c = Class.forName(appName); - + return Class.forName(appName); } catch (ClassNotFoundException e) { throw new JavaFXLibraryNonFatalException("Unable to launch application: " + appName, e); } - - Application app = createWrapperApplication(c, appArgs); - createNewSession(app); - RobotLog.info("Application: " + appName + " started."); } private void _addPathToClassPath(String path) { diff --git a/src/main/java/javafxlibrary/utils/HelperFunctions.java b/src/main/java/javafxlibrary/utils/HelperFunctions.java index d14142d..509be25 100644 --- a/src/main/java/javafxlibrary/utils/HelperFunctions.java +++ b/src/main/java/javafxlibrary/utils/HelperFunctions.java @@ -842,6 +842,28 @@ public void start(Stage primaryStage) { } } + public static Application createThreadedWrapperApplication(Class c, String... appArgs) { + try { + Method main = c.getMethod("main", String[].class); + return new Application() { + @Override + public void start(Stage primaryStage) { + Thread t = new Thread (() -> { + try { + main.invoke(null, (Object) appArgs); + + } catch (IllegalAccessException | InvocationTargetException e) { + throw new JavaFXLibraryNonFatalException("Unable to launch application: " + c.getName(), e); + } + }); + t.start(); + } + }; + } catch (NoSuchMethodException e) { + throw new JavaFXLibraryNonFatalException("Couldn't create wrapper application for " + c.getName(), e); + } + } + public static Finder createFinder() { return new Finder(); } From ffa9303ea5313b34ffd2d86b15e6ce183a9a3d99 Mon Sep 17 00:00:00 2001 From: Juho Saarinen Date: Tue, 27 Nov 2018 09:18:28 +0200 Subject: [PATCH 44/95] Moved test app to test code Updated some dependencies Testing what's delivered in containers Surefire update because of https://issues.apache.org/jira/browse/SUREFIRE-1588 / https://stackoverflow.com/questions/53010200/maven-surefire-could-not-find-forkedbooter-class --- Dockerfile_build | 1 + docker/robot-javafx-demo/test.sh | 6 ++- entrypoint_build.sh | 3 +- pom.xml | 45 +++++++++++++++++-- .../javafxlibrary/testapps/DatePickerApp.java | 0 .../java/javafxlibrary/testapps/DemoApp.java | 0 .../javafxlibrary/testapps/FinderApp.java | 0 .../java/javafxlibrary/testapps/MenuApp.java | 0 .../testapps/SwingApplication.java | 0 .../testapps/SwingApplicationWrapper.java | 0 .../testapps/TestBoundsLocation.java | 0 .../testapps/TestClickRobot.java | 0 .../javafxlibrary/testapps/TestDragRobot.java | 0 .../testapps/TestKeyboardRobot.java | 0 .../testapps/TestMultipleWindows.java | 0 .../testapps/TestPointLocation.java | 0 .../testapps/TestScreenCapturing.java | 0 .../testapps/TestScrollRobot.java | 0 .../testapps/TestScrollRobot2.java | 0 .../testapps/TestSleepRobot.java | 0 .../testapps/TestTableManagement.java | 0 .../testapps/TestWindowManagement.java | 0 .../controllers/DemoAppController.java | 0 .../controllers/ImageDemoController.java | 0 .../controllers/MenuAppController.java | 0 .../TestBoundsLocationController.java | 0 .../controllers/TestClickRobotController.java | 0 .../controllers/TestDragRobotController.java | 0 .../TestKeyboardRobotController.java | 0 .../TestMultipleWindowsController.java | 0 .../TestPointLocationController.java | 0 .../TestScreenCapturingController.java | 0 .../TestScrollRobot2Controller.java | 0 .../TestScrollRobotController.java | 0 .../controllers/TestSleepRobotController.java | 0 .../TestWindowManagementController.java | 0 .../controllers/TextListController.java | 0 .../ColorChangingRectangle.java | 0 .../testapps/customcomponents/ImageDemo.java | 0 .../testapps/customcomponents/Statistic.java | 0 .../testapps/customcomponents/TextList.java | 0 .../testapps/customcomponents/TextRow.java | 0 src/test/robotframework/resource.robot | 4 ++ 43 files changed, 52 insertions(+), 7 deletions(-) rename src/{main => test}/java/javafxlibrary/testapps/DatePickerApp.java (100%) rename src/{main => test}/java/javafxlibrary/testapps/DemoApp.java (100%) rename src/{main => test}/java/javafxlibrary/testapps/FinderApp.java (100%) rename src/{main => test}/java/javafxlibrary/testapps/MenuApp.java (100%) rename src/{main => test}/java/javafxlibrary/testapps/SwingApplication.java (100%) rename src/{main => test}/java/javafxlibrary/testapps/SwingApplicationWrapper.java (100%) rename src/{main => test}/java/javafxlibrary/testapps/TestBoundsLocation.java (100%) rename src/{main => test}/java/javafxlibrary/testapps/TestClickRobot.java (100%) rename src/{main => test}/java/javafxlibrary/testapps/TestDragRobot.java (100%) rename src/{main => test}/java/javafxlibrary/testapps/TestKeyboardRobot.java (100%) rename src/{main => test}/java/javafxlibrary/testapps/TestMultipleWindows.java (100%) rename src/{main => test}/java/javafxlibrary/testapps/TestPointLocation.java (100%) rename src/{main => test}/java/javafxlibrary/testapps/TestScreenCapturing.java (100%) rename src/{main => test}/java/javafxlibrary/testapps/TestScrollRobot.java (100%) rename src/{main => test}/java/javafxlibrary/testapps/TestScrollRobot2.java (100%) rename src/{main => test}/java/javafxlibrary/testapps/TestSleepRobot.java (100%) rename src/{main => test}/java/javafxlibrary/testapps/TestTableManagement.java (100%) rename src/{main => test}/java/javafxlibrary/testapps/TestWindowManagement.java (100%) rename src/{main => test}/java/javafxlibrary/testapps/controllers/DemoAppController.java (100%) rename src/{main => test}/java/javafxlibrary/testapps/controllers/ImageDemoController.java (100%) rename src/{main => test}/java/javafxlibrary/testapps/controllers/MenuAppController.java (100%) rename src/{main => test}/java/javafxlibrary/testapps/controllers/TestBoundsLocationController.java (100%) rename src/{main => test}/java/javafxlibrary/testapps/controllers/TestClickRobotController.java (100%) rename src/{main => test}/java/javafxlibrary/testapps/controllers/TestDragRobotController.java (100%) rename src/{main => test}/java/javafxlibrary/testapps/controllers/TestKeyboardRobotController.java (100%) rename src/{main => test}/java/javafxlibrary/testapps/controllers/TestMultipleWindowsController.java (100%) rename src/{main => test}/java/javafxlibrary/testapps/controllers/TestPointLocationController.java (100%) rename src/{main => test}/java/javafxlibrary/testapps/controllers/TestScreenCapturingController.java (100%) rename src/{main => test}/java/javafxlibrary/testapps/controllers/TestScrollRobot2Controller.java (100%) rename src/{main => test}/java/javafxlibrary/testapps/controllers/TestScrollRobotController.java (100%) rename src/{main => test}/java/javafxlibrary/testapps/controllers/TestSleepRobotController.java (100%) rename src/{main => test}/java/javafxlibrary/testapps/controllers/TestWindowManagementController.java (100%) rename src/{main => test}/java/javafxlibrary/testapps/controllers/TextListController.java (100%) rename src/{main => test}/java/javafxlibrary/testapps/customcomponents/ColorChangingRectangle.java (100%) rename src/{main => test}/java/javafxlibrary/testapps/customcomponents/ImageDemo.java (100%) rename src/{main => test}/java/javafxlibrary/testapps/customcomponents/Statistic.java (100%) rename src/{main => test}/java/javafxlibrary/testapps/customcomponents/TextList.java (100%) rename src/{main => test}/java/javafxlibrary/testapps/customcomponents/TextRow.java (100%) diff --git a/Dockerfile_build b/Dockerfile_build index c472fa7..d34c660 100644 --- a/Dockerfile_build +++ b/Dockerfile_build @@ -15,6 +15,7 @@ RUN mvn package FROM ubuntu:16.04 COPY --from=builder /code/target/javafxlibrary-*-SNAPSHOT-jar-with-dependencies.jar /. +COPY --from=builder /code/target/javafxlibrary-*-SNAPSHOT-tests.jar /. COPY entrypoint_build.sh /. RUN apt-get -qq update && apt-get dist-upgrade -y && apt-get install -qq --no-install-recommends --allow-unauthenticated -y \ openjdk-8-jre \ diff --git a/docker/robot-javafx-demo/test.sh b/docker/robot-javafx-demo/test.sh index b7572bc..59d1baf 100644 --- a/docker/robot-javafx-demo/test.sh +++ b/docker/robot-javafx-demo/test.sh @@ -5,7 +5,8 @@ function local() { echo "**********************" echo "INFO: Local execution:" file=$(ls -1 /javafxbinary/javafxlibrary-*-jar-with-dependencies.jar) - java -cp ${file} org.robotframework.RobotFramework -d /robot/results/local --include smoke $@ /robot/acceptance + testJar=$(ls -1 /javafxbinary/javafxlibrary-*-tests.jar) + java -cp ${file} org.robotframework.RobotFramework -d /robot/results/local --include smoke --variable appJar:${testJar} $@ /robot/acceptance # $@ #just to testing script if [[ "$?" != "0" ]]; then EXIT_VALUE=$((EXIT_VALUE+1)) @@ -15,7 +16,8 @@ function local() { function remote() { echo "***********************" echo "INFO: Remote execution:" - robot -d /robot/results/remote --include smoke $@ /robot/acceptance + testJar=$(ls -1 /javafxbinary/javafxlibrary-*-tests.jar) + robot -d /robot/results/remote --include smoke --variable appJar:${testJar} $@ /robot/acceptance # $@ #just to testing script if [[ "$?" != "0" ]]; then EXIT_VALUE=$((EXIT_VALUE+2)) diff --git a/entrypoint_build.sh b/entrypoint_build.sh index 1c61959..a4ba273 100644 --- a/entrypoint_build.sh +++ b/entrypoint_build.sh @@ -1,5 +1,6 @@ #!/usr/bin/env bash rm -rvf /javafxbinary/* cp -vf /javafxlibrary-*-jar-with-dependencies.jar /javafxbinary/. -chmod 555 /javafxbinary/javafxlibrary-*-jar-with-dependencies.jar +cp -vf /javafxlibrary-*-tests.jar /javafxbinary/. +chmod 555 /javafxbinary/* java -jar /javafxlibrary-*-jar-with-dependencies.jar diff --git a/pom.xml b/pom.xml index 72ac47c..5566f19 100644 --- a/pom.xml +++ b/pom.xml @@ -102,6 +102,33 @@ + + + org.codehaus.mojo + build-helper-maven-plugin + 1.10 + + + attach-artifacts + package + + attach-artifact + + + + + ${project.build.directory}/${project.artifactId}.html + html + + + ${project.build.directory}/${project.artifactId}.xml + xml + + + + + + org.apache.maven.plugins maven-gpg-plugin @@ -138,6 +165,11 @@ + + org.apache.maven.plugins + maven-surefire-plugin + 3.0.0-M1 + org.sonatype.plugins nexus-staging-maven-plugin @@ -219,6 +251,9 @@ TRACE:INFO false + + appJar:${project.build.directory}/${project.artifactId}*tests.jar + @@ -229,6 +264,7 @@ + ${project.build.directory} ${project.artifactId}.html JavaFXLibrary ${project.version} @@ -243,6 +279,7 @@ + ${project.build.directory} ${project.artifactId}.xml JavaFXLibrary ${project.version} @@ -299,7 +336,7 @@ org.apache.maven maven-model - 3.3.9 + 3.6.0 org.jmockit @@ -315,7 +352,7 @@ org.testfx testfx-core - 4.0.14-alpha + 4.0.15-alpha org.testfx @@ -331,7 +368,7 @@ org.robotframework robotframework - 3.0.2 + 3.0.4 org.hamcrest @@ -341,7 +378,7 @@ com.google.guava guava - 23.0 + 27.0.1-jre com.github.ombre42 diff --git a/src/main/java/javafxlibrary/testapps/DatePickerApp.java b/src/test/java/javafxlibrary/testapps/DatePickerApp.java similarity index 100% rename from src/main/java/javafxlibrary/testapps/DatePickerApp.java rename to src/test/java/javafxlibrary/testapps/DatePickerApp.java diff --git a/src/main/java/javafxlibrary/testapps/DemoApp.java b/src/test/java/javafxlibrary/testapps/DemoApp.java similarity index 100% rename from src/main/java/javafxlibrary/testapps/DemoApp.java rename to src/test/java/javafxlibrary/testapps/DemoApp.java diff --git a/src/main/java/javafxlibrary/testapps/FinderApp.java b/src/test/java/javafxlibrary/testapps/FinderApp.java similarity index 100% rename from src/main/java/javafxlibrary/testapps/FinderApp.java rename to src/test/java/javafxlibrary/testapps/FinderApp.java diff --git a/src/main/java/javafxlibrary/testapps/MenuApp.java b/src/test/java/javafxlibrary/testapps/MenuApp.java similarity index 100% rename from src/main/java/javafxlibrary/testapps/MenuApp.java rename to src/test/java/javafxlibrary/testapps/MenuApp.java diff --git a/src/main/java/javafxlibrary/testapps/SwingApplication.java b/src/test/java/javafxlibrary/testapps/SwingApplication.java similarity index 100% rename from src/main/java/javafxlibrary/testapps/SwingApplication.java rename to src/test/java/javafxlibrary/testapps/SwingApplication.java diff --git a/src/main/java/javafxlibrary/testapps/SwingApplicationWrapper.java b/src/test/java/javafxlibrary/testapps/SwingApplicationWrapper.java similarity index 100% rename from src/main/java/javafxlibrary/testapps/SwingApplicationWrapper.java rename to src/test/java/javafxlibrary/testapps/SwingApplicationWrapper.java diff --git a/src/main/java/javafxlibrary/testapps/TestBoundsLocation.java b/src/test/java/javafxlibrary/testapps/TestBoundsLocation.java similarity index 100% rename from src/main/java/javafxlibrary/testapps/TestBoundsLocation.java rename to src/test/java/javafxlibrary/testapps/TestBoundsLocation.java diff --git a/src/main/java/javafxlibrary/testapps/TestClickRobot.java b/src/test/java/javafxlibrary/testapps/TestClickRobot.java similarity index 100% rename from src/main/java/javafxlibrary/testapps/TestClickRobot.java rename to src/test/java/javafxlibrary/testapps/TestClickRobot.java diff --git a/src/main/java/javafxlibrary/testapps/TestDragRobot.java b/src/test/java/javafxlibrary/testapps/TestDragRobot.java similarity index 100% rename from src/main/java/javafxlibrary/testapps/TestDragRobot.java rename to src/test/java/javafxlibrary/testapps/TestDragRobot.java diff --git a/src/main/java/javafxlibrary/testapps/TestKeyboardRobot.java b/src/test/java/javafxlibrary/testapps/TestKeyboardRobot.java similarity index 100% rename from src/main/java/javafxlibrary/testapps/TestKeyboardRobot.java rename to src/test/java/javafxlibrary/testapps/TestKeyboardRobot.java diff --git a/src/main/java/javafxlibrary/testapps/TestMultipleWindows.java b/src/test/java/javafxlibrary/testapps/TestMultipleWindows.java similarity index 100% rename from src/main/java/javafxlibrary/testapps/TestMultipleWindows.java rename to src/test/java/javafxlibrary/testapps/TestMultipleWindows.java diff --git a/src/main/java/javafxlibrary/testapps/TestPointLocation.java b/src/test/java/javafxlibrary/testapps/TestPointLocation.java similarity index 100% rename from src/main/java/javafxlibrary/testapps/TestPointLocation.java rename to src/test/java/javafxlibrary/testapps/TestPointLocation.java diff --git a/src/main/java/javafxlibrary/testapps/TestScreenCapturing.java b/src/test/java/javafxlibrary/testapps/TestScreenCapturing.java similarity index 100% rename from src/main/java/javafxlibrary/testapps/TestScreenCapturing.java rename to src/test/java/javafxlibrary/testapps/TestScreenCapturing.java diff --git a/src/main/java/javafxlibrary/testapps/TestScrollRobot.java b/src/test/java/javafxlibrary/testapps/TestScrollRobot.java similarity index 100% rename from src/main/java/javafxlibrary/testapps/TestScrollRobot.java rename to src/test/java/javafxlibrary/testapps/TestScrollRobot.java diff --git a/src/main/java/javafxlibrary/testapps/TestScrollRobot2.java b/src/test/java/javafxlibrary/testapps/TestScrollRobot2.java similarity index 100% rename from src/main/java/javafxlibrary/testapps/TestScrollRobot2.java rename to src/test/java/javafxlibrary/testapps/TestScrollRobot2.java diff --git a/src/main/java/javafxlibrary/testapps/TestSleepRobot.java b/src/test/java/javafxlibrary/testapps/TestSleepRobot.java similarity index 100% rename from src/main/java/javafxlibrary/testapps/TestSleepRobot.java rename to src/test/java/javafxlibrary/testapps/TestSleepRobot.java diff --git a/src/main/java/javafxlibrary/testapps/TestTableManagement.java b/src/test/java/javafxlibrary/testapps/TestTableManagement.java similarity index 100% rename from src/main/java/javafxlibrary/testapps/TestTableManagement.java rename to src/test/java/javafxlibrary/testapps/TestTableManagement.java diff --git a/src/main/java/javafxlibrary/testapps/TestWindowManagement.java b/src/test/java/javafxlibrary/testapps/TestWindowManagement.java similarity index 100% rename from src/main/java/javafxlibrary/testapps/TestWindowManagement.java rename to src/test/java/javafxlibrary/testapps/TestWindowManagement.java diff --git a/src/main/java/javafxlibrary/testapps/controllers/DemoAppController.java b/src/test/java/javafxlibrary/testapps/controllers/DemoAppController.java similarity index 100% rename from src/main/java/javafxlibrary/testapps/controllers/DemoAppController.java rename to src/test/java/javafxlibrary/testapps/controllers/DemoAppController.java diff --git a/src/main/java/javafxlibrary/testapps/controllers/ImageDemoController.java b/src/test/java/javafxlibrary/testapps/controllers/ImageDemoController.java similarity index 100% rename from src/main/java/javafxlibrary/testapps/controllers/ImageDemoController.java rename to src/test/java/javafxlibrary/testapps/controllers/ImageDemoController.java diff --git a/src/main/java/javafxlibrary/testapps/controllers/MenuAppController.java b/src/test/java/javafxlibrary/testapps/controllers/MenuAppController.java similarity index 100% rename from src/main/java/javafxlibrary/testapps/controllers/MenuAppController.java rename to src/test/java/javafxlibrary/testapps/controllers/MenuAppController.java diff --git a/src/main/java/javafxlibrary/testapps/controllers/TestBoundsLocationController.java b/src/test/java/javafxlibrary/testapps/controllers/TestBoundsLocationController.java similarity index 100% rename from src/main/java/javafxlibrary/testapps/controllers/TestBoundsLocationController.java rename to src/test/java/javafxlibrary/testapps/controllers/TestBoundsLocationController.java diff --git a/src/main/java/javafxlibrary/testapps/controllers/TestClickRobotController.java b/src/test/java/javafxlibrary/testapps/controllers/TestClickRobotController.java similarity index 100% rename from src/main/java/javafxlibrary/testapps/controllers/TestClickRobotController.java rename to src/test/java/javafxlibrary/testapps/controllers/TestClickRobotController.java diff --git a/src/main/java/javafxlibrary/testapps/controllers/TestDragRobotController.java b/src/test/java/javafxlibrary/testapps/controllers/TestDragRobotController.java similarity index 100% rename from src/main/java/javafxlibrary/testapps/controllers/TestDragRobotController.java rename to src/test/java/javafxlibrary/testapps/controllers/TestDragRobotController.java diff --git a/src/main/java/javafxlibrary/testapps/controllers/TestKeyboardRobotController.java b/src/test/java/javafxlibrary/testapps/controllers/TestKeyboardRobotController.java similarity index 100% rename from src/main/java/javafxlibrary/testapps/controllers/TestKeyboardRobotController.java rename to src/test/java/javafxlibrary/testapps/controllers/TestKeyboardRobotController.java diff --git a/src/main/java/javafxlibrary/testapps/controllers/TestMultipleWindowsController.java b/src/test/java/javafxlibrary/testapps/controllers/TestMultipleWindowsController.java similarity index 100% rename from src/main/java/javafxlibrary/testapps/controllers/TestMultipleWindowsController.java rename to src/test/java/javafxlibrary/testapps/controllers/TestMultipleWindowsController.java diff --git a/src/main/java/javafxlibrary/testapps/controllers/TestPointLocationController.java b/src/test/java/javafxlibrary/testapps/controllers/TestPointLocationController.java similarity index 100% rename from src/main/java/javafxlibrary/testapps/controllers/TestPointLocationController.java rename to src/test/java/javafxlibrary/testapps/controllers/TestPointLocationController.java diff --git a/src/main/java/javafxlibrary/testapps/controllers/TestScreenCapturingController.java b/src/test/java/javafxlibrary/testapps/controllers/TestScreenCapturingController.java similarity index 100% rename from src/main/java/javafxlibrary/testapps/controllers/TestScreenCapturingController.java rename to src/test/java/javafxlibrary/testapps/controllers/TestScreenCapturingController.java diff --git a/src/main/java/javafxlibrary/testapps/controllers/TestScrollRobot2Controller.java b/src/test/java/javafxlibrary/testapps/controllers/TestScrollRobot2Controller.java similarity index 100% rename from src/main/java/javafxlibrary/testapps/controllers/TestScrollRobot2Controller.java rename to src/test/java/javafxlibrary/testapps/controllers/TestScrollRobot2Controller.java diff --git a/src/main/java/javafxlibrary/testapps/controllers/TestScrollRobotController.java b/src/test/java/javafxlibrary/testapps/controllers/TestScrollRobotController.java similarity index 100% rename from src/main/java/javafxlibrary/testapps/controllers/TestScrollRobotController.java rename to src/test/java/javafxlibrary/testapps/controllers/TestScrollRobotController.java diff --git a/src/main/java/javafxlibrary/testapps/controllers/TestSleepRobotController.java b/src/test/java/javafxlibrary/testapps/controllers/TestSleepRobotController.java similarity index 100% rename from src/main/java/javafxlibrary/testapps/controllers/TestSleepRobotController.java rename to src/test/java/javafxlibrary/testapps/controllers/TestSleepRobotController.java diff --git a/src/main/java/javafxlibrary/testapps/controllers/TestWindowManagementController.java b/src/test/java/javafxlibrary/testapps/controllers/TestWindowManagementController.java similarity index 100% rename from src/main/java/javafxlibrary/testapps/controllers/TestWindowManagementController.java rename to src/test/java/javafxlibrary/testapps/controllers/TestWindowManagementController.java diff --git a/src/main/java/javafxlibrary/testapps/controllers/TextListController.java b/src/test/java/javafxlibrary/testapps/controllers/TextListController.java similarity index 100% rename from src/main/java/javafxlibrary/testapps/controllers/TextListController.java rename to src/test/java/javafxlibrary/testapps/controllers/TextListController.java diff --git a/src/main/java/javafxlibrary/testapps/customcomponents/ColorChangingRectangle.java b/src/test/java/javafxlibrary/testapps/customcomponents/ColorChangingRectangle.java similarity index 100% rename from src/main/java/javafxlibrary/testapps/customcomponents/ColorChangingRectangle.java rename to src/test/java/javafxlibrary/testapps/customcomponents/ColorChangingRectangle.java diff --git a/src/main/java/javafxlibrary/testapps/customcomponents/ImageDemo.java b/src/test/java/javafxlibrary/testapps/customcomponents/ImageDemo.java similarity index 100% rename from src/main/java/javafxlibrary/testapps/customcomponents/ImageDemo.java rename to src/test/java/javafxlibrary/testapps/customcomponents/ImageDemo.java diff --git a/src/main/java/javafxlibrary/testapps/customcomponents/Statistic.java b/src/test/java/javafxlibrary/testapps/customcomponents/Statistic.java similarity index 100% rename from src/main/java/javafxlibrary/testapps/customcomponents/Statistic.java rename to src/test/java/javafxlibrary/testapps/customcomponents/Statistic.java diff --git a/src/main/java/javafxlibrary/testapps/customcomponents/TextList.java b/src/test/java/javafxlibrary/testapps/customcomponents/TextList.java similarity index 100% rename from src/main/java/javafxlibrary/testapps/customcomponents/TextList.java rename to src/test/java/javafxlibrary/testapps/customcomponents/TextList.java diff --git a/src/main/java/javafxlibrary/testapps/customcomponents/TextRow.java b/src/test/java/javafxlibrary/testapps/customcomponents/TextRow.java similarity index 100% rename from src/main/java/javafxlibrary/testapps/customcomponents/TextRow.java rename to src/test/java/javafxlibrary/testapps/customcomponents/TextRow.java diff --git a/src/test/robotframework/resource.robot b/src/test/robotframework/resource.robot index 2802640..bff1e77 100644 --- a/src/test/robotframework/resource.robot +++ b/src/test/robotframework/resource.robot @@ -1,7 +1,11 @@ +*** Variables *** +${appJar} javafxlibrary-*-tests.jar + *** Keywords *** Import JavaFXLibrary Run Keyword If sys.platform.startswith('java') Import Library JavaFXLibrary ... ELSE Import Library Remote http://javafxcompile:8270 WITH NAME RemoteJavaFXLibrary + Set To Classpath ${appJar} Disable Embedded Image Logging For Negative Tests :FOR ${tag} IN @{TEST TAGS} From f86b9bbc73eeeb6ea3e819765d5d19156b677970 Mon Sep 17 00:00:00 2001 From: Juho Saarinen Date: Tue, 27 Nov 2018 09:50:28 +0200 Subject: [PATCH 45/95] Continuing to use awt robot with library --- src/main/java/JavaFXLibrary.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/JavaFXLibrary.java b/src/main/java/JavaFXLibrary.java index da646a5..c80b415 100644 --- a/src/main/java/JavaFXLibrary.java +++ b/src/main/java/JavaFXLibrary.java @@ -60,6 +60,9 @@ public class JavaFXLibrary extends AnnotationLibrary { public JavaFXLibrary() { super(includePatterns); deleteScreenshotsFrom("report-images/imagecomparison"); + //v4.0.15-alpha sets default robot as glass, which breaks rolling + //Forcing usage of awt robot as previous versions + System.setProperty("testfx.robot", "awt"); } @Autowired From 9052b63131898b13a752f03c3eec96884864e2f0 Mon Sep 17 00:00:00 2001 From: Juho Saarinen Date: Wed, 28 Nov 2018 09:00:13 +0200 Subject: [PATCH 46/95] Added init argument to determine if tests are run headless Documentation for the headless mode activation --- src/main/java/JavaFXLibrary.java | 34 ++++++++++++++++++--- src/main/java/libdoc-documentation.txt | 7 ++++- src/main/java/libdoc-init-documentation.txt | 3 ++ 3 files changed, 38 insertions(+), 6 deletions(-) create mode 100644 src/main/java/libdoc-init-documentation.txt diff --git a/src/main/java/JavaFXLibrary.java b/src/main/java/JavaFXLibrary.java index c80b415..54d65a3 100644 --- a/src/main/java/JavaFXLibrary.java +++ b/src/main/java/JavaFXLibrary.java @@ -58,12 +58,23 @@ public class JavaFXLibrary extends AnnotationLibrary { }}; public JavaFXLibrary() { + this(false); + } + + public JavaFXLibrary(boolean headless) { super(includePatterns); deleteScreenshotsFrom("report-images/imagecomparison"); - //v4.0.15-alpha sets default robot as glass, which breaks rolling - //Forcing usage of awt robot as previous versions - System.setProperty("testfx.robot", "awt"); - } + if (headless) { + System.setProperty("testfx.robot", "glass"); + System.setProperty("testfx.headless", "true"); + System.setProperty("prism.order", "sw"); + System.setProperty("prism.text", "t2k"); + } else { + //v4.0.15-alpha sets default robot as glass, which breaks rolling + //Forcing usage of awt robot as previous versions + System.setProperty("testfx.robot", "awt"); + } + } @Autowired protected RunOnFailure runOnFailure; @@ -136,8 +147,21 @@ public String getKeywordDocumentation(String keywordName) { e.printStackTrace(); return "IOException occured while reading the documentation file!"; } + } else if (keywordName.equals("__init__")) { + try { + return FileUtils.readFileToString(new File("./src/main/java/libdoc-init-documentation.txt"), "utf-8"); + } catch (IOException e) { + e.printStackTrace(); + return "IOException occured while reading the init documentation file!"; + } + } else { + try { + return super.getKeywordDocumentation(keywordName); + } + catch (Exception e) { + return keywordName; + } } - return super.getKeywordDocumentation(keywordName); } /** diff --git a/src/main/java/libdoc-documentation.txt b/src/main/java/libdoc-documentation.txt index 20d20f0..d46f063 100644 --- a/src/main/java/libdoc-documentation.txt +++ b/src/main/java/libdoc-documentation.txt @@ -21,6 +21,9 @@ First, the JavaFXLibrary needs to be taken into use in the settings table. | *Settings* | *Value* | | Library | JavaFXLibrary | +Experimental headless mode can be activated at the import time by setting first argument to ${True} +| *Settings* | *Value* | +| Library | JavaFXLibrary | ${True} | === 2.2 Usage in remote mode(Jython & Python) === When using the test library in remote mode, the library needs to be started at the remote end first. This can be done as follows: @@ -40,7 +43,9 @@ Multiple JavaFXLibraries in remote mode: | Library | Remote | ip_address:8270 | WITH NAME | my_application | | Library | Remote | ip_address:8271 | WITH NAME | my_other_application | - +Experimental headless mode can be activated in remote mode at the import time by setting first argument to ${True} +| *Settings* | *Value* | +| Library | Remote | http://localhost:8270 | ${True} | WITH NAME | JavaFXLibrary | == 3. Locating JavaFX Nodes == === 3.1 Locator syntax === diff --git a/src/main/java/libdoc-init-documentation.txt b/src/main/java/libdoc-init-documentation.txt new file mode 100644 index 0000000..9c67516 --- /dev/null +++ b/src/main/java/libdoc-init-documentation.txt @@ -0,0 +1,3 @@ +JavaFXLibrary can be imported with one optional arguments. + +- ``headless``: Determines if tests will be run in headless mode using [https://wiki.openjdk.java.net/display/OpenJFX/Monocle|Monocle]. Default value is ``false``. From 642701f7e2c8f86089abac2361c595e0523baf37 Mon Sep 17 00:00:00 2001 From: Juho Saarinen Date: Wed, 28 Nov 2018 10:17:39 +0200 Subject: [PATCH 47/95] Added javaagent explicitly (windows build failed without it) --- pom.xml | 345 +++++++++++++++++++++++++++++--------------------------- 1 file changed, 176 insertions(+), 169 deletions(-) diff --git a/pom.xml b/pom.xml index a98e2a3..a586d1c 100644 --- a/pom.xml +++ b/pom.xml @@ -24,6 +24,7 @@ 0.5.2-SNAPSHOT UTF-8 + 1.44 ${project.groupId}:${project.artifactId} @@ -163,178 +164,184 @@ - - - + + + org.apache.maven.plugins maven-surefire-plugin 3.0.0-M1 + + + -javaagent:${settings.localRepository}/org/jmockit/jmockit/${jmockit.version}/jmockit-${jmockit.version}.jar + + - - org.sonatype.plugins - nexus-staging-maven-plugin - 1.6.7 - true - - ossrh - https://oss.sonatype.org/ - false - - - - maven-compiler-plugin - 3.6.1 - - 1.8 - 1.8 - - - - org.apache.maven.plugins - maven-jar-plugin - 3.0.2 - - - - true - JavaFXLibrary - - - - - - - test-jar - - - - - - maven-assembly-plugin - 3.0.0 - - - package - - single - - - - - - - JavaFXLibrary - - - - jar-with-dependencies - - - - - org.robotframework - robotframework-maven-plugin - 1.4.7 - - - acceptance tests - integration-test - - run - - - - smoke - - - not-ready - - TRACE:INFO - false - - appJar:${project.build.directory}/${project.artifactId}*tests.jar - - - - - documentation - package - - libdoc - - - - ${project.build.directory} - ${project.artifactId}.html - JavaFXLibrary - ${project.version} - - - - - xml - package - - libdoc - - - - ${project.build.directory} - ${project.artifactId}.xml - JavaFXLibrary - ${project.version} - - - - - - - org.apache.maven.plugins - maven-shade-plugin - 3.1.0 - - - package - - shade - - - - - JavaFXLibrary - - - - - com.google.common - shaded.com.google.common - - - org.apache.commons - shaded.org.apache.commons - - - - - *:* - - - - - *:* - - META-INF/*.SF - META-INF/*.DSA - META-INF/*.RSA - - - - - - - - - + + org.sonatype.plugins + nexus-staging-maven-plugin + 1.6.7 + true + + ossrh + https://oss.sonatype.org/ + false + + + + maven-compiler-plugin + 3.6.1 + + 1.8 + 1.8 + + + + org.apache.maven.plugins + maven-jar-plugin + 3.0.2 + + + + true + JavaFXLibrary + + + + + + + test-jar + + + + + + maven-assembly-plugin + 3.0.0 + + + package + + single + + + + + + + JavaFXLibrary + + + + jar-with-dependencies + + + + + org.robotframework + robotframework-maven-plugin + 1.4.7 + + + acceptance tests + integration-test + + run + + + + smoke + + + not-ready + + TRACE:INFO + false + + appJar:${project.build.directory}/${project.artifactId}*tests.jar + + + + + documentation + package + + libdoc + + + + ${project.build.directory} + ${project.artifactId}.html + JavaFXLibrary + ${project.version} + + + + + xml + package + + libdoc + + + + ${project.build.directory} + ${project.artifactId}.xml + JavaFXLibrary + ${project.version} + + + + + + + org.apache.maven.plugins + maven-shade-plugin + 3.1.0 + + + package + + shade + + + + + JavaFXLibrary + + + + + com.google.common + shaded.com.google.common + + + org.apache.commons + shaded.org.apache.commons + + + + + *:* + + + + + *:* + + META-INF/*.SF + META-INF/*.DSA + META-INF/*.RSA + + + + + + + + + @@ -346,7 +353,7 @@ org.jmockit jmockit test - 1.38 + ${jmockit.version} junit From 72754fba9cffdbe87ad25d5be919710a1ef9a99f Mon Sep 17 00:00:00 2001 From: Juho Saarinen Date: Wed, 28 Nov 2018 10:36:15 +0200 Subject: [PATCH 48/95] Including monocle also in actual package --- pom.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/pom.xml b/pom.xml index a98e2a3..e71343e 100644 --- a/pom.xml +++ b/pom.xml @@ -362,7 +362,6 @@ org.testfx openjfx-monocle 8u76-b04 - test org.robotframework From 3e3e1abb277d10c8a47c6c586e2aad2d1233ebec Mon Sep 17 00:00:00 2001 From: Sami Pesonen Date: Wed, 28 Nov 2018 22:38:41 +0200 Subject: [PATCH 49/95] merge 0.5.2-development branch => release 0.5.2 - Merge pull request #9 from Hi-Fi/packageImprovements - Package improvements - Merge pull request #8 from Hi-Fi/shadeCommons - Prevent conflicts with Commons by shading it - Continuing to use awt robot with library - Moved test app to test code - Updated some dependencies - Testing what's delivered in containers - Surefire update because of https://issues.apache.org/jira/browse/SUREFIRE-1588 / https://stackoverflow.com/questions/53010200/maven-surefire-could-not-find-forkedbooter-class - Add keyword Launch Swing Application In Separate Thread - Prevent conflicts with Commons by shading it - Get FxRobotContext from the active sessionRobot in TestFxAdapter - Adjust readme - Add instructions for enabling accessibility features on MacOS Mojave --- AUTHORS.txt | 1 + Dockerfile_build | 1 + README.md | 9 +++ docker/robot-javafx-demo/test.sh | 6 +- entrypoint_build.sh | 3 +- pom.xml | 56 +++++++++++++++---- src/main/java/JavaFXLibrary.java | 3 + .../ApplicationLauncher.java | 36 +++++++++--- .../AdditionalKeywords/Verifiers.java | 4 +- .../keywords/Keywords/KeyboardRobot.java | 2 +- .../keywords/Keywords/ScreenCapturing.java | 6 +- .../javafxlibrary/utils/HelperFunctions.java | 22 ++++++++ .../java/javafxlibrary/utils/Session.java | 7 +-- .../javafxlibrary/utils/TestFxAdapter.java | 18 ++---- .../javafxlibrary/testapps/DatePickerApp.java | 0 .../java/javafxlibrary/testapps/DemoApp.java | 0 .../javafxlibrary/testapps/FinderApp.java | 0 .../java/javafxlibrary/testapps/MenuApp.java | 0 .../testapps/SwingApplication.java | 0 .../testapps/SwingApplicationWrapper.java | 0 .../testapps/TestBoundsLocation.java | 0 .../testapps/TestClickRobot.java | 0 .../javafxlibrary/testapps/TestDragRobot.java | 0 .../testapps/TestKeyboardRobot.java | 0 .../testapps/TestMultipleWindows.java | 0 .../testapps/TestPointLocation.java | 0 .../testapps/TestScreenCapturing.java | 0 .../testapps/TestScrollRobot.java | 0 .../testapps/TestScrollRobot2.java | 0 .../testapps/TestSleepRobot.java | 0 .../testapps/TestTableManagement.java | 0 .../testapps/TestWindowManagement.java | 0 .../controllers/DemoAppController.java | 0 .../controllers/ImageDemoController.java | 0 .../controllers/MenuAppController.java | 0 .../TestBoundsLocationController.java | 0 .../controllers/TestClickRobotController.java | 0 .../controllers/TestDragRobotController.java | 0 .../TestKeyboardRobotController.java | 0 .../TestMultipleWindowsController.java | 0 .../TestPointLocationController.java | 0 .../TestScreenCapturingController.java | 0 .../TestScrollRobot2Controller.java | 0 .../TestScrollRobotController.java | 0 .../controllers/TestSleepRobotController.java | 0 .../TestWindowManagementController.java | 0 .../controllers/TextListController.java | 0 .../ColorChangingRectangle.java | 0 .../testapps/customcomponents/ImageDemo.java | 0 .../testapps/customcomponents/Statistic.java | 0 .../testapps/customcomponents/TextList.java | 0 .../testapps/customcomponents/TextRow.java | 0 src/test/robotframework/resource.robot | 4 ++ 53 files changed, 134 insertions(+), 44 deletions(-) rename src/{main => test}/java/javafxlibrary/testapps/DatePickerApp.java (100%) rename src/{main => test}/java/javafxlibrary/testapps/DemoApp.java (100%) rename src/{main => test}/java/javafxlibrary/testapps/FinderApp.java (100%) rename src/{main => test}/java/javafxlibrary/testapps/MenuApp.java (100%) rename src/{main => test}/java/javafxlibrary/testapps/SwingApplication.java (100%) rename src/{main => test}/java/javafxlibrary/testapps/SwingApplicationWrapper.java (100%) rename src/{main => test}/java/javafxlibrary/testapps/TestBoundsLocation.java (100%) rename src/{main => test}/java/javafxlibrary/testapps/TestClickRobot.java (100%) rename src/{main => test}/java/javafxlibrary/testapps/TestDragRobot.java (100%) rename src/{main => test}/java/javafxlibrary/testapps/TestKeyboardRobot.java (100%) rename src/{main => test}/java/javafxlibrary/testapps/TestMultipleWindows.java (100%) rename src/{main => test}/java/javafxlibrary/testapps/TestPointLocation.java (100%) rename src/{main => test}/java/javafxlibrary/testapps/TestScreenCapturing.java (100%) rename src/{main => test}/java/javafxlibrary/testapps/TestScrollRobot.java (100%) rename src/{main => test}/java/javafxlibrary/testapps/TestScrollRobot2.java (100%) rename src/{main => test}/java/javafxlibrary/testapps/TestSleepRobot.java (100%) rename src/{main => test}/java/javafxlibrary/testapps/TestTableManagement.java (100%) rename src/{main => test}/java/javafxlibrary/testapps/TestWindowManagement.java (100%) rename src/{main => test}/java/javafxlibrary/testapps/controllers/DemoAppController.java (100%) rename src/{main => test}/java/javafxlibrary/testapps/controllers/ImageDemoController.java (100%) rename src/{main => test}/java/javafxlibrary/testapps/controllers/MenuAppController.java (100%) rename src/{main => test}/java/javafxlibrary/testapps/controllers/TestBoundsLocationController.java (100%) rename src/{main => test}/java/javafxlibrary/testapps/controllers/TestClickRobotController.java (100%) rename src/{main => test}/java/javafxlibrary/testapps/controllers/TestDragRobotController.java (100%) rename src/{main => test}/java/javafxlibrary/testapps/controllers/TestKeyboardRobotController.java (100%) rename src/{main => test}/java/javafxlibrary/testapps/controllers/TestMultipleWindowsController.java (100%) rename src/{main => test}/java/javafxlibrary/testapps/controllers/TestPointLocationController.java (100%) rename src/{main => test}/java/javafxlibrary/testapps/controllers/TestScreenCapturingController.java (100%) rename src/{main => test}/java/javafxlibrary/testapps/controllers/TestScrollRobot2Controller.java (100%) rename src/{main => test}/java/javafxlibrary/testapps/controllers/TestScrollRobotController.java (100%) rename src/{main => test}/java/javafxlibrary/testapps/controllers/TestSleepRobotController.java (100%) rename src/{main => test}/java/javafxlibrary/testapps/controllers/TestWindowManagementController.java (100%) rename src/{main => test}/java/javafxlibrary/testapps/controllers/TextListController.java (100%) rename src/{main => test}/java/javafxlibrary/testapps/customcomponents/ColorChangingRectangle.java (100%) rename src/{main => test}/java/javafxlibrary/testapps/customcomponents/ImageDemo.java (100%) rename src/{main => test}/java/javafxlibrary/testapps/customcomponents/Statistic.java (100%) rename src/{main => test}/java/javafxlibrary/testapps/customcomponents/TextList.java (100%) rename src/{main => test}/java/javafxlibrary/testapps/customcomponents/TextRow.java (100%) diff --git a/AUTHORS.txt b/AUTHORS.txt index e294876..4b5c288 100644 --- a/AUTHORS.txt +++ b/AUTHORS.txt @@ -7,3 +7,4 @@ Other contributors: Tatu Lahtela Find All With Pseudo Class and Find Class keywords Sakari Hoisko Dockerized linux env with X Juho Lehtonen Optimized docker environment. +Juho Saarinen Package improvements diff --git a/Dockerfile_build b/Dockerfile_build index c472fa7..d34c660 100644 --- a/Dockerfile_build +++ b/Dockerfile_build @@ -15,6 +15,7 @@ RUN mvn package FROM ubuntu:16.04 COPY --from=builder /code/target/javafxlibrary-*-SNAPSHOT-jar-with-dependencies.jar /. +COPY --from=builder /code/target/javafxlibrary-*-SNAPSHOT-tests.jar /. COPY entrypoint_build.sh /. RUN apt-get -qq update && apt-get dist-upgrade -y && apt-get install -qq --no-install-recommends --allow-unauthenticated -y \ openjdk-8-jre \ diff --git a/README.md b/README.md index e6b25a7..9d5acd1 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,15 @@ Library Remote http://127.0.0.1:8270 WITH NAME JavaFXLibrary ``` 4. Run your tests: `robot tests.robot` +## Using JavaFXLibrary on macOS Mojave +MacOS Mojave introduced changes to security settings and disabled some of the features JavaFXLibrary uses by default. +To use JavaFXLibrary on macOS Mojave you must enable the accessibility features for terminal in system preferences: +- Navigate to `Apple menu > System Preferences > Security & Privacy > Privacy > Accessibility` +- Click the lock and enter your password to change these settings +- If terminal has requested accessibility features before it should show in the list +- If not, add it by clicking :heavy_plus_sign: and selecting `Applications > Utilities > Terminal` +- Enable accessibility features by checking the box: :white_check_mark: Terminal + ## Identifying JavaFX UI objects [Scenic View](http://fxexperience.com/scenic-view/) is a tool that allows you to inspect the JavaFX application scenegraph. This can be useful especially when you do not have access to the source code. diff --git a/docker/robot-javafx-demo/test.sh b/docker/robot-javafx-demo/test.sh index b7572bc..59d1baf 100644 --- a/docker/robot-javafx-demo/test.sh +++ b/docker/robot-javafx-demo/test.sh @@ -5,7 +5,8 @@ function local() { echo "**********************" echo "INFO: Local execution:" file=$(ls -1 /javafxbinary/javafxlibrary-*-jar-with-dependencies.jar) - java -cp ${file} org.robotframework.RobotFramework -d /robot/results/local --include smoke $@ /robot/acceptance + testJar=$(ls -1 /javafxbinary/javafxlibrary-*-tests.jar) + java -cp ${file} org.robotframework.RobotFramework -d /robot/results/local --include smoke --variable appJar:${testJar} $@ /robot/acceptance # $@ #just to testing script if [[ "$?" != "0" ]]; then EXIT_VALUE=$((EXIT_VALUE+1)) @@ -15,7 +16,8 @@ function local() { function remote() { echo "***********************" echo "INFO: Remote execution:" - robot -d /robot/results/remote --include smoke $@ /robot/acceptance + testJar=$(ls -1 /javafxbinary/javafxlibrary-*-tests.jar) + robot -d /robot/results/remote --include smoke --variable appJar:${testJar} $@ /robot/acceptance # $@ #just to testing script if [[ "$?" != "0" ]]; then EXIT_VALUE=$((EXIT_VALUE+2)) diff --git a/entrypoint_build.sh b/entrypoint_build.sh index 1c61959..a4ba273 100644 --- a/entrypoint_build.sh +++ b/entrypoint_build.sh @@ -1,5 +1,6 @@ #!/usr/bin/env bash rm -rvf /javafxbinary/* cp -vf /javafxlibrary-*-jar-with-dependencies.jar /javafxbinary/. -chmod 555 /javafxbinary/javafxlibrary-*-jar-with-dependencies.jar +cp -vf /javafxlibrary-*-tests.jar /javafxbinary/. +chmod 555 /javafxbinary/* java -jar /javafxlibrary-*-jar-with-dependencies.jar diff --git a/pom.xml b/pom.xml index 372bf1d..c011ec2 100644 --- a/pom.xml +++ b/pom.xml @@ -21,7 +21,7 @@ org.robotframework javafxlibrary jar - 0.5.2-SNAPSHOT + 0.5.2 UTF-8 @@ -102,6 +102,33 @@ + + + org.codehaus.mojo + build-helper-maven-plugin + 1.10 + + + attach-artifacts + package + + attach-artifact + + + + + ${project.build.directory}/${project.artifactId}.html + html + + + ${project.build.directory}/${project.artifactId}.xml + xml + + + + + + org.apache.maven.plugins maven-gpg-plugin @@ -138,6 +165,11 @@ + + org.apache.maven.plugins + maven-surefire-plugin + 3.0.0-M1 + org.sonatype.plugins nexus-staging-maven-plugin @@ -219,6 +251,9 @@ TRACE:INFO false + + appJar:${project.build.directory}/${project.artifactId}*tests.jar + @@ -229,6 +264,7 @@ + ${project.build.directory} ${project.artifactId}.html JavaFXLibrary ${project.version} @@ -243,6 +279,7 @@ + ${project.build.directory} ${project.artifactId}.xml JavaFXLibrary ${project.version} @@ -272,6 +309,10 @@ com.google.common shaded.com.google.common + + org.apache.commons + shaded.org.apache.commons + @@ -299,7 +340,7 @@ org.apache.maven maven-model - 3.3.9 + 3.6.0 org.jmockit @@ -315,12 +356,7 @@ org.testfx testfx-core - 4.0.14-alpha - - - org.testfx - testfx-junit - 4.0.14-alpha + 4.0.15-alpha org.testfx @@ -336,7 +372,7 @@ org.robotframework robotframework - 3.0.2 + 3.0.4 org.hamcrest @@ -346,7 +382,7 @@ com.google.guava guava - 23.0 + 27.0.1-jre com.github.ombre42 diff --git a/src/main/java/JavaFXLibrary.java b/src/main/java/JavaFXLibrary.java index da646a5..c80b415 100644 --- a/src/main/java/JavaFXLibrary.java +++ b/src/main/java/JavaFXLibrary.java @@ -60,6 +60,9 @@ public class JavaFXLibrary extends AnnotationLibrary { public JavaFXLibrary() { super(includePatterns); deleteScreenshotsFrom("report-images/imagecomparison"); + //v4.0.15-alpha sets default robot as glass, which breaks rolling + //Forcing usage of awt robot as previous versions + System.setProperty("testfx.robot", "awt"); } @Autowired diff --git a/src/main/java/javafxlibrary/keywords/AdditionalKeywords/ApplicationLauncher.java b/src/main/java/javafxlibrary/keywords/AdditionalKeywords/ApplicationLauncher.java index 5485539..1e8c896 100644 --- a/src/main/java/javafxlibrary/keywords/AdditionalKeywords/ApplicationLauncher.java +++ b/src/main/java/javafxlibrary/keywords/AdditionalKeywords/ApplicationLauncher.java @@ -31,6 +31,7 @@ import java.net.URLClassLoader; import java.util.*; +import static javafxlibrary.utils.HelperFunctions.createThreadedWrapperApplication; import static javafxlibrary.utils.HelperFunctions.createWrapperApplication; import static javafxlibrary.utils.HelperFunctions.getMainClassFromJarFile; @@ -66,21 +67,40 @@ public void launchJavafxApplication(String appName, String... appArgs) { @ArgumentNames({"appName", "*args"}) public void launchSwingApplication(String appName, String... appArgs) { RobotLog.info("Starting application:" + appName); - Class c; + Class c = getMainClass(appName); + Application app = createWrapperApplication(c, appArgs); + createNewSession(app); + RobotLog.info("Application: " + appName + " started."); + } + + @RobotKeyword("Creates a wrapper application the same way as in `Launch Swing Application`, but starts it in a new " + + "thread. This is required when main method of the test application is blocked and execution does not " + + "return after calling it until the application gets closed. Be sure to set the library timeout with " + + "`Set Timeout` so that the test application will have enough time to load, as the test execution will " + + "continue instantly after calling the main method.\n\n" + + "``appName`` is the name of the application to launch. \n\n" + + "``appArgs`` is a list of arguments to be passed for the application. \n\n" + + "Example:\n" + + "| Launch Swing Application In Separate Thread | _javafxlibrary.testapps.SwingApplication |\n" + + "| Launch Swing Application In Separate Thread | _TestApplication.jar_ |\n") + @ArgumentNames({"appName", "*args"}) + public void launchSwingApplicationInSeparateThread(String appName, String... appArgs) { + RobotLog.info("Starting application:" + appName); + Class c = getMainClass(appName); + Application app = createThreadedWrapperApplication(c, appArgs); + createNewSession(app); + RobotLog.info("Application: " + appName + " started."); + } + private Class getMainClass(String appName) { try { if (appName.endsWith(".jar")) - c = getMainClassFromJarFile(appName); + return getMainClassFromJarFile(appName); else - c = Class.forName(appName); - + return Class.forName(appName); } catch (ClassNotFoundException e) { throw new JavaFXLibraryNonFatalException("Unable to launch application: " + appName, e); } - - Application app = createWrapperApplication(c, appArgs); - createNewSession(app); - RobotLog.info("Application: " + appName + " started."); } private void _addPathToClassPath(String path) { diff --git a/src/main/java/javafxlibrary/keywords/AdditionalKeywords/Verifiers.java b/src/main/java/javafxlibrary/keywords/AdditionalKeywords/Verifiers.java index f9b0c16..fa48610 100644 --- a/src/main/java/javafxlibrary/keywords/AdditionalKeywords/Verifiers.java +++ b/src/main/java/javafxlibrary/keywords/AdditionalKeywords/Verifiers.java @@ -252,7 +252,7 @@ public void imagesShouldMatch(Image image1, Image image2, double percentage) { throw new JavaFXLibraryNonFatalException("Images must be same size to compare: Image1 is " + (int)image1.getWidth() + "x" + (int)image1.getHeight() + " and Image2 is " + (int)image2.getWidth() + "x" + (int)image2.getHeight()); - PixelMatcherResult result = robotContext.getCaptureSupport().matchImages(image1, image2, new PixelMatcherRgb()); + PixelMatcherResult result = robotContext().getCaptureSupport().matchImages(image1, image2, new PixelMatcherRgb()); int sharedPixels = (int) (result.getMatchFactor() * 100); RobotLog.info("Matching pixels: " + sharedPixels + "%"); @@ -280,7 +280,7 @@ public void imagesShouldNotMatch(Image image1, Image image2, double percentage) throw new JavaFXLibraryNonFatalException("Images must be same size to compare: Image1 is " + (int)image1.getWidth() + "x" + (int)image1.getHeight() + " and Image2 is " + (int)image2.getWidth() + "x" + (int)image2.getHeight()); - PixelMatcherResult result = robotContext.getCaptureSupport().matchImages(image1, image2, new PixelMatcherRgb()); + PixelMatcherResult result = robotContext().getCaptureSupport().matchImages(image1, image2, new PixelMatcherRgb()); int nonSharedPixels = (int) (result.getNonMatchFactor() * 100); RobotLog.info("Matching pixels: " + nonSharedPixels + "%"); diff --git a/src/main/java/javafxlibrary/keywords/Keywords/KeyboardRobot.java b/src/main/java/javafxlibrary/keywords/Keywords/KeyboardRobot.java index ab6c70c..b45b44f 100644 --- a/src/main/java/javafxlibrary/keywords/Keywords/KeyboardRobot.java +++ b/src/main/java/javafxlibrary/keywords/Keywords/KeyboardRobot.java @@ -204,7 +204,7 @@ public void writeFast(String text) { + "`3. Locating or specifying UI elements`. \n\n" + "``text`` is the text characters to write\n" + "\nExample: \n" - + "| Write | Robot Framework | \n") + + "| Write To | Robot Framework | \n") @ArgumentNames({ "locator", "text" }) public FxRobotInterface writeTo(Object locator, String text) { RobotLog.info("Writing to " + locator); diff --git a/src/main/java/javafxlibrary/keywords/Keywords/ScreenCapturing.java b/src/main/java/javafxlibrary/keywords/Keywords/ScreenCapturing.java index d855160..ce546dd 100644 --- a/src/main/java/javafxlibrary/keywords/Keywords/ScreenCapturing.java +++ b/src/main/java/javafxlibrary/keywords/Keywords/ScreenCapturing.java @@ -86,7 +86,7 @@ public Object captureImage(Object locator, boolean logImage){ try { image = robot.capture(targetBounds).getImage(); Path path = createNewImageFileNameWithPath(); - robotContext.getCaptureSupport().saveImage(image, path); + robotContext().getCaptureSupport().saveImage(image, path); if (logImage) { Double printSize = targetBounds.getWidth() > 800 ? 800 : targetBounds.getWidth(); @@ -94,7 +94,7 @@ public Object captureImage(Object locator, boolean logImage){ if(TestFxAdapter.logImages.toLowerCase().equals("embedded")) { Image resizedImage = resizeImage(image, path); Path tempPath = Paths.get(getCurrentSessionScreenshotDirectory(), "temp.png"); - robotContext.getCaptureSupport().saveImage(resizedImage, tempPath); + robotContext().getCaptureSupport().saveImage(resizedImage, tempPath); File imageFile = convertToJpeg(tempPath); byte[] imageBytes = IOUtils.toByteArray(new FileInputStream(imageFile)); @@ -157,7 +157,7 @@ public Object loadImageFromUrl(String url) { public void saveImageAs(Image image, String path) { try { RobotLog.info("Saving image \"" + image + "\" to path \"" + path + "\""); - robotContext.getCaptureSupport().saveImage(image, Paths.get(path)); + robotContext().getCaptureSupport().saveImage(image, Paths.get(path)); } catch (Exception e) { if(e instanceof JavaFXLibraryNonFatalException) throw e; diff --git a/src/main/java/javafxlibrary/utils/HelperFunctions.java b/src/main/java/javafxlibrary/utils/HelperFunctions.java index d14142d..509be25 100644 --- a/src/main/java/javafxlibrary/utils/HelperFunctions.java +++ b/src/main/java/javafxlibrary/utils/HelperFunctions.java @@ -842,6 +842,28 @@ public void start(Stage primaryStage) { } } + public static Application createThreadedWrapperApplication(Class c, String... appArgs) { + try { + Method main = c.getMethod("main", String[].class); + return new Application() { + @Override + public void start(Stage primaryStage) { + Thread t = new Thread (() -> { + try { + main.invoke(null, (Object) appArgs); + + } catch (IllegalAccessException | InvocationTargetException e) { + throw new JavaFXLibraryNonFatalException("Unable to launch application: " + c.getName(), e); + } + }); + t.start(); + } + }; + } catch (NoSuchMethodException e) { + throw new JavaFXLibraryNonFatalException("Couldn't create wrapper application for " + c.getName(), e); + } + } + public static Finder createFinder() { return new Finder(); } diff --git a/src/main/java/javafxlibrary/utils/Session.java b/src/main/java/javafxlibrary/utils/Session.java index 45b78a5..5554031 100644 --- a/src/main/java/javafxlibrary/utils/Session.java +++ b/src/main/java/javafxlibrary/utils/Session.java @@ -24,14 +24,13 @@ import javafxlibrary.exceptions.JavaFXLibraryNonFatalException; import org.testfx.api.FxRobot; import org.testfx.api.FxToolkit; -import org.testfx.framework.junit.ApplicationTest; import javax.swing.*; import java.awt.*; import java.awt.event.WindowEvent; import java.util.concurrent.TimeoutException; -public class Session extends ApplicationTest { +public class Session { public Stage primaryStage; public FxRobot sessionRobot; @@ -40,7 +39,7 @@ public class Session extends ApplicationTest { public String screenshotDirectory = null; public Session(String appName, String... appArgs) { - try{ + try { // start the client this.primaryStage = FxToolkit.registerPrimaryStage(); this.sessionApplication = FxToolkit.setupApplication((Class)Class.forName(appName), appArgs); @@ -88,7 +87,7 @@ public void closeApplication() { sessionRobot.release(new KeyCode[] {}); sessionRobot.release(new MouseButton[] {}); FxToolkit.cleanupApplication(sessionApplication); - } catch (Exception e){ + } catch (Exception e) { throw new JavaFXLibraryNonFatalException("Problem shutting down the application: " + e.getMessage(), e); } } diff --git a/src/main/java/javafxlibrary/utils/TestFxAdapter.java b/src/main/java/javafxlibrary/utils/TestFxAdapter.java index 4ce01d9..9d79ce7 100644 --- a/src/main/java/javafxlibrary/utils/TestFxAdapter.java +++ b/src/main/java/javafxlibrary/utils/TestFxAdapter.java @@ -35,12 +35,6 @@ public static void setRobot(FxRobotInterface robot) { } public static FxRobotInterface getRobot() { return robot; } - // current robot context - protected static FxRobotContext robotContext; - public static void setRobotContext(FxRobotContext context) { - TestFxAdapter.robotContext = context; - } - // TODO: consider adding support for multiple sessions private static Session activeSession = null; @@ -62,14 +56,12 @@ in their start method for the controller class to load properly */ } setRobot(activeSession.sessionRobot); - setRobotContext(activeSession.robotContext()); } public void createNewSession(Application application) { activeSession = new Session(application); setRobot(activeSession.sessionRobot); - setRobotContext(activeSession.robotContext()); } public void deleteSession() { @@ -95,17 +87,17 @@ public String getCurrentSessionScreenshotDirectory() { public void setCurrentSessionScreenshotDirectory(String dir){ - if(activeSession != null) { + if (activeSession != null) { File errDir = new File(dir); - if(!errDir.exists()) + if (!errDir.exists()) errDir.mkdirs(); activeSession.screenshotDirectory = dir; - } - else + } else { throw new JavaFXLibraryNonFatalException("Unable to set screenshot directory, no application is currently open!"); + } } public static FxRobotContext robotContext() { - return robotContext; + return activeSession.sessionRobot.robotContext(); } } diff --git a/src/main/java/javafxlibrary/testapps/DatePickerApp.java b/src/test/java/javafxlibrary/testapps/DatePickerApp.java similarity index 100% rename from src/main/java/javafxlibrary/testapps/DatePickerApp.java rename to src/test/java/javafxlibrary/testapps/DatePickerApp.java diff --git a/src/main/java/javafxlibrary/testapps/DemoApp.java b/src/test/java/javafxlibrary/testapps/DemoApp.java similarity index 100% rename from src/main/java/javafxlibrary/testapps/DemoApp.java rename to src/test/java/javafxlibrary/testapps/DemoApp.java diff --git a/src/main/java/javafxlibrary/testapps/FinderApp.java b/src/test/java/javafxlibrary/testapps/FinderApp.java similarity index 100% rename from src/main/java/javafxlibrary/testapps/FinderApp.java rename to src/test/java/javafxlibrary/testapps/FinderApp.java diff --git a/src/main/java/javafxlibrary/testapps/MenuApp.java b/src/test/java/javafxlibrary/testapps/MenuApp.java similarity index 100% rename from src/main/java/javafxlibrary/testapps/MenuApp.java rename to src/test/java/javafxlibrary/testapps/MenuApp.java diff --git a/src/main/java/javafxlibrary/testapps/SwingApplication.java b/src/test/java/javafxlibrary/testapps/SwingApplication.java similarity index 100% rename from src/main/java/javafxlibrary/testapps/SwingApplication.java rename to src/test/java/javafxlibrary/testapps/SwingApplication.java diff --git a/src/main/java/javafxlibrary/testapps/SwingApplicationWrapper.java b/src/test/java/javafxlibrary/testapps/SwingApplicationWrapper.java similarity index 100% rename from src/main/java/javafxlibrary/testapps/SwingApplicationWrapper.java rename to src/test/java/javafxlibrary/testapps/SwingApplicationWrapper.java diff --git a/src/main/java/javafxlibrary/testapps/TestBoundsLocation.java b/src/test/java/javafxlibrary/testapps/TestBoundsLocation.java similarity index 100% rename from src/main/java/javafxlibrary/testapps/TestBoundsLocation.java rename to src/test/java/javafxlibrary/testapps/TestBoundsLocation.java diff --git a/src/main/java/javafxlibrary/testapps/TestClickRobot.java b/src/test/java/javafxlibrary/testapps/TestClickRobot.java similarity index 100% rename from src/main/java/javafxlibrary/testapps/TestClickRobot.java rename to src/test/java/javafxlibrary/testapps/TestClickRobot.java diff --git a/src/main/java/javafxlibrary/testapps/TestDragRobot.java b/src/test/java/javafxlibrary/testapps/TestDragRobot.java similarity index 100% rename from src/main/java/javafxlibrary/testapps/TestDragRobot.java rename to src/test/java/javafxlibrary/testapps/TestDragRobot.java diff --git a/src/main/java/javafxlibrary/testapps/TestKeyboardRobot.java b/src/test/java/javafxlibrary/testapps/TestKeyboardRobot.java similarity index 100% rename from src/main/java/javafxlibrary/testapps/TestKeyboardRobot.java rename to src/test/java/javafxlibrary/testapps/TestKeyboardRobot.java diff --git a/src/main/java/javafxlibrary/testapps/TestMultipleWindows.java b/src/test/java/javafxlibrary/testapps/TestMultipleWindows.java similarity index 100% rename from src/main/java/javafxlibrary/testapps/TestMultipleWindows.java rename to src/test/java/javafxlibrary/testapps/TestMultipleWindows.java diff --git a/src/main/java/javafxlibrary/testapps/TestPointLocation.java b/src/test/java/javafxlibrary/testapps/TestPointLocation.java similarity index 100% rename from src/main/java/javafxlibrary/testapps/TestPointLocation.java rename to src/test/java/javafxlibrary/testapps/TestPointLocation.java diff --git a/src/main/java/javafxlibrary/testapps/TestScreenCapturing.java b/src/test/java/javafxlibrary/testapps/TestScreenCapturing.java similarity index 100% rename from src/main/java/javafxlibrary/testapps/TestScreenCapturing.java rename to src/test/java/javafxlibrary/testapps/TestScreenCapturing.java diff --git a/src/main/java/javafxlibrary/testapps/TestScrollRobot.java b/src/test/java/javafxlibrary/testapps/TestScrollRobot.java similarity index 100% rename from src/main/java/javafxlibrary/testapps/TestScrollRobot.java rename to src/test/java/javafxlibrary/testapps/TestScrollRobot.java diff --git a/src/main/java/javafxlibrary/testapps/TestScrollRobot2.java b/src/test/java/javafxlibrary/testapps/TestScrollRobot2.java similarity index 100% rename from src/main/java/javafxlibrary/testapps/TestScrollRobot2.java rename to src/test/java/javafxlibrary/testapps/TestScrollRobot2.java diff --git a/src/main/java/javafxlibrary/testapps/TestSleepRobot.java b/src/test/java/javafxlibrary/testapps/TestSleepRobot.java similarity index 100% rename from src/main/java/javafxlibrary/testapps/TestSleepRobot.java rename to src/test/java/javafxlibrary/testapps/TestSleepRobot.java diff --git a/src/main/java/javafxlibrary/testapps/TestTableManagement.java b/src/test/java/javafxlibrary/testapps/TestTableManagement.java similarity index 100% rename from src/main/java/javafxlibrary/testapps/TestTableManagement.java rename to src/test/java/javafxlibrary/testapps/TestTableManagement.java diff --git a/src/main/java/javafxlibrary/testapps/TestWindowManagement.java b/src/test/java/javafxlibrary/testapps/TestWindowManagement.java similarity index 100% rename from src/main/java/javafxlibrary/testapps/TestWindowManagement.java rename to src/test/java/javafxlibrary/testapps/TestWindowManagement.java diff --git a/src/main/java/javafxlibrary/testapps/controllers/DemoAppController.java b/src/test/java/javafxlibrary/testapps/controllers/DemoAppController.java similarity index 100% rename from src/main/java/javafxlibrary/testapps/controllers/DemoAppController.java rename to src/test/java/javafxlibrary/testapps/controllers/DemoAppController.java diff --git a/src/main/java/javafxlibrary/testapps/controllers/ImageDemoController.java b/src/test/java/javafxlibrary/testapps/controllers/ImageDemoController.java similarity index 100% rename from src/main/java/javafxlibrary/testapps/controllers/ImageDemoController.java rename to src/test/java/javafxlibrary/testapps/controllers/ImageDemoController.java diff --git a/src/main/java/javafxlibrary/testapps/controllers/MenuAppController.java b/src/test/java/javafxlibrary/testapps/controllers/MenuAppController.java similarity index 100% rename from src/main/java/javafxlibrary/testapps/controllers/MenuAppController.java rename to src/test/java/javafxlibrary/testapps/controllers/MenuAppController.java diff --git a/src/main/java/javafxlibrary/testapps/controllers/TestBoundsLocationController.java b/src/test/java/javafxlibrary/testapps/controllers/TestBoundsLocationController.java similarity index 100% rename from src/main/java/javafxlibrary/testapps/controllers/TestBoundsLocationController.java rename to src/test/java/javafxlibrary/testapps/controllers/TestBoundsLocationController.java diff --git a/src/main/java/javafxlibrary/testapps/controllers/TestClickRobotController.java b/src/test/java/javafxlibrary/testapps/controllers/TestClickRobotController.java similarity index 100% rename from src/main/java/javafxlibrary/testapps/controllers/TestClickRobotController.java rename to src/test/java/javafxlibrary/testapps/controllers/TestClickRobotController.java diff --git a/src/main/java/javafxlibrary/testapps/controllers/TestDragRobotController.java b/src/test/java/javafxlibrary/testapps/controllers/TestDragRobotController.java similarity index 100% rename from src/main/java/javafxlibrary/testapps/controllers/TestDragRobotController.java rename to src/test/java/javafxlibrary/testapps/controllers/TestDragRobotController.java diff --git a/src/main/java/javafxlibrary/testapps/controllers/TestKeyboardRobotController.java b/src/test/java/javafxlibrary/testapps/controllers/TestKeyboardRobotController.java similarity index 100% rename from src/main/java/javafxlibrary/testapps/controllers/TestKeyboardRobotController.java rename to src/test/java/javafxlibrary/testapps/controllers/TestKeyboardRobotController.java diff --git a/src/main/java/javafxlibrary/testapps/controllers/TestMultipleWindowsController.java b/src/test/java/javafxlibrary/testapps/controllers/TestMultipleWindowsController.java similarity index 100% rename from src/main/java/javafxlibrary/testapps/controllers/TestMultipleWindowsController.java rename to src/test/java/javafxlibrary/testapps/controllers/TestMultipleWindowsController.java diff --git a/src/main/java/javafxlibrary/testapps/controllers/TestPointLocationController.java b/src/test/java/javafxlibrary/testapps/controllers/TestPointLocationController.java similarity index 100% rename from src/main/java/javafxlibrary/testapps/controllers/TestPointLocationController.java rename to src/test/java/javafxlibrary/testapps/controllers/TestPointLocationController.java diff --git a/src/main/java/javafxlibrary/testapps/controllers/TestScreenCapturingController.java b/src/test/java/javafxlibrary/testapps/controllers/TestScreenCapturingController.java similarity index 100% rename from src/main/java/javafxlibrary/testapps/controllers/TestScreenCapturingController.java rename to src/test/java/javafxlibrary/testapps/controllers/TestScreenCapturingController.java diff --git a/src/main/java/javafxlibrary/testapps/controllers/TestScrollRobot2Controller.java b/src/test/java/javafxlibrary/testapps/controllers/TestScrollRobot2Controller.java similarity index 100% rename from src/main/java/javafxlibrary/testapps/controllers/TestScrollRobot2Controller.java rename to src/test/java/javafxlibrary/testapps/controllers/TestScrollRobot2Controller.java diff --git a/src/main/java/javafxlibrary/testapps/controllers/TestScrollRobotController.java b/src/test/java/javafxlibrary/testapps/controllers/TestScrollRobotController.java similarity index 100% rename from src/main/java/javafxlibrary/testapps/controllers/TestScrollRobotController.java rename to src/test/java/javafxlibrary/testapps/controllers/TestScrollRobotController.java diff --git a/src/main/java/javafxlibrary/testapps/controllers/TestSleepRobotController.java b/src/test/java/javafxlibrary/testapps/controllers/TestSleepRobotController.java similarity index 100% rename from src/main/java/javafxlibrary/testapps/controllers/TestSleepRobotController.java rename to src/test/java/javafxlibrary/testapps/controllers/TestSleepRobotController.java diff --git a/src/main/java/javafxlibrary/testapps/controllers/TestWindowManagementController.java b/src/test/java/javafxlibrary/testapps/controllers/TestWindowManagementController.java similarity index 100% rename from src/main/java/javafxlibrary/testapps/controllers/TestWindowManagementController.java rename to src/test/java/javafxlibrary/testapps/controllers/TestWindowManagementController.java diff --git a/src/main/java/javafxlibrary/testapps/controllers/TextListController.java b/src/test/java/javafxlibrary/testapps/controllers/TextListController.java similarity index 100% rename from src/main/java/javafxlibrary/testapps/controllers/TextListController.java rename to src/test/java/javafxlibrary/testapps/controllers/TextListController.java diff --git a/src/main/java/javafxlibrary/testapps/customcomponents/ColorChangingRectangle.java b/src/test/java/javafxlibrary/testapps/customcomponents/ColorChangingRectangle.java similarity index 100% rename from src/main/java/javafxlibrary/testapps/customcomponents/ColorChangingRectangle.java rename to src/test/java/javafxlibrary/testapps/customcomponents/ColorChangingRectangle.java diff --git a/src/main/java/javafxlibrary/testapps/customcomponents/ImageDemo.java b/src/test/java/javafxlibrary/testapps/customcomponents/ImageDemo.java similarity index 100% rename from src/main/java/javafxlibrary/testapps/customcomponents/ImageDemo.java rename to src/test/java/javafxlibrary/testapps/customcomponents/ImageDemo.java diff --git a/src/main/java/javafxlibrary/testapps/customcomponents/Statistic.java b/src/test/java/javafxlibrary/testapps/customcomponents/Statistic.java similarity index 100% rename from src/main/java/javafxlibrary/testapps/customcomponents/Statistic.java rename to src/test/java/javafxlibrary/testapps/customcomponents/Statistic.java diff --git a/src/main/java/javafxlibrary/testapps/customcomponents/TextList.java b/src/test/java/javafxlibrary/testapps/customcomponents/TextList.java similarity index 100% rename from src/main/java/javafxlibrary/testapps/customcomponents/TextList.java rename to src/test/java/javafxlibrary/testapps/customcomponents/TextList.java diff --git a/src/main/java/javafxlibrary/testapps/customcomponents/TextRow.java b/src/test/java/javafxlibrary/testapps/customcomponents/TextRow.java similarity index 100% rename from src/main/java/javafxlibrary/testapps/customcomponents/TextRow.java rename to src/test/java/javafxlibrary/testapps/customcomponents/TextRow.java diff --git a/src/test/robotframework/resource.robot b/src/test/robotframework/resource.robot index 2802640..bff1e77 100644 --- a/src/test/robotframework/resource.robot +++ b/src/test/robotframework/resource.robot @@ -1,7 +1,11 @@ +*** Variables *** +${appJar} javafxlibrary-*-tests.jar + *** Keywords *** Import JavaFXLibrary Run Keyword If sys.platform.startswith('java') Import Library JavaFXLibrary ... ELSE Import Library Remote http://javafxcompile:8270 WITH NAME RemoteJavaFXLibrary + Set To Classpath ${appJar} Disable Embedded Image Logging For Negative Tests :FOR ${tag} IN @{TEST TAGS} From e82853ba9887ebb1182a2290681576e36bc78acf Mon Sep 17 00:00:00 2001 From: Sami Pesonen Date: Wed, 28 Nov 2018 22:56:51 +0200 Subject: [PATCH 50/95] 0.5.2 released --- docs/javafxlibrary.html | 1822 ++++++++--------- .../keywords/Keywords/KeyboardRobot.java | 2 +- 2 files changed, 912 insertions(+), 912 deletions(-) diff --git a/docs/javafxlibrary.html b/docs/javafxlibrary.html index de3aa26..7d15eb3 100644 --- a/docs/javafxlibrary.html +++ b/docs/javafxlibrary.html @@ -1,911 +1,911 @@ - - - - - - - - - - - - - - - - - - - -Codestin Search App - - - -
-

Opening library documentation failed

-
    -
  • Verify that you have JavaScript enabled in your browser.
  • -
  • Make sure you are using a modern enough browser. Firefox 3.5, IE 8, or equivalent is required, newer browsers are recommended.
  • -
  • Check are there messages in your browser's JavaScript error log. Please report the problem if you suspect you have encountered a bug.
  • -
-
- - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + +Codestin Search App + + + +
+

Opening library documentation failed

+
    +
  • Verify that you have JavaScript enabled in your browser.
  • +
  • Make sure you are using a modern enough browser. Firefox 3.5, IE 8, or equivalent is required, newer browsers are recommended.
  • +
  • Check are there messages in your browser's JavaScript error log. Please report the problem if you suspect you have encountered a bug.
  • +
+
+ + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/javafxlibrary/keywords/Keywords/KeyboardRobot.java b/src/main/java/javafxlibrary/keywords/Keywords/KeyboardRobot.java index b45b44f..828a277 100644 --- a/src/main/java/javafxlibrary/keywords/Keywords/KeyboardRobot.java +++ b/src/main/java/javafxlibrary/keywords/Keywords/KeyboardRobot.java @@ -204,7 +204,7 @@ public void writeFast(String text) { + "`3. Locating or specifying UI elements`. \n\n" + "``text`` is the text characters to write\n" + "\nExample: \n" - + "| Write To | Robot Framework | \n") + + "| Write To | .css-name | Robot Framework | \n") @ArgumentNames({ "locator", "text" }) public FxRobotInterface writeTo(Object locator, String text) { RobotLog.info("Writing to " + locator); From 233a42ff696e7886d98aaf6ef5d4bf16d87a4489 Mon Sep 17 00:00:00 2001 From: Sami Pesonen Date: Thu, 29 Nov 2018 09:26:27 +0200 Subject: [PATCH 51/95] development branch with 0.5.3-SNAPSHOT --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index c011ec2..114f5e2 100644 --- a/pom.xml +++ b/pom.xml @@ -21,7 +21,7 @@ org.robotframework javafxlibrary jar - 0.5.2 + 0.5.3-SNAPSHOT UTF-8 From 599c6df0e267f01e532825a33182d5e230675123 Mon Sep 17 00:00:00 2001 From: Sami Pesonen Date: Thu, 29 Nov 2018 10:13:54 +0200 Subject: [PATCH 52/95] add Nexus part to BUILD.md --- BUILD.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/BUILD.md b/BUILD.md index 903c64e..defb0d8 100644 --- a/BUILD.md +++ b/BUILD.md @@ -58,8 +58,12 @@ JavaFXLibrary uses Apache Maven as a build tool. ```` * Release snapshot or actual release (depending what is in version tag in pom.xml)``mvn clean deploy -P release`` + * In case of release log in to https://oss.sonatype.org: + * from left choose `Staging repositories` and scroll down, choose `robotframework-*` repository and review + * choose from top toolbar `Release`, add to reason field `x.y.z release` and submit + * sync takes typically hours before visible in Maven Central * snapshots can be found from https://oss.sonatype.org/content/repositories/snapshots/org/robotframework/javafxlibrary/ - * actual releases can be found from https://search.maven.org/ and typing `javafxlibrary` in the search field. + * actual releases can be found from https://search.maven.org/ and typing `javafxlibrary` in the search field. ## Announcements From 10e29319d305ed332af251346058111a9903b5ff Mon Sep 17 00:00:00 2001 From: Juho Saarinen Date: Thu, 29 Nov 2018 14:56:06 +0200 Subject: [PATCH 53/95] Helper function for bringing the window that's going to be clicked on the front --- src/main/java/javafxlibrary/utils/HelperFunctions.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/javafxlibrary/utils/HelperFunctions.java b/src/main/java/javafxlibrary/utils/HelperFunctions.java index 509be25..e4a7327 100644 --- a/src/main/java/javafxlibrary/utils/HelperFunctions.java +++ b/src/main/java/javafxlibrary/utils/HelperFunctions.java @@ -29,6 +29,7 @@ import javafx.stage.Window; import javafxlibrary.exceptions.JavaFXLibraryNonFatalException; import javafxlibrary.exceptions.JavaFXLibraryTimeoutException; +import javafxlibrary.keywords.AdditionalKeywords.ConvenienceKeywords; import javafxlibrary.matchers.ProgressBarMatchers; import javafxlibrary.utils.finder.Finder; import org.apache.commons.lang3.StringUtils; @@ -425,6 +426,7 @@ public static void checkClickLocation(int x, int y) { public static void checkClickLocation(Object object) { RobotLog.trace("Checking if target \"" + object.toString() + "\" is within active window"); + verifyClickLocationOnFront(object); if (safeClicking) { @@ -438,6 +440,10 @@ public static void checkClickLocation(Object object) { } RobotLog.trace("Target location checks out OK, it is within active window"); } + + public static void verifyClickLocationOnFront(Object object) { + new ConvenienceKeywords().bringStageToFront((Stage) objectToNode(object).getScene().getWindow()); + } public static Object checkClickTarget(Object target) { try { From a480220f54074cb067f88528f4269f4b752e878d Mon Sep 17 00:00:00 2001 From: Juho Saarinen Date: Fri, 30 Nov 2018 09:49:55 +0200 Subject: [PATCH 54/95] Storing info about headless execution to variable Using normal write if fast write is called at headless mode At clicking trying to bring window containing element to the top --- src/main/java/JavaFXLibrary.java | 2 ++ .../keywords/Keywords/KeyboardRobot.java | 33 +++++++++++-------- .../javafxlibrary/utils/HelperFunctions.java | 12 ++++--- .../javafxlibrary/utils/TestFxAdapter.java | 1 + 4 files changed, 30 insertions(+), 18 deletions(-) diff --git a/src/main/java/JavaFXLibrary.java b/src/main/java/JavaFXLibrary.java index 54d65a3..984259d 100644 --- a/src/main/java/JavaFXLibrary.java +++ b/src/main/java/JavaFXLibrary.java @@ -31,6 +31,7 @@ import javafxlibrary.keywords.AdditionalKeywords.RunOnFailure; import javafxlibrary.utils.HelperFunctions; import javafxlibrary.utils.RobotLog; +import javafxlibrary.utils.TestFxAdapter; import javafxlibrary.utils.TestListener; import org.apache.commons.io.FileUtils; import org.python.google.common.base.Throwables; @@ -69,6 +70,7 @@ public JavaFXLibrary(boolean headless) { System.setProperty("testfx.headless", "true"); System.setProperty("prism.order", "sw"); System.setProperty("prism.text", "t2k"); + TestFxAdapter.isHeadless = true; } else { //v4.0.15-alpha sets default robot as glass, which breaks rolling //Forcing usage of awt robot as previous versions diff --git a/src/main/java/javafxlibrary/keywords/Keywords/KeyboardRobot.java b/src/main/java/javafxlibrary/keywords/Keywords/KeyboardRobot.java index 828a277..eb31498 100644 --- a/src/main/java/javafxlibrary/keywords/Keywords/KeyboardRobot.java +++ b/src/main/java/javafxlibrary/keywords/Keywords/KeyboardRobot.java @@ -183,20 +183,25 @@ public FxRobotInterface write(String text) { + "| Write Fast | Robot Framework | \n") @ArgumentNames({ "text" }) public void writeFast(String text) { - try { - Clipboard c = Toolkit.getDefaultToolkit().getSystemClipboard(); - StringSelection testData = new StringSelection(text); - c.setContents(testData, testData); - - if(isMac()) - robot.push(KeyCode.META, KeyCode.V).sleep(100); - else - robot.push(KeyCode.CONTROL, KeyCode.V).sleep(100); - } catch (Exception e) { - if(e instanceof JavaFXLibraryNonFatalException) - throw e; - throw new JavaFXLibraryNonFatalException("Unable to write text using copy/paste method.", e); - } + if (TestFxAdapter.isHeadless) { + RobotLog.info("Fast write not working in headless mode. Writing text normally"); + this.write(text); + } else { + try { + Clipboard c = Toolkit.getDefaultToolkit().getSystemClipboard(); + StringSelection testData = new StringSelection(text); + c.setContents(testData, testData); + + if(isMac()) + robot.push(KeyCode.META, KeyCode.V).sleep(100); + else + robot.push(KeyCode.CONTROL, KeyCode.V).sleep(100); + } catch (Exception e) { + if(e instanceof JavaFXLibraryNonFatalException) + throw e; + throw new JavaFXLibraryNonFatalException("Unable to write text using copy/paste method.", e); + } + } } @RobotKeyword("Writes a given text characters one after the other to given locator.\n\n" diff --git a/src/main/java/javafxlibrary/utils/HelperFunctions.java b/src/main/java/javafxlibrary/utils/HelperFunctions.java index e4a7327..04e4983 100644 --- a/src/main/java/javafxlibrary/utils/HelperFunctions.java +++ b/src/main/java/javafxlibrary/utils/HelperFunctions.java @@ -426,7 +426,6 @@ public static void checkClickLocation(int x, int y) { public static void checkClickLocation(Object object) { RobotLog.trace("Checking if target \"" + object.toString() + "\" is within active window"); - verifyClickLocationOnFront(object); if (safeClicking) { @@ -442,15 +441,20 @@ public static void checkClickLocation(Object object) { } public static void verifyClickLocationOnFront(Object object) { - new ConvenienceKeywords().bringStageToFront((Stage) objectToNode(object).getScene().getWindow()); + try { + new ConvenienceKeywords().bringStageToFront((Stage) objectToNode(object).getScene().getWindow()); + } catch (Exception e) { + RobotLog.trace("Node's window wasn't castable to Stage. Tried with object: "+object); + } } public static Object checkClickTarget(Object target) { try { - if (target instanceof String || target instanceof Node) + if (target instanceof String || target instanceof Node) { target = waitUntilEnabled(waitUntilVisible(target, waitUntilTimeout), waitUntilTimeout); - + verifyClickLocationOnFront(target); + } checkClickLocation(target); return target; diff --git a/src/main/java/javafxlibrary/utils/TestFxAdapter.java b/src/main/java/javafxlibrary/utils/TestFxAdapter.java index 9d79ce7..3fd7b45 100644 --- a/src/main/java/javafxlibrary/utils/TestFxAdapter.java +++ b/src/main/java/javafxlibrary/utils/TestFxAdapter.java @@ -28,6 +28,7 @@ public class TestFxAdapter { + public static boolean isHeadless = false; // current robot instance in use protected static FxRobotInterface robot; public static void setRobot(FxRobotInterface robot) { From bbb9236dd8a923ddefeba3786327d2652ec4059d Mon Sep 17 00:00:00 2001 From: Juho Saarinen Date: Fri, 30 Nov 2018 12:50:05 +0200 Subject: [PATCH 55/95] - Tagging monocle failing tests with "monocle-issue" if headless mode is enabled - Checking in scrolling tests that app is in right stage at the beginning of test case - Initializing library as headless mode false --- src/test/robotframework/acceptance/ScrollRobotTest.robot | 1 + src/test/robotframework/acceptance/ScrollRobotTest2.robot | 8 ++++++++ .../acceptance/SwingApplicationWrapperTest.robot | 3 +++ src/test/robotframework/acceptance/WindowLookupTest.robot | 1 + src/test/robotframework/resource.robot | 5 +++-- 5 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/test/robotframework/acceptance/ScrollRobotTest.robot b/src/test/robotframework/acceptance/ScrollRobotTest.robot index f84cc8d..8ed56ed 100644 --- a/src/test/robotframework/acceptance/ScrollRobotTest.robot +++ b/src/test/robotframework/acceptance/ScrollRobotTest.robot @@ -69,6 +69,7 @@ Scroll Right *** Keywords *** Setup all tests Import JavaFXLibrary + Run Keyword If ${headless} Set Tags monocle-issue Launch Javafx Application ${TEST_APPLICATION} Set Screenshot Directory ${OUTPUT_DIR}${/}report-images Set Variables diff --git a/src/test/robotframework/acceptance/ScrollRobotTest2.robot b/src/test/robotframework/acceptance/ScrollRobotTest2.robot index abe7f4c..6f046e8 100644 --- a/src/test/robotframework/acceptance/ScrollRobotTest2.robot +++ b/src/test/robotframework/acceptance/ScrollRobotTest2.robot @@ -13,23 +13,27 @@ ${TEST_APPLICATION} javafxlibrary.testapps.TestScrollRobot2 *** Test Cases *** Scroll down [Tags] smoke demo-set + Verify String Should Not Match id=verticalScrollLocation max Scroll Vertically DOWN 50 Verify String id=verticalScrollLocation max Scroll up [Tags] smoke demo-set + Verify String Should Not Match id=verticalScrollLocation min Scroll Vertically UP 50 Verify String id=verticalScrollLocation min Scroll right [Tags] smoke demo-set Skip Test On Linux + Verify String Should Not Match id=horizontalScrollLocation max Scroll Horizontally RIGHT 50 Verify String id=horizontalScrollLocation max Scroll left [Tags] smoke demo-set Skip Test On Linux + Verify String Should Not Match id=horizontalScrollLocation min Scroll Horizontally LEFT 50 Verify String id=horizontalScrollLocation min @@ -41,24 +45,28 @@ Scroll down once Scroll up once [Tags] smoke + Verify String Should Not Match id=verticalScrollLocation min Scroll Vertically UP 1 Verify String id=verticalScrollLocation min Scroll Right Once [Tags] smoke Skip Test On Linux + Verify String id=horizontalScrollLocation min Scroll Horizontally RIGHT 1 Verify String Should Not Match id=horizontalScrollLocation min Scroll Left Once [Tags] smoke Skip Test On Linux + Verify String Should Not Match id=horizontalScrollLocation min Scroll Horizontally LEFT 1 Verify String id=horizontalScrollLocation min *** Keywords *** Setup all tests Import JavaFXLibrary + Run Keyword If ${headless} Set Tags monocle-issue Launch Javafx Application ${TEST_APPLICATION} Set Screenshot Directory ${OUTPUT_DIR}${/}report-images Move To id=scrollPane diff --git a/src/test/robotframework/acceptance/SwingApplicationWrapperTest.robot b/src/test/robotframework/acceptance/SwingApplicationWrapperTest.robot index 430e053..1043cfa 100644 --- a/src/test/robotframework/acceptance/SwingApplicationWrapperTest.robot +++ b/src/test/robotframework/acceptance/SwingApplicationWrapperTest.robot @@ -9,6 +9,7 @@ Test Teardown Teardown Test Case *** Testcases *** Swing Embedded JavaFX Click Test [Tags] smoke demo-set + Run Keyword If ${headless} Set Tags monocle-issue Launch Swing Application javafxlibrary.testapps.SwingApplication Wait Until Keyword Succeeds 15 sec 250ms Find css=.button failIfNotFound=True ${colors} Create List 0xdc143cff 0x00fa9aff 0xee82eeff 0xffff00ff 0x00ffffff @@ -19,6 +20,7 @@ Swing Embedded JavaFX Click Test Swing Embedded JavaFX Type Test [Tags] smoke + Run Keyword If ${headless} Set Tags monocle-issue Launch Swing Application javafxlibrary.testapps.SwingApplication Wait Until Keyword Succeeds 15 sec 250ms Find id=textField failIfNotFound=True Write To id=textField JavaFXLibrary @@ -26,6 +28,7 @@ Swing Embedded JavaFX Type Test Launch Swing Application Using External Wrapper Class [Tags] smoke + Run Keyword If ${headless} Set Tags monocle-issue Launch Javafx Application javafxlibrary.testapps.SwingApplicationWrapper Wait Until Keyword Succeeds 15 sec 250ms Find id=textField failIfNotFound=True Write To id=textField JavaFXLibrary diff --git a/src/test/robotframework/acceptance/WindowLookupTest.robot b/src/test/robotframework/acceptance/WindowLookupTest.robot index a0fb5fd..271a7f9 100644 --- a/src/test/robotframework/acceptance/WindowLookupTest.robot +++ b/src/test/robotframework/acceptance/WindowLookupTest.robot @@ -91,6 +91,7 @@ Bring Stage To Front # Keyword is located in TypeRobot Close Current Window [Tags] smoke set-todo + Run Keyword If ${headless} Set Tags monocle-issue ${START} List Windows Activate window @{START}[0] Close Current Window diff --git a/src/test/robotframework/resource.robot b/src/test/robotframework/resource.robot index bff1e77..754f8d3 100644 --- a/src/test/robotframework/resource.robot +++ b/src/test/robotframework/resource.robot @@ -1,10 +1,11 @@ *** Variables *** ${appJar} javafxlibrary-*-tests.jar +${headless} ${False} *** Keywords *** Import JavaFXLibrary - Run Keyword If sys.platform.startswith('java') Import Library JavaFXLibrary - ... ELSE Import Library Remote http://javafxcompile:8270 WITH NAME RemoteJavaFXLibrary + Run Keyword If sys.platform.startswith('java') Import Library JavaFXLibrary ${headless} + ... ELSE Import Library Remote http://javafxcompile:8270 ${headless} WITH NAME RemoteJavaFXLibrary Set To Classpath ${appJar} Disable Embedded Image Logging For Negative Tests From 14085d31a0737dc6aaf060ea9fd6ed45189e6403 Mon Sep 17 00:00:00 2001 From: Juho Saarinen Date: Fri, 30 Nov 2018 12:54:19 +0200 Subject: [PATCH 56/95] Updated documentation monocle-issue as non-critical tag --- BUILD.md | 4 ++-- README.md | 33 ++++++++++++++++++++++++++++++--- pom.xml | 3 +++ 3 files changed, 35 insertions(+), 5 deletions(-) diff --git a/BUILD.md b/BUILD.md index defb0d8..7265cc9 100644 --- a/BUILD.md +++ b/BUILD.md @@ -16,8 +16,8 @@ JavaFXLibrary uses Apache Maven as a build tool. are being used by both JavaFXLibrary and the AUT. It's not uncommon that a specific version is needed for AUT and another version of the same dependency is required for JavaFXLibrary(e.g. TestFX dependency for Google Guava). Not always are these dependencies backwards compatible and therefore JavaFXLibrary has adopted Apache Maven Shade Plugin to cope with this issue. - Currently the package com.google.common has been renamed in JavaFXLibrary as shaded.com.google.common to avoid version - mismatches with Google Guava dependencies. See https://maven.apache.org/plugins/maven-shade-plugin/ for more info. + Currently the package com.google.common has been renamed in JavaFXLibrary as shaded.com.google.common and org.apache.commons as shaded.org.apache.commons to avoid version + mismatches with dependencies in AUT and internally. See https://maven.apache.org/plugins/maven-shade-plugin/ for more info. ## Releasing diff --git a/README.md b/README.md index 9d5acd1..2302f0f 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,9 @@ JavaFXLibrary works with both Jython (local and remote use) and Python (remote o JavaFXLibrary is tested to work with Robot Framework 3.0.2 or later. ## Keyword documentation -See keyword [documentation](https://eficode.github.io/JavaFXLibrary/javafxlibrary.html). +See keyword [documentation](https://repo1.maven.org/maven2/org/robotframework/javafxlibrary/0.5.2/javafxlibrary-0.5.2.html). + +For editors (IDEs) keyword documentation can be obtained from [here](https://repo1.maven.org/maven2/org/robotframework/javafxlibrary/0.5.2/javafxlibrary-0.5.2.xml). ## Taking the library into use ### As a local library @@ -17,7 +19,7 @@ See keyword [documentation](https://eficode.github.io/JavaFXLibrary/javafxlibrar *** Settings *** Library JavaFXLibrary ``` -3. Add library jar to Jython [module search path](http://robotframework.org/robotframework/3.0b1/RobotFrameworkUserGuide.html#configuring-where-to-search-libraries-and-other-extensions) and run your tests: +3. Add library jar to Jython [module search path](http://robotframework.org/robotframework/3.0.4/RobotFrameworkUserGuide.html#configuring-where-to-search-libraries-and-other-extensions) and run your tests: ``` jython -J-cp javafxlibrary-.jar -m robot.run tests.robot ``` @@ -70,4 +72,29 @@ Library's acceptance test suite can be used as a JavaFXLibrary demo. Running the Executing _test.sh_ runs the acceptance suite twice: first using JavaFXLibrary as a local Robot Framework library on Jython, and after that using the library in remote mode executing the same tests on python version of Robot Framework. -If you want the suite to run only once, you can define which type of library to use by including **local** or **remote** as an argument. For example command `test.sh remote` will execute the suite only in remote mode. \ No newline at end of file +If you want the suite to run only once, you can define which type of library to use by including **local** or **remote** as an argument. For example command `test.sh remote` will execute the suite only in remote mode. + +## Experimental: Headless support +Library supports headless operation utilizing [Monocle](https://wiki.openjdk.java.net/display/OpenJFX/Monocle). The support for this is still at experimental level. + +### Main issues with headless function +* Scrolling doesn't work same way as with screen +** "Tick" (amount of scrolling) is much smaller in headless than normally +** Vertical (left/right) scrolling is not working +* Separate app windows' can't be closed (unless app offers that functionality itself) +* Swing applications can't be tested in headless mode. + +### Enabling headless mode +Headless mode can be enabled by setting first library initialization to "True". + +Locally: +``` +*** Settings *** +Library JavaFXLibrary ${True} +``` + +Remote: +``` +*** Settings *** +Library Remote http://127.0.0.1:8270 ${True} WITH NAME JavaFXLibrary +``` \ No newline at end of file diff --git a/pom.xml b/pom.xml index 79246a9..ce5cfcb 100644 --- a/pom.xml +++ b/pom.xml @@ -255,6 +255,9 @@ not-ready + + monocle-issue + TRACE:INFO false From e2c774a7e1fc1d6da3f7e054bc9da5316a558300 Mon Sep 17 00:00:00 2001 From: Juho Saarinen Date: Fri, 30 Nov 2018 14:23:48 +0200 Subject: [PATCH 57/95] Fixed list indent --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 2302f0f..0128a0d 100644 --- a/README.md +++ b/README.md @@ -79,8 +79,8 @@ Library supports headless operation utilizing [Monocle](https://wiki.openjdk.jav ### Main issues with headless function * Scrolling doesn't work same way as with screen -** "Tick" (amount of scrolling) is much smaller in headless than normally -** Vertical (left/right) scrolling is not working + * "Tick" (amount of scrolling) is much smaller in headless than normally + * Vertical (left/right) scrolling is not working * Separate app windows' can't be closed (unless app offers that functionality itself) * Swing applications can't be tested in headless mode. From f56306a2b762da44949bf317512b979db481190c Mon Sep 17 00:00:00 2001 From: Juho Saarinen Date: Tue, 4 Dec 2018 08:37:00 +0200 Subject: [PATCH 58/95] Capturing active window if locator is not given Capturing full screen in case of error (as focus is not probably set to window that is interesting Possibility to capture whole (primary) screen as a separate keyword Fixes eficode/JavaFXLibrary#19 --- .../AdditionalKeywords/RunOnFailure.java | 34 +++++++++++-------- .../keywords/Keywords/ScreenCapturing.java | 34 +++++++++++++++++-- 2 files changed, 52 insertions(+), 16 deletions(-) diff --git a/src/main/java/javafxlibrary/keywords/AdditionalKeywords/RunOnFailure.java b/src/main/java/javafxlibrary/keywords/AdditionalKeywords/RunOnFailure.java index bd94c52..6797357 100644 --- a/src/main/java/javafxlibrary/keywords/AdditionalKeywords/RunOnFailure.java +++ b/src/main/java/javafxlibrary/keywords/AdditionalKeywords/RunOnFailure.java @@ -17,10 +17,14 @@ package javafxlibrary.keywords.AdditionalKeywords; -import javafx.stage.Screen; +import javafx.geometry.Rectangle2D; import javafxlibrary.keywords.Keywords.ScreenCapturing; import javafxlibrary.utils.RobotLog; import javafxlibrary.utils.TestFxAdapter; + +import java.awt.GraphicsDevice; +import java.awt.GraphicsEnvironment; + import org.robotframework.javalib.annotation.RobotKeywords; @RobotKeywords @@ -30,7 +34,7 @@ public class RunOnFailure extends TestFxAdapter{ private String runOnFailureKeyword = "Take Screenshot"; // Only run keyword on failure if false - private boolean runningOnFailureRoutine = false; + private static boolean runningOnFailureRoutine = false; // ############################## @@ -55,17 +59,19 @@ public void runOnFailure() { runningOnFailureRoutine = true; - RobotLog.info("JavaFXLibrary keyword has failed!"); - if (robot == null) { - RobotLog.error("FxRobot not initialized, launch test application with the library"); - } - - if (robot.targetWindow() != null) { - new ScreenCapturing().captureImage(robot.targetWindow()); - } else { - new ScreenCapturing().captureImage(Screen.getPrimary().getBounds()); - } - - runningOnFailureRoutine = false; + try { + RobotLog.info("JavaFXLibrary keyword has failed!"); + if (robot == null) { + RobotLog.error("FxRobot not initialized, launch test application with the library"); + } else { + GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice(); + RobotLog.debug("Capturing screenshot from primary screen with resolution "+gd.getDisplayMode().getWidth()+"x"+gd.getDisplayMode().getHeight()+"."); + new ScreenCapturing().captureImage(new Rectangle2D(0, 0, gd.getDisplayMode().getWidth(), gd.getDisplayMode().getHeight())); + } + } catch (Exception e) { + RobotLog.error("Error when capturing screenshot. Actual error: "+e.getMessage()); + } finally { + runningOnFailureRoutine = false; + } } } \ No newline at end of file diff --git a/src/main/java/javafxlibrary/keywords/Keywords/ScreenCapturing.java b/src/main/java/javafxlibrary/keywords/Keywords/ScreenCapturing.java index ce546dd..a240b75 100644 --- a/src/main/java/javafxlibrary/keywords/Keywords/ScreenCapturing.java +++ b/src/main/java/javafxlibrary/keywords/Keywords/ScreenCapturing.java @@ -18,8 +18,12 @@ package javafxlibrary.keywords.Keywords; import javafx.embed.swing.SwingFXUtils; +import javafx.scene.Scene; import javafx.geometry.Bounds; +import javafx.geometry.Rectangle2D; import javafxlibrary.exceptions.JavaFXLibraryNonFatalException; +import javafxlibrary.keywords.AdditionalKeywords.ConvenienceKeywords; +import javafxlibrary.keywords.AdditionalKeywords.Find; import javafxlibrary.utils.RobotLog; import javafxlibrary.utils.TestFxAdapter; import org.apache.commons.io.IOUtils; @@ -29,6 +33,9 @@ import org.robotframework.javalib.annotation.RobotKeywords; import javafx.scene.image.Image; import javax.imageio.ImageIO; + +import java.awt.GraphicsDevice; +import java.awt.GraphicsEnvironment; import java.awt.image.BufferedImage; import java.io.*; import java.net.MalformedURLException; @@ -58,13 +65,25 @@ else if (value.toLowerCase().equals("diskonly")) throw new JavaFXLibraryNonFatalException("Value \"" + value + "\" is not supported! Value must be either " + "\"EMBEDDED\" or \"DISKONLY\""); } + + @RobotKeyword("Returns a screenshot from whole primary screen. Note that this shows also other applications that are open.") + public Object capturePrimaryScreen() { + GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice(); + return this.captureImage(new Rectangle2D(0, 0, gd.getDisplayMode().getWidth(), gd.getDisplayMode().getHeight())); + } + + @RobotKeywordOverload + public Object captureImage() { + return captureImage(robot.targetWindow()); + } @RobotKeywordOverload public Object captureImage(Object locator){ return captureImage(locator, true); } - @RobotKeyword("Returns a screenshot of the given locator.\n\n" + @RobotKeyword("Returns a screenshot of the given locator, or if not given from whole active window.\n\n" + + "Note that active window might only be part of the visible window, it e.g. dialog is active.\n\n" + "``locator`` is either a _query_ or _Object:Bounds, Node, Point2D, Rectangle, PointQuery, Scene, Window_ for identifying the element, see " + "`3. Locating or specifying UI elements`. \n\n" + "Argument ``logImage`` is a boolean value that specifies whether a captured image is also printed to test execution log. \n\n " @@ -73,8 +92,9 @@ public Object captureImage(Object locator){ + "| ${capture}= | Capture Image | ${region} | \n" + "| ${capture}= | Capture Image | ${node} | \n" + "| ${capture}= | Capture Image | ${window} | \n" + + "| ${capture}= | Capture Image | | \n" + "| ${capture}= | Capture Image | \\#id | logImage=False |\n" ) - @ArgumentNames({"locator", "logImage=True"}) + @ArgumentNames({"locator=target window", "logImage=True"}) public Object captureImage(Object locator, boolean logImage){ if (locator == null) throw new JavaFXLibraryNonFatalException("Unable to capture image, given locator was null!"); @@ -118,6 +138,16 @@ public Object captureImage(Object locator, boolean logImage){ throw new JavaFXLibraryNonFatalException("Unable to take capture : \"" + locator + "\"", e); } } + + @RobotKeyword("Returns a screenshot of the scene conatining given locator.\n\n" + + "``locator`` is a query locator, see `3.1 Using queries`.\n\n " + + "\nExample:\n" + + "| ${capture}= | Capture Scene Containing Node | ${node} | \n" ) + @ArgumentNames({"locator", "logImage=True"}) + public Object captureSceneContainingNode(Object locator) { + Scene scene = (Scene) useMappedObject(new ConvenienceKeywords().getScene(locator)); + return this.captureImage(scene); + } @RobotKeyword("Loads an image from the given _path_ in hard drive \n\n" + "``path`` is the source path for image in local hard drive. \n\n" From e6704041f6e779c3565721ca019c2d87b3683473 Mon Sep 17 00:00:00 2001 From: Esko Tajakka Date: Sat, 4 May 2019 23:55:28 +0300 Subject: [PATCH 59/95] Fixed incorrect jar filename with SNAPSHOT from jar file copy step in Dockerfile_build, added print of jar files --- Dockerfile_build | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Dockerfile_build b/Dockerfile_build index d34c660..6086fa9 100644 --- a/Dockerfile_build +++ b/Dockerfile_build @@ -14,8 +14,9 @@ RUN mvn package # ENTRYPOINT java -jar /code/target/javafxlibrary-*-SNAPSHOT-jar-with-dependencies.jar FROM ubuntu:16.04 -COPY --from=builder /code/target/javafxlibrary-*-SNAPSHOT-jar-with-dependencies.jar /. -COPY --from=builder /code/target/javafxlibrary-*-SNAPSHOT-tests.jar /. +COPY --from=builder /code/target/javafxlibrary-*-jar-with-dependencies.jar /. +COPY --from=builder /code/target/javafxlibrary-*-tests.jar /. +RUN echo "Built following jar files" && ls -latr /*.jar COPY entrypoint_build.sh /. RUN apt-get -qq update && apt-get dist-upgrade -y && apt-get install -qq --no-install-recommends --allow-unauthenticated -y \ openjdk-8-jre \ From 5ba5ac7ca6b9121447112b3daeb4bd3cb1c6758e Mon Sep 17 00:00:00 2001 From: Sami Pesonen Date: Mon, 19 Aug 2019 16:03:10 +0300 Subject: [PATCH 60/95] add multipointer support to demo containers --- docker-compose.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/docker-compose.yml b/docker-compose.yml index 6c63797..016492d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -14,6 +14,7 @@ services: - testapp environment: - RESOLUTION=1920x1080 + - X11VNC_ARGS=-multiptr javafxcompile: build: From 8681dc1895a4729cc485e7d117292c581656d62e Mon Sep 17 00:00:00 2001 From: Sami Pesonen Date: Wed, 21 Aug 2019 12:47:58 +0300 Subject: [PATCH 61/95] SwingApplicationWrapperTest fine tuning, variable for remote hostname --- .../acceptance/SwingApplicationWrapperTest.robot | 8 ++++---- src/test/robotframework/resource.robot | 3 ++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/test/robotframework/acceptance/SwingApplicationWrapperTest.robot b/src/test/robotframework/acceptance/SwingApplicationWrapperTest.robot index 1043cfa..9a16a2d 100644 --- a/src/test/robotframework/acceptance/SwingApplicationWrapperTest.robot +++ b/src/test/robotframework/acceptance/SwingApplicationWrapperTest.robot @@ -6,10 +6,10 @@ Suite Setup Import JavaFXLibrary Test Setup Disable Embedded Image Logging For Negative Tests Test Teardown Teardown Test Case -*** Testcases *** +*** Test Cases *** Swing Embedded JavaFX Click Test [Tags] smoke demo-set - Run Keyword If ${headless} Set Tags monocle-issue + Run Keyword If ${headless} Set Tags smonocle-issue Launch Swing Application javafxlibrary.testapps.SwingApplication Wait Until Keyword Succeeds 15 sec 250ms Find css=.button failIfNotFound=True ${colors} Create List 0xdc143cff 0x00fa9aff 0xee82eeff 0xffff00ff 0x00ffffff @@ -20,7 +20,7 @@ Swing Embedded JavaFX Click Test Swing Embedded JavaFX Type Test [Tags] smoke - Run Keyword If ${headless} Set Tags monocle-issue + Run Keyword If ${headless} Set Tags monocle-issue Launch Swing Application javafxlibrary.testapps.SwingApplication Wait Until Keyword Succeeds 15 sec 250ms Find id=textField failIfNotFound=True Write To id=textField JavaFXLibrary @@ -28,7 +28,7 @@ Swing Embedded JavaFX Type Test Launch Swing Application Using External Wrapper Class [Tags] smoke - Run Keyword If ${headless} Set Tags monocle-issue + Run Keyword If ${headless} Set Tags monocle-issue Launch Javafx Application javafxlibrary.testapps.SwingApplicationWrapper Wait Until Keyword Succeeds 15 sec 250ms Find id=textField failIfNotFound=True Write To id=textField JavaFXLibrary diff --git a/src/test/robotframework/resource.robot b/src/test/robotframework/resource.robot index 754f8d3..fa82c95 100644 --- a/src/test/robotframework/resource.robot +++ b/src/test/robotframework/resource.robot @@ -1,11 +1,12 @@ *** Variables *** ${appJar} javafxlibrary-*-tests.jar ${headless} ${False} +${host} javafxcompile *** Keywords *** Import JavaFXLibrary Run Keyword If sys.platform.startswith('java') Import Library JavaFXLibrary ${headless} - ... ELSE Import Library Remote http://javafxcompile:8270 ${headless} WITH NAME RemoteJavaFXLibrary + ... ELSE Import Library Remote http://${host}:8270 ${headless} WITH NAME RemoteJavaFXLibrary Set To Classpath ${appJar} Disable Embedded Image Logging For Negative Tests From cd6d81641fe4f75b3efd92acdc3ad9c84de3c7ce Mon Sep 17 00:00:00 2001 From: Sami Pesonen Date: Wed, 4 Sep 2019 12:11:30 +0300 Subject: [PATCH 62/95] workaround failIfNotFound at this point --- src/test/robotframework/acceptance/MiscTests.robot | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/test/robotframework/acceptance/MiscTests.robot b/src/test/robotframework/acceptance/MiscTests.robot index 20aaa9b..99f415a 100644 --- a/src/test/robotframework/acceptance/MiscTests.robot +++ b/src/test/robotframework/acceptance/MiscTests.robot @@ -15,15 +15,15 @@ ${CURRENT_APPLICATION} NOT SET Find Id That Does Not Exist [Tags] negative smoke Set Test Application javafxlibrary.testapps.TestBoundsLocation - ${MSG} Run Keyword And Expect Error * Find id=idThatDoesNotExist failIfNotFound=True + ${MSG} Run Keyword And Expect Error * Find id=idThatDoesNotExist ${True} # TODO: failIfNotFound=True Should Be Equal ${MSG} Unable to find anything with query: "id=idThatDoesNotExist" msg=Find does not fail with expected error message when query not found - ${MSG} Run Keyword Find id=idThatDoesNotExist failIfNotFound=False + ${MSG} Run Keyword Find id=idThatDoesNotExist ${False} # TODO: failIfNotFound=False Should Be Equal ${MSG} ${EMPTY} msg=Find does not return None value when query not found Find All With Wrong Style Class [Tags] negative smoke Set Test Application javafxlibrary.testapps.TestBoundsLocation - ${MSG} Run Keyword And Expect Error * Find All css=.thisIsNotAStyleClass failIfNotFound=True + ${MSG} Run Keyword And Expect Error * Find All css=.thisIsNotAStyleClass ${True} # TODO: failIfNotFound=True Should Be Equal ${MSG} Unable to find anything with query: "css=.thisIsNotAStyleClass" Print Child Nodes Of Incompatible Node From d4272a623d109e12831442d19d40d6ea18cf1987 Mon Sep 17 00:00:00 2001 From: Sami Pesonen Date: Fri, 8 Nov 2019 15:04:31 +0200 Subject: [PATCH 63/95] update dependencies, fix #26 async usage in waitUntilExists, library startup printout improvements --- pom.xml | 29 ++++++++++--------- src/main/java/JavaFXLibrary.java | 13 +++++---- .../javafxlibrary/utils/HelperFunctions.java | 21 +++++++++----- .../WaitUntilExistsTest.java | 1 - 4 files changed, 36 insertions(+), 28 deletions(-) diff --git a/pom.xml b/pom.xml index ce5cfcb..5434db4 100644 --- a/pom.xml +++ b/pom.xml @@ -80,7 +80,7 @@ org.apache.maven.plugins maven-source-plugin - 3.0.1 + 3.1.0 attach-sources @@ -93,7 +93,7 @@ org.apache.maven.plugins maven-javadoc-plugin - 3.0.1 + 3.1.1 attach-javadocs @@ -107,7 +107,7 @@ org.codehaus.mojo build-helper-maven-plugin - 1.10 + 3.0.0 attach-artifacts @@ -169,7 +169,7 @@ org.apache.maven.plugins maven-surefire-plugin - 3.0.0-M1 + 2.22.2 -javaagent:${settings.localRepository}/org/jmockit/jmockit/${jmockit.version}/jmockit-${jmockit.version}.jar @@ -189,7 +189,7 @@ maven-compiler-plugin - 3.6.1 + 3.8.1 1.8 1.8 @@ -198,7 +198,7 @@ org.apache.maven.plugins maven-jar-plugin - 3.0.2 + 3.2.0 @@ -217,7 +217,7 @@ maven-assembly-plugin - 3.0.0 + 3.2.0 package @@ -240,7 +240,7 @@ org.robotframework robotframework-maven-plugin - 1.4.7 + 1.5.1 acceptance tests @@ -251,6 +251,7 @@ smoke + not-ready @@ -300,7 +301,7 @@ org.apache.maven.plugins maven-shade-plugin - 3.1.0 + 3.2.1 package @@ -350,7 +351,7 @@ org.apache.maven maven-model - 3.6.0 + 3.6.2 org.jmockit @@ -366,7 +367,7 @@ org.testfx testfx-core - 4.0.15-alpha + 4.0.16-alpha org.testfx @@ -381,7 +382,7 @@ org.robotframework robotframework - 3.0.4 + 3.1.2 org.hamcrest @@ -391,7 +392,7 @@ com.google.guava guava - 27.0.1-jre + 28.1-jre com.github.ombre42 @@ -401,7 +402,7 @@ org.apache.commons commons-lang3 - 3.7 + 3.9 commons-io diff --git a/src/main/java/JavaFXLibrary.java b/src/main/java/JavaFXLibrary.java index 984259d..07d376c 100644 --- a/src/main/java/JavaFXLibrary.java +++ b/src/main/java/JavaFXLibrary.java @@ -44,6 +44,7 @@ import javax.script.ScriptEngineManager; import javax.script.ScriptException; import static javafxlibrary.utils.HelperFunctions.*; +import static org.testfx.util.WaitForAsyncUtils.waitFor; public class JavaFXLibrary extends AnnotationLibrary { @@ -64,7 +65,6 @@ public JavaFXLibrary() { public JavaFXLibrary(boolean headless) { super(includePatterns); - deleteScreenshotsFrom("report-images/imagecomparison"); if (headless) { System.setProperty("testfx.robot", "glass"); System.setProperty("testfx.headless", "true"); @@ -99,7 +99,7 @@ public Object runKeyword(String keywordName, Object[] args) { try { RobotLog.ignoreDuplicates(); // timeout + 500 ms so that underlying timeout has a chance to expire first - WaitForAsyncUtils.waitFor(getWaitUntilTimeout(TimeUnit.MILLISECONDS) + 500, TimeUnit.MILLISECONDS, () -> { + waitFor(getWaitUntilTimeout(TimeUnit.MILLISECONDS) + 500, TimeUnit.MILLISECONDS, () -> { try { retval.set(super.runKeyword(keywordName, finalArgs)); @@ -182,7 +182,7 @@ public static JavaFXLibrary getLibraryInstance() throws ScriptException { public static void main(String[] args) throws Exception { JavaFXLibraryRemoteServer.configureLogging(); - System.out.println("-------------------- JavaFXLibrary --------------------- "); + System.out.println("---------------------------= JavaFXLibrary =---------------------------- "); RemoteServer server = new JavaFXLibraryRemoteServer(); server.putLibrary("/RPC2", new JavaFXLibrary()); int port = 8270; @@ -192,12 +192,13 @@ public static void main(String[] args) throws Exception { if (args.length > 0) port = Integer.parseInt(args[0]); else - System.out.println("RemoteServer for JavaFXLibrary will be started at default port of: " + port + - ". If you wish to use another port, restart the library and give port number as an argument."); + System.out.println("RemoteServer for JavaFXLibrary will be started at default port of: " + port + ".\n" + + "If you wish to use another port, restart the library and give port number\n" + + "as an argument."); server.setPort(port); server.start(); - System.out.println("\n JavaFXLibrary " + ROBOT_LIBRARY_VERSION + " is now available at: " + + System.out.println("\n JavaFXLibrary " + ROBOT_LIBRARY_VERSION + " is now available at: " + ipAddr.getHostAddress() + ":" + port + "\n"); } catch (NumberFormatException nfe) { diff --git a/src/main/java/javafxlibrary/utils/HelperFunctions.java b/src/main/java/javafxlibrary/utils/HelperFunctions.java index 04e4983..1d68edb 100644 --- a/src/main/java/javafxlibrary/utils/HelperFunctions.java +++ b/src/main/java/javafxlibrary/utils/HelperFunctions.java @@ -54,7 +54,6 @@ import javafx.scene.input.KeyCode; import org.testfx.service.query.PointQuery; -import org.testfx.util.WaitForAsyncUtils; import java.util.List; import java.util.concurrent.TimeUnit; @@ -68,6 +67,9 @@ import static javafxlibrary.utils.TestFxAdapter.objectMap; import static javafxlibrary.utils.TestFxAdapter.robot; import static org.testfx.matcher.base.NodeMatchers.*; +import static org.testfx.util.WaitForAsyncUtils.waitFor; +import static org.testfx.util.WaitForAsyncUtils.asyncFx; +import static org.testfx.util.WaitForAsyncUtils.waitForFxEvents; public class HelperFunctions { @@ -83,10 +85,15 @@ public static Node waitUntilExists(String target, int timeout, String timeUnit) + timeout + ", timeUnit=" + timeUnit); try { - WaitForAsyncUtils.waitFor((long) timeout, getTimeUnit(timeUnit), () -> createFinder().find(target) != null); - Node node = createFinder().find(target); + waitFor(timeout, getTimeUnit(timeUnit), () -> { + return asyncFx(() -> createFinder().find(target) != null).get(); + }); + Node node = asyncFx(() -> createFinder().find(target)).get(); // TODO: Add null checks for node.getScene() - WaitForAsyncUtils.waitFor((long) timeout, getTimeUnit(timeUnit), () -> hasValidCoordinates(node)); + waitFor(timeout, getTimeUnit(timeUnit), () -> { + return asyncFx(() -> hasValidCoordinates(node)).get(); + }); + waitForFxEvents(); return node; } catch (TimeoutException te) { throw new JavaFXLibraryTimeoutException("Given element \"" + target + "\" was not found within given timeout of " @@ -108,7 +115,7 @@ public static Node waitUntilVisible(Object target, int timeout) { RobotLog.trace("Waiting until target \"" + target + "\" becomes visible, timeout=" + timeout); try { - WaitForAsyncUtils.waitFor((long) timeout, TimeUnit.SECONDS, () -> Matchers.is(isVisible()).matches(finalTarget)); + waitFor((long) timeout, TimeUnit.SECONDS, () -> Matchers.is(isVisible()).matches(finalTarget)); return (Node) target; } catch (JavaFXLibraryNonFatalException nfe) { throw nfe; @@ -129,7 +136,7 @@ public static Node waitUntilEnabled(Object target, int timeout) { RobotLog.trace("Waiting until target \"" + target + "\" becomes enabled, timeout=" + timeout); try { - WaitForAsyncUtils.waitFor((long) timeout, TimeUnit.SECONDS, () -> Matchers.is(isEnabled()).matches(finalTarget)); + waitFor((long) timeout, TimeUnit.SECONDS, () -> Matchers.is(isEnabled()).matches(finalTarget)); return (Node) target; } catch (JavaFXLibraryNonFatalException nfe) { throw nfe; @@ -143,7 +150,7 @@ public static Node waitUntilEnabled(Object target, int timeout) { public static void waitForProgressBarToFinish(ProgressBar pb, int timeout) { try { - WaitForAsyncUtils.waitFor((long) timeout, TimeUnit.SECONDS, () -> Matchers.is(ProgressBarMatchers.isComplete()).matches(pb)); + waitFor((long) timeout, TimeUnit.SECONDS, () -> Matchers.is(ProgressBarMatchers.isComplete()).matches(pb)); } catch (TimeoutException te) { throw new JavaFXLibraryNonFatalException("Given ProgressBar did not complete in " + timeout + " seconds!"); } diff --git a/src/test/java/javafxlibrary/utils/HelperFunctionsTests/WaitUntilExistsTest.java b/src/test/java/javafxlibrary/utils/HelperFunctionsTests/WaitUntilExistsTest.java index d1311e5..10aacc7 100644 --- a/src/test/java/javafxlibrary/utils/HelperFunctionsTests/WaitUntilExistsTest.java +++ b/src/test/java/javafxlibrary/utils/HelperFunctionsTests/WaitUntilExistsTest.java @@ -3,7 +3,6 @@ import javafx.scene.Node; import javafx.scene.control.Button; import javafxlibrary.TestFxAdapterTest; -import javafxlibrary.exceptions.JavaFXLibraryNonFatalException; import javafxlibrary.exceptions.JavaFXLibraryTimeoutException; import javafxlibrary.utils.finder.Finder; import javafxlibrary.utils.HelperFunctions; From 459329798751257d26f168582a7ad5de8a09fc1b Mon Sep 17 00:00:00 2001 From: Pasi Saikkonen Date: Fri, 8 Nov 2019 17:00:32 +0200 Subject: [PATCH 64/95] Fix local test set failing on Docker Running apt-get openjfx installs openjfx-11 which is incompatible with openjdk-8. Workaround is to install older version of openjfx. --- docker/robot-javafx-demo/Dockerfile | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/docker/robot-javafx-demo/Dockerfile b/docker/robot-javafx-demo/Dockerfile index fe1dbac..81e3eea 100644 --- a/docker/robot-javafx-demo/Dockerfile +++ b/docker/robot-javafx-demo/Dockerfile @@ -10,7 +10,12 @@ RUN apt-get -qq update && apt-get dist-upgrade -y && apt-get install -qq --no-i python-setuptools \ wget \ openjdk-8-jre \ - openjfx \ + # Install older version of openjfx, current version is incompatible with openjdk8 + # Bug ticket: https://bugs.launchpad.net/ubuntu/+source/openjfx/+bug/1799946 + openjfx=8u161-b12-1ubuntu2 \ + libopenjfx-java=8u161-b12-1ubuntu2 \ + libopenjfx-jni=8u161-b12-1ubuntu2 \ + openjfx-source=8u161-b12-1ubuntu2 \ && apt-get clean && rm -rf /var/lib/apt/lists/* COPY test.sh /bin/test.sh From ea2f3bb6a72d6d402a0f3cd19fb301d44be58b19 Mon Sep 17 00:00:00 2001 From: Sami Pesonen Date: Mon, 11 Nov 2019 13:45:58 +0200 Subject: [PATCH 65/95] fix named arguments in acceptance testing for now (without named argument) --- .../acceptance/SwingApplicationWrapperTest.robot | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/test/robotframework/acceptance/SwingApplicationWrapperTest.robot b/src/test/robotframework/acceptance/SwingApplicationWrapperTest.robot index 9a16a2d..f73662f 100644 --- a/src/test/robotframework/acceptance/SwingApplicationWrapperTest.robot +++ b/src/test/robotframework/acceptance/SwingApplicationWrapperTest.robot @@ -11,7 +11,7 @@ Swing Embedded JavaFX Click Test [Tags] smoke demo-set Run Keyword If ${headless} Set Tags smonocle-issue Launch Swing Application javafxlibrary.testapps.SwingApplication - Wait Until Keyword Succeeds 15 sec 250ms Find css=.button failIfNotFound=True + Wait Until Keyword Succeeds 15 sec 250ms Find css=.button ${True} ${colors} Create List 0xdc143cff 0x00fa9aff 0xee82eeff 0xffff00ff 0x00ffffff Text Value Should Be Swing Embedded JavaFX :FOR ${I} IN RANGE 0 5 @@ -22,7 +22,7 @@ Swing Embedded JavaFX Type Test [Tags] smoke Run Keyword If ${headless} Set Tags monocle-issue Launch Swing Application javafxlibrary.testapps.SwingApplication - Wait Until Keyword Succeeds 15 sec 250ms Find id=textField failIfNotFound=True + Wait Until Keyword Succeeds 15 sec 250ms Find id=textField ${True} Write To id=textField JavaFXLibrary Wait Until Keyword Succeeds 3 sec 250ms Text Value Should Be JavaFXLibrary @@ -30,7 +30,7 @@ Launch Swing Application Using External Wrapper Class [Tags] smoke Run Keyword If ${headless} Set Tags monocle-issue Launch Javafx Application javafxlibrary.testapps.SwingApplicationWrapper - Wait Until Keyword Succeeds 15 sec 250ms Find id=textField failIfNotFound=True + Wait Until Keyword Succeeds 15 sec 250ms Find id=textField ${True} Write To id=textField JavaFXLibrary Wait Until Keyword Succeeds 3 sec 250ms Text Value Should Be JavaFXLibrary From 63e70f19e7a4d427a23bd59c34715ed26cecd25f Mon Sep 17 00:00:00 2001 From: Sami Pesonen Date: Mon, 11 Nov 2019 15:58:44 +0200 Subject: [PATCH 66/95] 0.5.3 release preparation --- AUTHORS.txt | 15 ++++++++------- README.md | 6 +++--- docs/javafxlibrary.html | 19 ++++++++++--------- pom.xml | 2 +- 4 files changed, 22 insertions(+), 20 deletions(-) diff --git a/AUTHORS.txt b/AUTHORS.txt index 4b5c288..582711d 100644 --- a/AUTHORS.txt +++ b/AUTHORS.txt @@ -1,10 +1,11 @@ Core contributors: -Jukka Haavisto 2017 - -Sami Pesonen 2017 - -Pasi Saikkonen 2017 - +Jukka Haavisto 2017 - +Sami Pesonen 2017 - +Pasi Saikkonen 2017 - Other contributors: -Tatu Lahtela Find All With Pseudo Class and Find Class keywords -Sakari Hoisko Dockerized linux env with X -Juho Lehtonen Optimized docker environment. -Juho Saarinen Package improvements +Tatu Lahtela Find All With Pseudo Class and Find Class keywords +Sakari Hoisko Dockerized linux env with X +Juho Lehtonen Optimized docker environment. +Juho Saarinen Package improvements, initial monocle support, screenshot bug fix + diff --git a/README.md b/README.md index 0128a0d..96ae7b0 100644 --- a/README.md +++ b/README.md @@ -7,9 +7,9 @@ JavaFXLibrary works with both Jython (local and remote use) and Python (remote o JavaFXLibrary is tested to work with Robot Framework 3.0.2 or later. ## Keyword documentation -See keyword [documentation](https://repo1.maven.org/maven2/org/robotframework/javafxlibrary/0.5.2/javafxlibrary-0.5.2.html). +See keyword [documentation](https://repo1.maven.org/maven2/org/robotframework/javafxlibrary/0.5.3/javafxlibrary-0.5.3.html). -For editors (IDEs) keyword documentation can be obtained from [here](https://repo1.maven.org/maven2/org/robotframework/javafxlibrary/0.5.2/javafxlibrary-0.5.2.xml). +For editors (IDEs) keyword documentation can be obtained from [here](https://repo1.maven.org/maven2/org/robotframework/javafxlibrary/0.5.3/javafxlibrary-0.5.3.xml). ## Taking the library into use ### As a local library @@ -19,7 +19,7 @@ For editors (IDEs) keyword documentation can be obtained from [here](https://rep *** Settings *** Library JavaFXLibrary ``` -3. Add library jar to Jython [module search path](http://robotframework.org/robotframework/3.0.4/RobotFrameworkUserGuide.html#configuring-where-to-search-libraries-and-other-extensions) and run your tests: +3. Add library jar to Jython [module search path](http://robotframework.org/robotframework/3.1.2/RobotFrameworkUserGuide.html#configuring-where-to-search-libraries-and-other-extensions) and run your tests: ``` jython -J-cp javafxlibrary-.jar -m robot.run tests.robot ``` diff --git a/docs/javafxlibrary.html b/docs/javafxlibrary.html index 7d15eb3..ca40777 100644 --- a/docs/javafxlibrary.html +++ b/docs/javafxlibrary.html @@ -5,8 +5,8 @@ - - + +