-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SDTEST-158] Browser tests support via selenium integration #183
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #183 +/- ##
==========================================
- Coverage 98.95% 98.87% -0.09%
==========================================
Files 209 220 +11
Lines 9758 10011 +253
Branches 452 465 +13
==========================================
+ Hits 9656 9898 +242
- Misses 102 113 +11 ☔ View full report in Codecov by Sentry. |
…t; add finishing touches for the integration
def self.is_rum_active?(script_executor) | ||
is_rum_active_script_result = script_executor.execute_script(Ext::SCRIPT_IS_RUM_ACTIVE) | ||
Datadog.logger.debug { "[Selenium] SCRIPT_IS_RUM_ACTIVE result is #{is_rum_active_script_result.inspect}" } | ||
is_rum_active_script_result == "true" || is_rum_active_script_result == true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should the script_executor
be ensuring its result's a bool, rather than checking for both here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
script_executor is coming from selenium-webdriver, it could be Selenium::WebDriver::Manager
or Selenium::WebDriver::Driver
One could say that we need to be exactly sure what type this returns but in Ruby case one can never be sure. Another more beatiful way to write it would be is_rum_active_script_result.to_s == "true"
, I think this would look better
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hehe, I would be more likely to try to cast the string to a bool :) but anyway, it's not very important, I think the code's fine as is.
What does this PR do?
Automatically recognises tests that use selenium and marks them as browser tests. Integrates with Datadog RUM to automatically show browser sessions in the test run view (see screenshots below).
Additional Notes
selenium-webdriver
gem because capybara has its own logic to reset browser session between test runs. In this PR bothSelenium::WebDriver::Driver
andCapybara::Selenium::Driver
(not that capybara is de-facto the default testing library for e2e tests in Ruby)How to test the change?
Unit tests are provided.
Tested on DD staging using the following test:
With the following results
Browser tags and is_rum_active tag:
Browser session replay connected to a test: