diff --git a/.github/workflows/github-actions.yml b/.github/workflows/github-actions.yml new file mode 100644 index 000000000..70f2492d5 --- /dev/null +++ b/.github/workflows/github-actions.yml @@ -0,0 +1,348 @@ +on: + push: + branches: + - '*' + paths-ignore: + - README.md + tags: + - '*' + schedule: + - cron: '0 18 * * 0' +env: + solution: ${{ github.workspace }}/Ocaramba.sln + buildPlatform: Any CPU + buildConfiguration: Release + frameworkVersion: 4.0.0 + TestResultsDirWindows: D:\a\Ocaramba\Ocaramba\TestResults + CHROMEWEBDRIVER: C:\SeleniumWebDrivers\ChromeDriver + BuildVersion: 4.0.0${{ github.run_number }} + ChromeDriverVersion: 122.0.6261.9400 + seleniumGridVersion: selenium-server-4.8.0.jar + seleniumGridUrl: https://github.com/SeleniumHQ/selenium/releases/download/selenium-4.8.0/selenium-server-4.8.0.jar + NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages +jobs: + build_Stage_BuildTestsOnWindows: + runs-on: windows-latest + steps: + - uses: actions/checkout@v4 + - uses: microsoft/setup-msbuild@v2 + - shell: powershell + run: | + $tags = git tag --sort=-creatordate + $tag = $tags[0] + Write-Host "##vso[task.setvariable variable=frameworkVersion]$tag" + if: startsWith(github.ref, 'refs/tags/') + - shell: powershell + run: '(Get-Content ''Ocaramba.sln'' -raw) -replace [regex](''.*?'' + ''Documentation'' + (''.*?\r\n'' * (5 + 1))) | set-content ''Ocaramba.sln''' + - name: Update ChromeDriver in csproj + run: | + Get-ChildItem ./ *.csproj -recurse | + Foreach-Object { + $c = ($_ | Get-Content) + $c = $c -replace '109.0.5414.7400','${{ env.ChromeDriverVersion }}' + [IO.File]::WriteAllText($_.FullName, ($c -join "`r`n")) + } + - name: Setup nuget + uses: nuget/setup-nuget@v2 + with: + nuget-version: latest + - name: Cache + uses: actions/cache@v4 + with: + path: ${{ github.workspace }}\.nuget\packages + key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }} #hash of project files + restore-keys: | + ${{ runner.os }}-nuget- + - name: NuGet restore + run: nuget restore ${{ env.solution }} + - name: Set project versions + id: update + uses: vers-one/dotnet-project-version-updater@v1.4 + with: + file: | + "**/Ocaramba.csproj", "**/OcarambaLite.csproj" + version: ${{ env.frameworkVersion }} + - run: msbuild '${{ env.solution }}' /p:configuration='${{ env.buildConfiguration }}' /p:platform='${{ env.buildPlatform }}' /v:minimal + - uses: actions/upload-artifact@v4 + with: + path: ./Ocaramba/bin/Release/Ocaramba.${{ env.frameworkVersion }}.nupkg + name: Ocaramba${{ env.frameworkVersion }} + - uses: actions/upload-artifact@v4 + with: + path: ./Ocaramba/bin/Release/Ocaramba.${{ env.frameworkVersion }}.snupkg + name: OcarambaS${{ env.frameworkVersion }} + - uses: actions/upload-artifact@v4 + with: + path: ./OcarambaLite/bin/Release/OcarambaLite.${{ env.frameworkVersion }}.nupkg + name: OcarambaLite${{ env.frameworkVersion }} + - uses: actions/upload-artifact@v4 + with: + path: ./OcarambaLite/bin/Release/OcarambaLite.${{ env.frameworkVersion }}.snupkg + name: OcarambaLiteS${{ env.frameworkVersion }} + - name: Zip artifact for deployment + run: Compress-Archive -Path ./ -Destination OcarambaBuild.zip + - uses: actions/upload-artifact@v4 + with: + path: OcarambaBuild.zip + name: OcarambaBuild + compression-level: 0 + if: (${{ job.status }} != 'cancelled') + test_Stage_RunTestsOnDocker: + runs-on: ubuntu-latest + needs: + - build_Stage_BuildTestsOnWindows + steps: + - uses: actions/checkout@v4 + - run: docker buildx build -f Dockerfile -t ***/selenium:latest + if: false + - run: docker push -t Dockerfile + if: false + - run: docker-compose -f docker-compose.yml up -d + - run: ./ExecutingTestsOnDockerGithubActions.ps1 + if: false + - name: Publish Test Results + uses: EnricoMi/publish-unit-test-result-action/linux@v2 + if: false + with: + files: | + /home/runner/work/Ocaramba/Ocaramba/TestResults/Ocaramba.Tests.Docker.xml + test_Stage_RunTestsOnLinux: + runs-on: ubuntu-latest + needs: + - build_Stage_BuildTestsOnWindows + steps: + - uses: actions/checkout@v4 + - run: find . -name '*.csproj' -exec sed -i -e 's/109.0.5414.7400/${{ env.ChromeDriverVersion }}/g' {} \; + - run: | + ls + + export ASPNETCORE_ENVIRONMENT=Linux + + echo $ASPNETCORE_ENVIRONMENT + + sudo apt-get install google-chrome-stable + + sed -i '/Documentation/,+5 d' ./Ocaramba.sln + - run: dotnet build ./Ocaramba.sln --configuration ${{ env.buildConfiguration }} + - shell: pwsh + run: ./ExecutingTestsOnLinuxAzure.ps1 + - name: Publish Test Results + uses: EnricoMi/publish-unit-test-result-action/linux@v2 + if: false + with: + files: | + /home/runner/work/Ocaramba/Ocaramba/TestResults/Ocaramba.Tests.netcoreapp.xml + test_Stage_RunTestsOnLinuxBrowserStack: + runs-on: ubuntu-latest + timeout-minutes: 10 + needs: + - build_Stage_BuildTestsOnWindows + steps: + - uses: actions/checkout@v4 + - run: | + ls + + export ASPNETCORE_ENVIRONMENT=Linux + + echo $ASPNETCORE_ENVIRONMENT + + sed -i '/Documentation/,+5 d' ./Ocaramba.sln + - run: dotnet build ./Ocaramba.sln --configuration ${{ env.buildConfiguration }} + - shell: pwsh + if: false + env: + MAPPED_ENV_BROWSERSTACKKEY: ${{ env.browserstackkey }} + MAPPED_ENV_BROWSERSTACKUSER: ${{ env.browserstackuser }} + MAPPED_ENV_TESTINGBOTKEY: ${{ env.testingbotkey }} + MAPPED_ENV_TESTINGBOTSECRET: ${{ env.testingbotsecret }} + MAPPED_ENV_SAUCELABSACCESSKEY: ${{ env.saucelabsaccessKey }} + MAPPED_ENV_SAUCELABSUSERNAME: ${{ env.saucelabsusername }} + run: ./ExecutingTestsOnLinuxBrowserStackGithubActions.ps1 + - name: Publish Test Results + uses: EnricoMi/publish-unit-test-result-action/linux@v2 + if: false + with: + files: | + /home/runner/work/Ocaramba/Ocaramba/TestResults/BrowserStacknetcoreapp.xml + test_Stage_RunTestsOnWindowsCore1: + runs-on: windows-latest + needs: + - build_Stage_BuildTestsOnWindows + steps: + - uses: actions/checkout@v4 + - uses: nuget/setup-nuget@v2 + with: + nuget-version: latest + - uses: actions/download-artifact@v4 + with: + name: OcarambaBuild + - run: Expand-Archive -Path OcarambaBuild.zip -DestinationPath ./ + - run: ./ExecutingTestsOnWindowsGithubActions1.ps1 + - run: Get-ChildItem .\ -Recurse + - name: Publish Test Results + uses: EnricoMi/publish-unit-test-result-action/windows@v2 + if: always() + with: + files: ${{ env.TestResultsDirWindows }}\Ocaramba.Tests.netcoreapp.trx + - name: Zip artifact + run: Compress-Archive -Path D:\a\Ocaramba\Ocaramba\Ocaramba\Ocaramba.Tests.NUnitExtentReports\bin\Release\net6.0\TestOutput -Destination ExtentReports_${{ github.run_id }}.zip + - uses: actions/upload-artifact@v4 + with: + path: ExtentReports_${{ github.run_id }}.zip + name: ExtentTestReport + if: always() + test_Stage_RunTestsOnWindowsCore2: + runs-on: windows-latest + needs: + - build_Stage_BuildTestsOnWindows + steps: + - uses: actions/checkout@v4 + - uses: nuget/setup-nuget@v2 + with: + nuget-version: latest + - uses: actions/download-artifact@v4 + with: + name: OcarambaBuild + - run: Expand-Archive -Path OcarambaBuild.zip -DestinationPath ./ + - run: ./ExecutingTestsOnWindowsGithubActions2.ps1 + - run: Get-ChildItem .\ -Recurse + - name: Publish Test Results + uses: EnricoMi/publish-unit-test-result-action/windows@v2 + if: always() + with: + files: | + ${{ env.TestResultsDirWindows }}\Ocaramba.Tests.netcoreapp.xml + ${{ env.TestResultsDirWindows }}\Ocaramba.Tests.EdgeChrominum.xml + test_Stage_RunTestsOnWindowsFramework: + runs-on: windows-latest + needs: + - build_Stage_BuildTestsOnWindows + steps: + - uses: actions/checkout@v4 + - uses: nuget/setup-nuget@v2 + with: + nuget-version: latest + - uses: actions/download-artifact@v4 + with: + name: OcarambaBuild + - run: Expand-Archive -Path OcarambaBuild.zip -DestinationPath ./ + - run: ./ExecutingTestsOnWindowsGithubActions3.ps1 + - name: Publish Test Results + uses: EnricoMi/publish-unit-test-result-action/windows@v2 + if: always() + with: + files: ${{ env.TestResultsDirWindows }}\Ocaramba.Tests.net4.xml + test_Stage_RunTestsOnWindowsBrowserStack: + runs-on: windows-latest + needs: + - build_Stage_BuildTestsOnWindows + steps: + - uses: actions/checkout@v4 + - uses: nuget/setup-nuget@v2 + with: + nuget-version: latest + - uses: actions/download-artifact@v4 + with: + name: OcarambaBuild + - run: Expand-Archive -Path OcarambaBuild.zip -DestinationPath ./ + - run: ./ExecutingTestsOnWindowsGithubActions4.ps1 + env: + MAPPED_ENV_BROWSERSTACKKEY: ${{ env.browserstackkey }} + MAPPED_ENV_BROWSERSTACKUSER: ${{ env.browserstackuser }} + MAPPED_ENV_TESTINGBOTKEY: ${{ env.testingbotkey }} + MAPPED_ENV_TESTINGBOTSECRET: ${{ env.testingbotsecret }} + MAPPED_ENV_SAUCELABSACCESSKEY: ${{ env.saucelabsaccessKey }} + MAPPED_ENV_SAUCELABSUSERNAME: ${{ env.saucelabsusername }} + - name: Publish Test Results + uses: EnricoMi/publish-unit-test-result-action/windows@v2 + if: always() + with: + files: ${{ env.TestResultsDirWindows }}\Ocaramba.Tests.BrowserStack.xml + test_Stage_RunTestsSeleniumGrid: + runs-on: windows-latest + needs: + - build_Stage_BuildTestsOnWindows + steps: + - uses: actions/checkout@v4 + - uses: nuget/setup-nuget@v2 + with: + nuget-version: latest + - uses: actions/download-artifact@v4 + with: + name: OcarambaBuild + - run: Expand-Archive -Path OcarambaBuild.zip -DestinationPath ./ + - run: ./ExecutingTestsOnWindowsGithubActions5.ps1 + - name: Publish Test Results + uses: EnricoMi/publish-unit-test-result-action/windows@v2 + if: always() + with: + files: | + ${{ env.TestResultsDirWindows }}\Ocaramba.Tests.NUnitGrid.xml + ${{ env.TestResultsDirWindows }}\Ocaramba.Tests.CloudProviderCrossBrowserGrid.xml + test_Stage_RunTestsOnWindowsSaucelabs: + runs-on: windows-latest + needs: + - build_Stage_BuildTestsOnWindows + steps: + - uses: actions/checkout@v4 + - uses: nuget/setup-nuget@v2 + with: + nuget-version: latest + - uses: actions/download-artifact@v4 + with: + name: OcarambaBuild + - run: Expand-Archive -Path OcarambaBuild.zip -DestinationPath ./ + - run: ./ExecutingTestsOnWindowsGithubActions6.ps1 + env: + MAPPED_ENV_BROWSERSTACKKEY: ${{ env.browserstackkey }} + MAPPED_ENV_BROWSERSTACKUSER: ${{ env.browserstackuser }} + MAPPED_ENV_TESTINGBOTKEY: ${{ env.testingbotkey }} + MAPPED_ENV_TESTINGBOTSECRET: ${{ env.testingbotsecret }} + MAPPED_ENV_SAUCELABSACCESSKEY: ${{ env.saucelabsaccessKey }} + MAPPED_ENV_SAUCELABSUSERNAME: ${{ env.saucelabsusername }} + - name: Publish Test Results + uses: EnricoMi/publish-unit-test-result-action/windows@v2 + if: always() + with: + files: | + ${{ env.TestResultsDirWindows }}\Ocaramba.Tests.saucelabsnet472.xml + release_Stage_PublishNuget: + runs-on: windows-latest + needs: + - build_Stage_BuildTestsOnWindows + - test_Stage_RunTestsOnDocker + - test_Stage_RunTestsOnLinux + - test_Stage_RunTestsOnLinuxBrowserStack + - test_Stage_RunTestsOnWindowsCore1 + - test_Stage_RunTestsOnWindowsCore2 + - test_Stage_RunTestsOnWindowsFramework + - test_Stage_RunTestsOnWindowsBrowserStack + - test_Stage_RunTestsSeleniumGrid + - test_Stage_RunTestsOnWindowsSaucelabs + steps: + - uses: actions/checkout@v4 + - shell: powershell + run: | + $tags = git tag --sort=-creatordate + $tag = $tags[0] + Write-Host "##vso[task.setvariable variable=frameworkVersion]$tag" + if: startsWith(github.ref, 'refs/tags/') + - uses: actions/download-artifact@v4 + with: + name: Ocaramba${{ env.frameworkVersion }} + - uses: actions/download-artifact@v4 + with: + name: OcarambaS${{ env.frameworkVersion }} + - uses: actions/download-artifact@v4 + with: + name: OcarambaLite${{ env.frameworkVersion }} + - uses: actions/download-artifact@v4 + with: + name: OcarambaLiteS${{ env.frameworkVersion }} + - run: Get-ChildItem ./ -Recurse + - name: Push Nuget Package + run: dotnet custom push ${{ env.Agent.BuildDirectory }}\Ocaramba.${{ env.frameworkVersion }}.nupkg -s https://api.nuget.org/v3/index.json -k ${{ env.NuGetApiKey }} + if: (success() && startsWith(github.ref, 'refs/tags/')) + - name: Push Nuget Package + run: dotnet custom push ${{ env.Agent.BuildDirectory }}\OcarambaLite.${{ env.frameworkVersion }}.nupkg -s https://api.nuget.org/v3/index.json -k ${{ env.NuGetApiKey }} + if: (success() && startsWith(github.ref, 'refs/tags/')) \ No newline at end of file diff --git a/ExecutingTestsOnDockerGithubActions.ps1 b/ExecutingTestsOnDockerGithubActions.ps1 new file mode 100644 index 000000000..e7e55c474 --- /dev/null +++ b/ExecutingTestsOnDockerGithubActions.ps1 @@ -0,0 +1,18 @@ +docker info + +docker ps -a +docker exec ocaramba_selenium bash -c "ls ; sed -i '/Documentation/,+5 d' ./Ocaramba.sln ; dotnet build ./Ocaramba.sln" +docker exec ocaramba_selenium bash -c 'pwsh ./scripts/set_AppConfig_for_tests.ps1 \"./Ocaramba.Tests.NUnit/bin/Debug/net6.0\" \"appsettings.Linux.json\" \"appSettings\" \"browser|PathToChromeDriverDirectory\" \"Chrome|/chromedriver\" -logValues -json' +docker exec ocaramba_selenium bash -c 'dotnet vstest ./Ocaramba.Tests.NUnit/bin/Debug/net6.0/Ocaramba.Tests.NUnit.dll /TestCaseFilter:\"(TestCategory!=NotImplementedInCoreOrUploadDownload)\" /Parallel --logger:\"trx;LogFileName=Ocaramba.Tests.Docker.xml\"' + +docker cp ocaramba_selenium:/Ocaramba/TestResults/Ocaramba.Tests.Docker.xml . + + +docker rm ocaramba_selenium --force + +if($lastexitcode -ne 0) + { + echo 'lastexitcode' $lastexitcode + } + +exit 0 \ No newline at end of file diff --git a/ExecutingTestsOnLinuxAzure.ps1 b/ExecutingTestsOnLinuxAzure.ps1 index 07f17fb56..f43711584 100644 --- a/ExecutingTestsOnLinuxAzure.ps1 +++ b/ExecutingTestsOnLinuxAzure.ps1 @@ -16,4 +16,4 @@ if($lastexitcode -ne 0) echo 'lastexitcode' $lastexitcode } -exit 0 +exit 0 \ No newline at end of file diff --git a/ExecutingTestsOnLinuxBrowserStackGithubActions.ps1 b/ExecutingTestsOnLinuxBrowserStackGithubActions.ps1 new file mode 100644 index 000000000..2c5448ab8 --- /dev/null +++ b/ExecutingTestsOnLinuxBrowserStackGithubActions.ps1 @@ -0,0 +1,20 @@ +echo '********************************************CloudProviderCrossBrowser tests********************************************' + +echo '********************************************BrowserStack tests********************************************' +$Env:ASPNETCORE_ENVIRONMENT="Linux" + +echo $Env:ASPNETCORE_ENVIRONMENT + +.\scripts\set_AppConfig_for_tests.ps1 ".\Ocaramba.Tests.CloudProviderCrossBrowser\bin\Release\net6.0" "appsettings.Linux.json" "appSettings" "browser|PathToChromeDriverDirectory" "Chrome|$($env:CHROMEWEBDRIVER)" -logValues -json + +.\scripts\set_AppConfig_for_tests.ps1 ".\Ocaramba.Tests.CloudProviderCrossBrowser\bin\Release\net6.0" "appsettings.Linux.json" "appSettings" "RemoteWebDriverHub" "https://$($env:MAPPED_ENV_BROWSERSTACKUSER):$($env:MAPPED_ENV_BROWSERSTACKKEY)@hub-cloud.browserstack.com/wd/hub" -json + +.\scripts\set_AppConfig_for_tests.ps1 ".\Ocaramba.Tests.CloudProviderCrossBrowser\bin\Release\net6.0" "appsettings.Linux.json" "DriverCapabilities" "buildName" "Ocaramba.Tests.BrowserStackCrossBrowser$($env:BuildVersion)" -logValues -json + +dotnet vstest ./Ocaramba.Tests.CloudProviderCrossBrowser/bin/Release/net6.0/Ocaramba.Tests.CloudProviderCrossBrowser.dll /Logger:"trx;LogFileName=Ocaramba.Tests.BrowserStacknetcoreapp.xml" + +if($lastexitcode -ne 0) + { + echo 'lastexitcode' $lastexitcode + } +exit 0 diff --git a/ExecutingTestsOnWindowsGithubActions1.ps1 b/ExecutingTestsOnWindowsGithubActions1.ps1 new file mode 100644 index 000000000..757632b7d --- /dev/null +++ b/ExecutingTestsOnWindowsGithubActions1.ps1 @@ -0,0 +1,21 @@ +echo '********************************************Executing tests********************************************' + +echo '********************************************net6.0 tests********************************************' + +.\scripts\set_AppConfig_for_tests.ps1 "D:\a\Ocaramba\Ocaramba\Ocaramba\Ocaramba.Tests.NUnit\bin\Release\net6.0" "appsettings.json" "appSettings" "browser|PathToChromeDriverDirectory" "Chrome|C:\SeleniumWebDrivers\ChromeDriver" -logValues -json +.\scripts\set_AppConfig_for_tests.ps1 "D:\a\Ocaramba\Ocaramba\Ocaramba\Ocaramba.Tests.Angular\bin\Release\net6.0" "appsettings.json" "appSettings" "browser|PathToChromeDriverDirectory" "Chrome|C:\SeleniumWebDrivers\ChromeDriver" -logValues -json +.\scripts\set_AppConfig_for_tests.ps1 "D:\a\Ocaramba\Ocaramba\Ocaramba\Ocaramba.Tests.NUnitExtentReports\bin\Release\net6.0" "appsettings.json" "appSettings" "browser|PathToChromeDriverDirectory" "Chrome|C:\SeleniumWebDrivers\ChromeDriver" -logValues -json + +dotnet vstest D:\a\Ocaramba\Ocaramba\Ocaramba\Ocaramba.Tests.Angular\bin\Release\net6.0\Ocaramba.Tests.Angular.dll D:\a\Ocaramba\Ocaramba\Ocaramba\Ocaramba.Tests.NUnit\bin\Release\net6.0\Ocaramba.Tests.NUnit.dll /TestCaseFilter:"(TestCategory!=TakingScreehShots)" /Parallel /Logger:"trx;LogFileName=Ocaramba.Tests.netcoreapp.trx" + +echo '********************************************net472 tests********************************************' + +#.\scripts\set_AppConfig_for_tests.ps1 "D:\a\Ocaramba\Ocaramba\Ocaramba\Ocaramba.Tests.Features\bin\Release\net472" "Ocaramba.Tests.Features.dll.config" "appsettings.json" "browser|PathToChromeDriverDirectory" "Chrome|C:\SeleniumWebDrivers\ChromeDriver" -logValues + +#vstest.console.exe D:\a\Ocaramba\Ocaramba\Ocaramba\Ocaramba.Tests.Features\bin\Release\net472\Ocaramba.Tests.Features.dll /Logger:"trx;LogFileName=Ocaramba.Tests.Features.trx" +if($lastexitcode -ne 0) + { + echo 'lastexitcode' $lastexitcode + } + +exit 0 \ No newline at end of file diff --git a/ExecutingTestsOnWindowsGithubActions2.ps1 b/ExecutingTestsOnWindowsGithubActions2.ps1 new file mode 100644 index 000000000..47b1e1d0d --- /dev/null +++ b/ExecutingTestsOnWindowsGithubActions2.ps1 @@ -0,0 +1,25 @@ +echo '********************************************Executing tests********************************************' + +echo '********************************************net6.0 tests********************************************' + +.\scripts\set_AppConfig_for_tests.ps1 "D:\a\Ocaramba\Ocaramba\Ocaramba\Ocaramba.Tests.Features\bin\Release\net6.0" "appsettings.json" "appSettings" "browser|PathToChromeDriverDirectory" "Chrome|C:\SeleniumWebDrivers\ChromeDriver" -logValues -json +.\scripts\set_AppConfig_for_tests.ps1 "D:\a\Ocaramba\Ocaramba\Ocaramba\Ocaramba.Tests.Xunit\bin\Release\net6.0" "appsettings.json" "appSettings" "browser|PathToChromeDriverDirectory" "Chrome|C:\SeleniumWebDrivers\ChromeDriver" -logValues -json +.\scripts\set_AppConfig_for_tests.ps1 "D:\a\Ocaramba\Ocaramba\Ocaramba\Ocaramba.Tests.MsTest\bin\Release\net6.0" "appsettings.json" "appSettings" "browser|PathToChromeDriverDirectory" "Chrome|C:\SeleniumWebDrivers\ChromeDriver" -logValues -json +.\scripts\set_AppConfig_for_tests.ps1 "D:\a\Ocaramba\Ocaramba\Ocaramba\Ocaramba.UnitTests\bin\Release\net6.0" "appsettings.json" "appSettings" "browser|PathToChromeDriverDirectory" "Chrome|C:\SeleniumWebDrivers\ChromeDriver" -logValues -json + +dotnet vstest D:\a\Ocaramba\Ocaramba\Ocaramba\Ocaramba.Tests.Features\bin\Release\net6.0\Ocaramba.Tests.Features.dll D:\a\Ocaramba\Ocaramba\Ocaramba\Ocaramba.Tests.Xunit\bin\Release\net6.0\Ocaramba.Tests.Xunit.dll D:\a\Ocaramba\Ocaramba\Ocaramba\Ocaramba.Tests.MsTest\bin\Release\net6.0\Ocaramba.Tests.MsTest.dll D:\a\Ocaramba\Ocaramba\Ocaramba\Ocaramba.UnitTests\bin\Release\net6.0\Ocaramba.UnitTests.dll /TestCaseFilter:"(TestCategory!=TakingScreehShots)" /Parallel /Logger:"trx;LogFileName=Ocaramba.Tests.netcoreapp.xml" + + +echo '********************************************EdgeChrominum tests********************************************' + +.\scripts\set_AppConfig_for_tests.ps1 "D:\a\Ocaramba\Ocaramba\Ocaramba\Ocaramba.Tests.NUnit\bin\Release\net6.0" "appsettings.json" "appSettings" "browser|PathToEdgeChromiumDriverDirectory" "EdgeChromium|C:\SeleniumWebDrivers\EdgeDriver" -logValues -json + + +dotnet vstest D:\a\Ocaramba\Ocaramba\Ocaramba\Ocaramba.Tests.NUnit\bin\Release\net6.0\Ocaramba.Tests.NUnit.dll /TestCaseFilter:"(TestCategory=Grid)" /Parallel /Logger:"trx;LogFileName=Ocaramba.Tests.EdgeChrominum.xml" + +if($lastexitcode -ne 0) + { + echo 'lastexitcode' $lastexitcode + } + +exit 0 \ No newline at end of file diff --git a/ExecutingTestsOnWindowsGithubActions3.ps1 b/ExecutingTestsOnWindowsGithubActions3.ps1 new file mode 100644 index 000000000..24e1eb2c1 --- /dev/null +++ b/ExecutingTestsOnWindowsGithubActions3.ps1 @@ -0,0 +1,18 @@ +echo '********************************************Executing tests********************************************' + +echo '********************************************net472 tests*********************************************' + +.\scripts\set_AppConfig_for_tests.ps1 "D:\a\Ocaramba\Ocaramba\Ocaramba\Ocaramba.Tests.Angular\bin\Release\net472" "Ocaramba.Tests.Angular.dll.config" "//appSettings" "browser|PathToChromeDriverDirectory" "Chrome|C:\SeleniumWebDrivers\ChromeDriver" -logValues +.\scripts\set_AppConfig_for_tests.ps1 "D:\a\Ocaramba\Ocaramba\Ocaramba\Ocaramba.Tests.NUnit\bin\Release\net472" "Ocaramba.Tests.NUnit.dll.config" "//appSettings" "browser|PathToChromeDriverDirectory" "Chrome|C:\SeleniumWebDrivers\ChromeDriver" -logValues +.\scripts\set_AppConfig_for_tests.ps1 "D:\a\Ocaramba\Ocaramba\Ocaramba\Ocaramba.UnitTests\bin\Release\net472" "Ocaramba.UnitTests.dll.config" "//appSettings" "browser|PathToChromeDriverDirectory" "Chrome|C:\SeleniumWebDrivers\ChromeDriver" -logValues + + +dotnet vstest D:\a\Ocaramba\Ocaramba\Ocaramba\Ocaramba.Tests.Angular\bin\Release\net472\Ocaramba.Tests.Angular.dll D:\a\Ocaramba\Ocaramba\Ocaramba\Ocaramba.Tests.NUnit\bin\Release\net472\Ocaramba.Tests.NUnit.dll D:\a\Ocaramba\Ocaramba\Ocaramba\Ocaramba.UnitTests\bin\Release\net472\Ocaramba.UnitTests.dll /Parallel /Logger:"trx;LogFileName=Ocaramba.Tests.net4.xml" + + +if($lastexitcode -ne 0) + { + echo 'lastexitcode' $lastexitcode + } + +exit 0 diff --git a/ExecutingTestsOnWindowsGithubActions4.ps1 b/ExecutingTestsOnWindowsGithubActions4.ps1 new file mode 100644 index 000000000..da149ef78 --- /dev/null +++ b/ExecutingTestsOnWindowsGithubActions4.ps1 @@ -0,0 +1,16 @@ +echo '********************************************CloudProviderCrossBrowser tests********************************************' + +echo '********************************************BrowserStack tests********************************************' + +.\scripts\set_AppConfig_for_tests.ps1 ".\Ocaramba\Ocaramba.Tests.CloudProviderCrossBrowser\bin\Release\net472" "Ocaramba.Tests.CloudProviderCrossBrowser.dll.config" "//appSettings" "RemoteWebDriverHub" "https://$($env:MAPPED_ENV_BROWSERSTACKUSER):$($env:MAPPED_ENV_BROWSERSTACKKEY)@hub-cloud.browserstack.com/wd/hub" + +.\scripts\set_AppConfig_for_tests.ps1 ".\Ocaramba\Ocaramba.Tests.CloudProviderCrossBrowser\bin\Release\net472" "Ocaramba.Tests.CloudProviderCrossBrowser.dll.config" "//DriverCapabilities" "buildName" "Ocaramba.Tests.BrowserStackCrossBrowser$($env:BuildVersion)" -logValues + +dotnet vstest D:\a\Ocaramba\Ocaramba\Ocaramba\Ocaramba.Tests.CloudProviderCrossBrowser\bin\Release\net472\Ocaramba.Tests.CloudProviderCrossBrowser.dll /Logger:"trx;LogFileName=Ocaramba.Tests.BrowserStack.xml" + +if($lastexitcode -ne 0) + { + echo 'lastexitcode' $lastexitcode + } + +exit 0 diff --git a/ExecutingTestsOnWindowsGithubActions5.ps1 b/ExecutingTestsOnWindowsGithubActions5.ps1 new file mode 100644 index 000000000..3e7b54aa1 --- /dev/null +++ b/ExecutingTestsOnWindowsGithubActions5.ps1 @@ -0,0 +1,71 @@ +echo '********************************************Downloading Selenium Grid********************************************' + +$url = $env:seleniumGridUrl + +$grid = $env:seleniumGridVersion + +$output = $PSScriptRoot + ".\Ocaramba\Ocaramba.Tests.NUnit\bin\Release\net472\$grid" + +$outputLogs = $PSScriptRoot + ".\Ocaramba\Ocaramba.Tests.NUnit\bin\Release\net472\" + +$start_time = Get-Date + +echo url: $url +echo grid: $grid +echo output: $output +echo outputLogs: $outputLogs + +echo "Downloading Selenium Grid from: $($url) to $($output)" +Invoke-WebRequest -Uri "$($url)" -Out "$($output)" + +echo "Selenium Grid downloaded to:" $output + +echo "Time taken to download $($grid): $((Get-Date).Subtract($start_time).Seconds) second(s)" + +echo '******************************************Start Selenium Grid in background****************************************' + +$appHub=Start-Process java -ArgumentList '-jar', $output' hub' -RedirectStandardOutput $outputLogs'console_hub.out' -RedirectStandardError $outputLogs'console_hub.err' -passthru + +Start-Sleep -s 5 + +echo "Selenium Grid hub started" + +$appNode=Start-Process java -ArgumentList '-jar', $output' node --detect-drivers true' -RedirectStandardOutput $outputLogs'console_node.out' -RedirectStandardError $outputLogs'console_node.err' -passthru + +Start-Sleep -s 5 + +echo "Selenium Grid node started" + +echo '********************************************Run tests with Selenium Grid ****************************************' + +.\scripts\set_AppConfig_for_tests.ps1 ".\Ocaramba\Ocaramba.Tests.NUnit\bin\Release\net472\" "Ocaramba.Tests.NUnit.dll.config" "//appSettings" "browser|RemoteWebDriverHub" "RemoteWebDriver|http://localhost:4444/wd/hub" -logValues + +dotnet vstest .\Ocaramba\Ocaramba.Tests.NUnit\bin\Release\net472\Ocaramba.Tests.NUnit.dll /TestCaseFilter:"TestCategory=Grid" /Parallel /Logger:"trx;LogFileName=Ocaramba.Tests.NUnitGrid.xml" + +echo '*****************************Run CloudProviderCrossBrowser tests with Selenium Grid****************************' + +.\scripts\set_AppConfig_for_tests.ps1 ".\Ocaramba\Ocaramba.Tests.CloudProviderCrossBrowser\bin\Release\net472" "Ocaramba.Tests.CloudProviderCrossBrowser.dll.config" "//appSettings" "RemoteWebDriverHub" "http://localhost:4444/wd/hub" -logValues + +dotnet vstest .\Ocaramba\Ocaramba.Tests.CloudProviderCrossBrowser\bin\Release\net472\Ocaramba.Tests.CloudProviderCrossBrowser.dll /TestCaseFilter:"FullyQualifiedName~Chrome" /Parallel /Logger:"trx;LogFileName=Ocaramba.Tests.CloudProviderCrossBrowserGrid.xml" + +if($lastexitcode -ne 0) + { + echo 'lastexitcode' $lastexitcode + } + +echo '*****************************Stop Selenium Grid****************************' + +echo "Stop Selenium Grid node" + +Stop-Process -Id $appNode.Id + +echo "Stop Selenium Grid hub" + +Stop-Process -Id $appHub.Id + +if($lastexitcode -ne 0) + { + echo 'lastexitcode' $lastexitcode + } + +exit 0 diff --git a/ExecutingTestsOnWindowsGithubActions6.ps1 b/ExecutingTestsOnWindowsGithubActions6.ps1 new file mode 100644 index 000000000..c726c37a0 --- /dev/null +++ b/ExecutingTestsOnWindowsGithubActions6.ps1 @@ -0,0 +1,16 @@ +echo '********************************************CloudProviderCrossBrowser tests********************************************' + +echo '********************************************saucelabs tests********************************************' + +.\scripts\set_AppConfig_for_tests.ps1 ".\Ocaramba\Ocaramba.Tests.CloudProviderCrossBrowser\bin\Release\net472" "Ocaramba.Tests.CloudProviderCrossBrowser.dll.config" "//appSettings" "RemoteWebDriverHub" "https://$($env:MAPPED_ENV_SAUCELABSUSERNAME):$($env:MAPPED_ENV_SAUCELABSACCESSKEY)@ondemand.us-west-1.saucelabs.com:443/wd/hub" + +.\scripts\set_AppConfig_for_tests.ps1 ".\Ocaramba\Ocaramba.Tests.CloudProviderCrossBrowser\bin\Release\net472" "Ocaramba.Tests.CloudProviderCrossBrowser.dll.config" "//DriverCapabilities" "buildName" "Ocaramba.Tests.SauceLabsCrossBrowser$($env:BuildVersion)" -logValues + +dotnet vstest .\Ocaramba\Ocaramba.Tests.CloudProviderCrossBrowser\bin\Release\net472\Ocaramba.Tests.CloudProviderCrossBrowser.dll /TestCaseFilter:"(FullyQualifiedName!~Iphone)&(FullyQualifiedName!~Android)&(FullyQualifiedName!~Samsung)" /Logger:"trx;LogFileName=Ocaramba.Tests.saucelabsnet472.xml" + +if($lastexitcode -ne 0) + { + echo 'lastexitcode' $lastexitcode + } + +exit 0 diff --git a/README.md b/README.md index fa41f75bd..640aa833f 100644 --- a/README.md +++ b/README.md @@ -5,49 +5,48 @@ [![Ocaramba Templates](https://img.shields.io/badge/get-Ocaramba_Templates-green.svg?color=4BC21F)](https://marketplace.visualstudio.com/items?itemName=Ocaramba.Ocaramba1) [![Build status](https://ci.appveyor.com/api/projects/status/p8p3bndotyknv7rk?svg=true)](https://ci.appveyor.com/project/ObjectivityAdminsTeam/ocaramba) -[![Build Status](https://dev.azure.com/ocaramba/Ocaramba/_apis/build/status/ObjectivityLtd.Ocaramba)](https://dev.azure.com/ocaramba/Ocaramba/_build/latest?definitionId=2) -[![Azure DevOps tests](https://img.shields.io/azure-devops/tests/ocaramba/Ocaramba/2)](https://dev.azure.com/ocaramba/Ocaramba/_build?definitionId=2) +[![Build status](https://github.com/Accenture/Ocaramba/actions/workflows/github-actions.yml/badge.svg) [![BrowserStack Status](https://automate.browserstack.com/badge.svg?badge_key=LzcxRG9pYjdqMWF0SG5OTzVYcHJmdkVDVzdzVEZvSnUwNHB6MDJjRkFtZz0tLVQ5NHNtQkllOFQzOXl6T3BiOHFzZFE9PQ==--be558d9ee42bf47757e26a14b2848c8eccecf751)](https://automate.browserstack.com/public-build/LzcxRG9pYjdqMWF0SG5OTzVYcHJmdkVDVzdzVEZvSnUwNHB6MDJjRkFtZz0tLVQ5NHNtQkllOFQzOXl6T3BiOHFzZFE9PQ==--be558d9ee42bf47757e26a14b2848c8eccecf751) [![Build Status](https://saucelabs.com/buildstatus/jraczek)](https://saucelabs.com/beta/builds/8de234710c7c46f1b5d0e9c9438e5d06) Test Framework was designed in Objectivity to propose a common way how people should create Selenium WebDriver tests. -Project API documentation can be found here: http://objectivityltd.github.io/Ocaramba

