Skip to content

Commit

Permalink
simulate both resetting session and quitting the driver in selenium u…
Browse files Browse the repository at this point in the history
…nit tests
  • Loading branch information
anmarchenko committed May 28, 2024
1 parent 691bf86 commit 639eae2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,7 @@
Then "visit page" do
visit "http://www.example.com"

Capybara.reset_session!

Capybara.current_session.quit
end
8 changes: 6 additions & 2 deletions spec/datadog/ci/contrib/selenium/instrumentation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,13 @@
end

it "recognize the test as browser test and adds additional tags" do
expect(visited_urls).to eq(["http://www.example.com"])
expect(visited_urls).to eq(["http://www.example.com", "about:blank"])
expect(executed_scripts).to eq(
[
Datadog::CI::Contrib::Selenium::Ext::SCRIPT_IS_RUM_ACTIVE,
Datadog::CI::Contrib::Selenium::Ext::SCRIPT_STOP_RUM_SESSION,
"window.sessionStorage.clear()",
"window.localStorage.clear()",
Datadog::CI::Contrib::Selenium::Ext::SCRIPT_IS_RUM_ACTIVE,
Datadog::CI::Contrib::Selenium::Ext::SCRIPT_STOP_RUM_SESSION
]
Expand All @@ -88,7 +92,7 @@
expect(manager).to have_received(:add_cookie).with(
{name: "datadog-ci-visibility-test-execution-id", value: first_test_span.trace_id.to_s}
)
expect(manager).to have_received(:delete_cookie).with("datadog-ci-visibility-test-execution-id")
expect(manager).to have_received(:delete_cookie).with("datadog-ci-visibility-test-execution-id").twice

expect(first_test_span).to have_test_tag(:type, "browser")
expect(first_test_span).to have_test_tag(:browser_driver, "selenium")
Expand Down

0 comments on commit 639eae2

Please sign in to comment.