From 6d95578cb92093c91db1aa27a5ad7b984baa937b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maarit=20H=C3=A4rk=C3=B6nen?= Date: Tue, 8 Oct 2024 08:51:29 +0300 Subject: [PATCH] Ms applications MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maarit Härkönen --- .../resources/common_keywords.resource | 13 ++++- .../test-suites/bat-tests/business_vm.robot | 45 ++++++++++---- flake.nix | 3 + .../default.nix | 58 +++++++++++++++++++ 4 files changed, 108 insertions(+), 11 deletions(-) create mode 100644 pkgs/robotframework-seleniumlibrary/default.nix diff --git a/Robot-Framework/resources/common_keywords.resource b/Robot-Framework/resources/common_keywords.resource index 2cac6713..e7528dad 100644 --- a/Robot-Framework/resources/common_keywords.resource +++ b/Robot-Framework/resources/common_keywords.resource @@ -19,8 +19,19 @@ Check that the application was started Should Not Be Empty ${app_pids} ${app_name} is not started Log To Console ${app_name} is started +Check Application Login Page + [Documentation] Check that application is able to connect to Internet and login page is available + [Arguments] ${application}=outlook + @{browser_ids} SeleniumLibrary.Get Browser Ids + Log ${browser_ids} + + ${source} SeleniumLibrary.Get source + Log ${source} + + ${handles} SeleniumLibrary.Get Window Handles + Log ${handles} + Check If Ping Fails [Documentation] Check that ping is not getting response from host - # ${out} Run and Return RC ping ${DEVICE_IP_ADDRESS} -c 1 ${result} Run Process ping ${DEVICE_IP_ADDRESS} -c1 timeout=1s Should Not Be Equal ${result.rc} ${0} \ No newline at end of file diff --git a/Robot-Framework/test-suites/bat-tests/business_vm.robot b/Robot-Framework/test-suites/bat-tests/business_vm.robot index 908008dd..65886b34 100644 --- a/Robot-Framework/test-suites/bat-tests/business_vm.robot +++ b/Robot-Framework/test-suites/bat-tests/business_vm.robot @@ -4,31 +4,36 @@ *** Settings *** Documentation Testing Business VM Force Tags bat businessvm lenovo-x1 +Resource ../../config/variables.robot Resource ../../resources/ssh_keywords.resource Resource ../../resources/virtualization_keywords.resource Resource ../../config/variables.robot Resource ../../resources/common_keywords.resource +Library SeleniumLibrary +# Suite Teardown Run Keywords Remove Wifi configuration AND Close All Connections Suite Teardown Close All Connections +Test Setup Run Keywords Connect to netvm AND Connect to VM ${GUI_VM} +*** Variables *** +${ta_wifi_ssid} TII-Testautomation +${netvm_ssh} ${EMPTY} -*** Test Cases *** +*** Test Cases *** Start Microsoft Outlook on LenovoX1 [Documentation] Start Microsoft Outlook in dedicated VM and verify process started - [Tags] outlook SP-T186 - Connect to netvm - Connect to VM ${GUI_VM} + [Tags] outlook SP-T186 SSRCSP-5328 + # Configure wifi ${netvm_ssh} ${ta_wifi_ssid} ${TA_WIFI_PSWD} lenovo=True Start XDG application "Microsoft Outlook" Connect to VM ${BUSINESS_VM} Check that the application was started outlook + Check Application Login Page [Teardown] Kill process @{app_pids} Start Microsoft 365 on LenovoX1 [Documentation] Start Microsoft 365 in dedicated VM and verify process started [Tags] microsoft365 SP-T188 - Connect to netvm - Connect to VM ${GUI_VM} Start XDG application "Microsoft 365" Connect to VM ${BUSINESS_VM} Check that the application was started microsoft365 @@ -37,8 +42,6 @@ Start Microsoft 365 on LenovoX1 Start Microsoft Teams on LenovoX1 [Documentation] Start Microsoft Teams in dedicated VM and verify process started [Tags] teams SP-T187 - Connect to netvm - Connect to VM ${GUI_VM} Start XDG application Teams Connect to VM ${BUSINESS_VM} Check that the application was started teams @@ -47,9 +50,31 @@ Start Microsoft Teams on LenovoX1 Start Microsoft Trusted Browser on LenovoX1 [Documentation] Start Microsoft Trusted Browser in dedicated VM and verify process started [Tags] trusted_browser SP-T189 - Connect to netvm - Connect to VM ${GUI_VM} Start XDG application "Trusted Browser" Connect to VM ${BUSINESS_VM} Check that the application was started chromium [Teardown] Kill process @{app_pids} + +*** Keywords *** +# Remove these after rebasing logging pr +Configure wifi + [Arguments] ${netvm_ssh} ${SSID} ${passw} ${lenovo}=False + Switch Connection ${netvm_ssh} + Log To Console Configuring Wifi + IF ${lenovo} + Execute Command nmcli dev wifi connect ${SSID} password ${passw} sudo=True sudo_password=${PASSWORD} + ELSE + Execute Command sh -c "wpa_passphrase ${SSID} ${passw} > /etc/wpa_supplicant.conf" sudo=True sudo_password=${PASSWORD} + Execute Command systemctl restart wpa_supplicant.service sudo=True sudo_password=${PASSWORD} + END + +Remove Wifi configuration + [Arguments] ${lenovo}=False + Switch Connection ${netvm_ssh} + Log To Console Removing Wifi configuration + IF ${lenovo} + Execute Command nmcli con down id ${SSID} sudo=True sudo_password=${PASSWORD} + ELSE + Execute Command rm /etc/wpa_supplicant.conf sudo=True sudo_password=${PASSWORD} + Execute Command systemctl restart wpa_supplicant.service sudo=True sudo_password=${PASSWORD} + END \ No newline at end of file diff --git a/flake.nix b/flake.nix index 3f82f551..30ae0f8e 100644 --- a/flake.nix +++ b/flake.nix @@ -26,10 +26,12 @@ robotframework-advancedlogging = self.packages.${system}.robotframework-advancedlogging; robotframework-jsonlibrary = self.packages.${system}.robotframework-jsonlibrary; robotframework-retryfailed = self.packages.${system}.robotframework-retryfailed; + robotframework-seleniumlibrary = self.packages.${system}.robotframework-seleniumlibrary; robotframework-seriallibrary = self.packages.${system}.robotframework-seriallibrary; }; robotframework-jsonlibrary = pkgs.python3Packages.callPackage ./pkgs/robotframework-jsonlibrary {}; robotframework-retryfailed = pkgs.python3Packages.callPackage ./pkgs/robotframework-retryfailed {}; + robotframework-seleniumlibrary = pkgs.python3Packages.callPackage ./pkgs/robotframework-seleniumlibrary {}; robotframework-seriallibrary = pkgs.python3Packages.callPackage ./pkgs/robotframework-seriallibrary {}; robotframework-advancedlogging = pkgs.python3Packages.callPackage ./pkgs/robotframework-advancedlogging {}; pkcs7 = pkgs.python3Packages.callPackage ./pkgs/pkcs7 {}; # Requirement of PyP100 @@ -47,6 +49,7 @@ robotframework self.packages.${system}.robotframework-jsonlibrary self.packages.${system}.robotframework-retryfailed + self.packages.${system}.robotframework-seleniumlibrary self.packages.${system}.robotframework-seriallibrary self.packages.${system}.robotframework-advancedlogging self.packages.${system}.PyP100 diff --git a/pkgs/robotframework-seleniumlibrary/default.nix b/pkgs/robotframework-seleniumlibrary/default.nix new file mode 100644 index 00000000..e53afed3 --- /dev/null +++ b/pkgs/robotframework-seleniumlibrary/default.nix @@ -0,0 +1,58 @@ +{ + lib, + buildPythonPackage, + fetchFromGitHub, + setuptools, + click, + robotframework, + robotframework-pythonlibcore, + selenium, + approvaltests, + pytest-mockito, + pytestCheckHook, + robotstatuschecker, +}: + +buildPythonPackage rec { + pname = "robotframework-seleniumlibrary"; + version = "6.6.1"; + pyproject = true; + + # no tests included in PyPI tarball + src = fetchFromGitHub { + owner = "robotframework"; + repo = "SeleniumLibrary"; + rev = "refs/tags/v${version}"; + sha256 = "sha256-ULY0FH1RFQIlhS45LU3vUKi6urZJHiDgi6NdqU5tV2g="; + }; + + build-system = [ setuptools ]; + + dependencies = [ + click + robotframework + robotframework-pythonlibcore + selenium + ]; + + nativeCheckInputs = [ + approvaltests + pytest-mockito + pytestCheckHook + robotstatuschecker + ]; + + preCheck = '' + mkdir utest/output_dir + ''; + + __darwinAllowLocalNetworking = true; + + meta = { + changelog = "https://github.com/robotframework/SeleniumLibrary/blob/${src.rev}/docs/SeleniumLibrary-${version}.rst"; + description = "Web testing library for Robot Framework"; + homepage = "https://github.com/robotframework/SeleniumLibrary"; + license = lib.licenses.asl20; + maintainers = with lib.maintainers; [ dotlambda ]; + }; +} \ No newline at end of file