+Project API documentation can be found here: http://Accenture.github.io/Ocaramba

- + **It provides the following features:** - .NET Frameworks 4.7.2 and .NET 6.0 supported - Cross-Platform Windows, Linux and macOS systems supported - Supports continuous integration tools like Azure DevOps, Teamcity, Jenkins and others. -- Ready for parallel tests execution, more details [here](https://github.com/ObjectivityLtd/Ocaramba/wiki/Selenium%20Parallel%20tests%20execution) +- Ready for parallel tests execution, more details [here](https://github.com/Accenture/Ocaramba/wiki/Selenium%20Parallel%20tests%20execution) - Possibility to use MSTest, NUnit or xUNIT framework - Specflow ready - Written entirely in C# - Contains example projects how to use it - Allows using Chrome, Firefox, Edge Chromium, Safari or Internet Explorer -- Overrides browser profile preferences, pass arguments to browsers, installs browser extensions, loading default firefox profile, Headless mode, more details [here](https://github.com/ObjectivityLtd/Ocaramba/wiki/Override-browser-profile-preferences,-install-browser-extensions,-Headless-mode) -- Extends Webdriver by additional methods like JavaScriptClick, WaitForAjax, WaitForAngular, etc., more details [here](http://objectivityltd.github.io/Ocaramba/html/d51aa97e-08b5-c0b6-6987-c10545a64ebd.htm) -- Automatically waits when locating element for specified time and conditions, GetElement method instead of Selenium FindElement, more details [here](http://objectivityltd.github.io/Ocaramba/html/3c09ca99-f931-c6c9-98fc-194eff6500ff.htm) +- Overrides browser profile preferences, pass arguments to browsers, installs browser extensions, loading default firefox profile, Headless mode, more details [here](https://github.com/Accenture/Ocaramba/wiki/Override-browser-profile-preferences,-install-browser-extensions,-Headless-mode) +- Extends Webdriver by additional methods like JavaScriptClick, WaitForAjax, WaitForAngular, etc., more details [here](http://Accenture.github.io/Ocaramba/html/d51aa97e-08b5-c0b6-6987-c10545a64ebd.htm) +- Automatically waits when locating element for specified time and conditions, GetElement method instead of Selenium FindElement, more details [here](http://Accenture.github.io/Ocaramba/html/3c09ca99-f931-c6c9-98fc-194eff6500ff.htm) - Page Object Pattern -- Support for [SeleniumGrid](https://github.com/SeleniumHQ/selenium/wiki/Grid2), [Cross browser parallel test execution](https://github.com/ObjectivityLtd/Ocaramba/wiki/Cross-browser-parallel-test-execution-with-SeleniumGrid-or-testing-Cloud-Providers) with [SauceLab](https://saucelabs.com/), [TestingBot](https://testingbot.com) and [Browserstack](https://www.browserstack.com/) more details [here](https://github.com/ObjectivityLtd/Ocaramba/wiki/Selenium-Grid-support), Advanced Browser Capabilities and Options more details [here](https://github.com/ObjectivityLtd/Ocaramba/wiki/Advanced-Browser-Capabilities-and-options) -- More common locators, e.g: ```"//*[@title='{0}' and @ms.title='{1}']"```, more details [here](https://github.com/ObjectivityLtd/Ocaramba/wiki/More%20common%20locators) -- Verify - asserts without stop tests, more details [here](https://github.com/ObjectivityLtd/Ocaramba/wiki/Verify-asserts-without-stop-tests) -- Measures average and 90 Percentile action times, more details [here](https://github.com/ObjectivityLtd/Ocaramba/wiki/Performance%20measures) -- DataDriven tests from Xml, Csv and Excel files for NUnit and Xml, Csv for MSTest with examples, more details [NUnit](https://github.com/ObjectivityLtd/Ocaramba/wiki/NUnit-DataDriven-tests-from-Xml,-CSV-and-Excel-files), [MsTest](https://github.com/ObjectivityLtd/Ocaramba/wiki/MsTest-DataDriven-tests-from-Xml-and-CSV-files) -- Possibility to take full desktop (only .NET Framework), save page source, more details [here](https://github.com/ObjectivityLtd/Ocaramba/wiki/Screen-shots---full-desktop---selenium---PageSource-saving) -- Visual Testing - browser screenshot of the element, more details [here](https://github.com/ObjectivityLtd/Ocaramba/wiki/Visual-Testing) -- Logging with NLog, EventFiringWebDriver logs, more details [here](https://github.com/ObjectivityLtd/Ocaramba/wiki/Logging) -- Files downloading (Firefox, Chrome), more details [here](https://github.com/ObjectivityLtd/Ocaramba/wiki/Downloading%20files) -- Possibility to send [SQL](http://objectivityltd.github.io/Ocaramba/html/730c92c7-831a-4449-3938-16540cf259b8.htm) or [MDX](http://objectivityltd.github.io/Ocaramba/html/7de319df-06eb-1c79-8c2d-9c60aaf3ab85.htm) queries (only .NET Framework) -- Possibility of debugging framework installed from nuget package with [sourcelink](https://github.com/dotnet/sourcelink), more details [here](https://github.com/ObjectivityLtd/Ocaramba/wiki/Debugging-Test.Automation-framework). -- AngularJS support, more details [here](https://github.com/ObjectivityLtd/Ocaramba/wiki/Angular-support). -- Possibility to check for JavaScript errors from the browser, more details [here](https://github.com/ObjectivityLtd/Ocaramba/wiki/Verifying-Javascript-Errors-from-browser). -- Instruction on how to run Ocaramba tests with Docker container, more details [here](https://github.com/ObjectivityLtd/Ocaramba/wiki/Run-Ocaramba-tests-with-Docker-container). -- ExtentReports support, more details [here](https://github.com/ObjectivityLtd/Ocaramba/wiki/ExtentReports-Support). - -For all documentation, visit the [Ocaramba Wiki](https://github.com/ObjectivityLtd/Ocaramba/wiki). +- Support for [SeleniumGrid](https://github.com/SeleniumHQ/selenium/wiki/Grid2), [Cross browser parallel test execution](https://github.com/Accenture/Ocaramba/wiki/Cross-browser-parallel-test-execution-with-SeleniumGrid-or-testing-Cloud-Providers) with [SauceLab](https://saucelabs.com/), [TestingBot](https://testingbot.com) and [Browserstack](https://www.browserstack.com/) more details [here](https://github.com/Accenture/Ocaramba/wiki/Selenium-Grid-support), Advanced Browser Capabilities and Options more details [here](https://github.com/Accenture/Ocaramba/wiki/Advanced-Browser-Capabilities-and-options) +- More common locators, e.g: ```"//*[@title='{0}' and @ms.title='{1}']"```, more details [here](https://github.com/Accenture/Ocaramba/wiki/More%20common%20locators) +- Verify - asserts without stop tests, more details [here](https://github.com/Accenture/Ocaramba/wiki/Verify-asserts-without-stop-tests) +- Measures average and 90 Percentile action times, more details [here](https://github.com/Accenture/Ocaramba/wiki/Performance%20measures) +- DataDriven tests from Xml, Csv and Excel files for NUnit and Xml, Csv for MSTest with examples, more details [NUnit](https://github.com/Accenture/Ocaramba/wiki/NUnit-DataDriven-tests-from-Xml,-CSV-and-Excel-files), [MsTest](https://github.com/Accenture/Ocaramba/wiki/MsTest-DataDriven-tests-from-Xml-and-CSV-files) +- Possibility to take full desktop (only .NET Framework), save page source, more details [here](https://github.com/Accenture/Ocaramba/wiki/Screen-shots---full-desktop---selenium---PageSource-saving) +- Visual Testing - browser screenshot of the element, more details [here](https://github.com/Accenture/Ocaramba/wiki/Visual-Testing) +- Logging with NLog, EventFiringWebDriver logs, more details [here](https://github.com/Accenture/Ocaramba/wiki/Logging) +- Files downloading (Firefox, Chrome), more details [here](https://github.com/Accenture/Ocaramba/wiki/Downloading%20files) +- Possibility to send [SQL](http://Accenture.github.io/Ocaramba/html/730c92c7-831a-4449-3938-16540cf259b8.htm) or [MDX](http://Accenture.github.io/Ocaramba/html/7de319df-06eb-1c79-8c2d-9c60aaf3ab85.htm) queries (only .NET Framework) +- Possibility of debugging framework installed from nuget package with [sourcelink](https://github.com/dotnet/sourcelink), more details [here](https://github.com/Accenture/Ocaramba/wiki/Debugging-Test.Automation-framework). +- AngularJS support, more details [here](https://github.com/Accenture/Ocaramba/wiki/Angular-support). +- Possibility to check for JavaScript errors from the browser, more details [here](https://github.com/Accenture/Ocaramba/wiki/Verifying-Javascript-Errors-from-browser). +- Instruction on how to run Ocaramba tests with Docker container, more details [here](https://github.com/Accenture/Ocaramba/wiki/Run-Ocaramba-tests-with-Docker-container). +- ExtentReports support, more details [here](https://github.com/Accenture/Ocaramba/wiki/ExtentReports-Support). + +For all documentation, visit the [Ocaramba Wiki](https://github.com/Accenture/Ocaramba/wiki). Projects examples of using Test Framework : - Ocaramba.Tests.Angular for AngularJS @@ -127,7 +126,7 @@ namespace Ocaramba.Tests.PageObjects.PageObjects.TheInternet #### Where to start? ------------- -- See [Getting started](https://github.com/ObjectivityLtd/Ocaramba/wiki/Getting%20started). +- See [Getting started](https://github.com/Accenture/Ocaramba/wiki/Getting%20started). Checkout the code or get it from [nuget.org](https://www.nuget.org/packages?q=Ocaramba) - Ocaramba [![NuGet Badge](https://buildstats.info/nuget/Ocaramba)](https://www.nuget.org/packages/Ocaramba/)