Skip to content

Conversation

@mialeska
Copy link
Contributor

No description provided.

@mialeska mialeska self-assigned this Aug 26, 2025
@mialeska mialeska added enhancement New feature or request dotnet labels Aug 26, 2025
@github-project-automation github-project-automation bot moved this to In progress in Aquality Selenium Aug 26, 2025
@coderabbitai
Copy link

coderabbitai bot commented Aug 26, 2025

Walkthrough

Removes the obsolete GetDevToolsSession(int) overload, introduces/uses GetDevToolsSession(DevToolsOptions), updates XML docs accordingly, bumps Aquality.Selenium.Core to 3.5.0, updates NUnit dependencies, adds retry categorization and constants for flaky tests, and adjusts DevTools Emulation test code to newer protocol versions.

Changes

Cohort / File(s) Summary of changes
Core dependency bump
Aquality.Selenium/src/Aquality.Selenium/Aquality.Selenium.csproj
Update PackageReference: Aquality.Selenium.Core 3.4.0 → 3.5.0.
DevTools API update
Aquality.Selenium/src/Aquality.Selenium/Browsers/DevToolsHandling.cs, Aquality.Selenium/src/Aquality.Selenium/Aquality.Selenium.xml
Remove GetDevToolsSession(int); retain default and add/update GetDevToolsSession(DevToolsOptions); update XML docs to reflect options-based API and default version behavior.
Test framework versions
Aquality.Selenium/tests/Aquality.Selenium.Tests/Aquality.Selenium.Tests.csproj
Bump nunit 4.3.2 → 4.4.0; NUnit3TestAdapter 5.0.0 → 5.1.0.
Retryable flaky tests
Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/BrowserTabsTests.cs, .../BrowserTests.cs, .../Elements/MultiChoiceBoxTests.cs, .../HiddenElementsTests.cs, .../ImageLocatorTests.cs
Add [Category(RetriesGroup), Retry(RetriesCount)] to designated [Test] methods; no test body changes.
DevTools emulation tests update
Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/DevToolsEmulationTests.cs
Update DevTools Emulation namespaces/usages to newer versions (e.g., V138/V139); add retry attributes to several tests.
Retry config constants
Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/UITest.cs
Add protected constants: RetriesCount = 5, RetriesGroup = "Flaky".

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor Test as Test/Client
  participant DH as DevToolsHandling
  participant DTP as DevToolsProvider
  participant DTS as DevToolsSession

  rect rgb(235,245,255)
  note over Test,DH: Default session retrieval (no options)
  Test->>DH: GetDevToolsSession()
  DH->>DTP: GetDevToolsSession() // provider default/autodetect
  DTP-->>DH: DevToolsSession
  DH-->>Test: DevToolsSession
  end

  rect rgb(240,255,240)
  note over Test,DH: Options-based session retrieval
  Test->>DH: GetDevToolsSession(DevToolsOptions options)
  DH->>DTP: GetDevToolsSession(options)
  DTP-->>DH: DevToolsSession
  DH-->>Test: DevToolsSession
  end

  note over Test,DH: Obsolete int overload removed
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested labels

feature

Suggested reviewers

  • DmitryBogatko

Poem

A hop, a skip, a version hopped anew,
Old int burrow closed; options tunnel through.
Flakes get retries—five lucky chews,
Tests nibble steady on DevTools views.
Core’s at 3.5, ears up, let’s go—
Thump-thump CI, green meadows glow! 🐇🌿

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch update-to-selenium-4.35.0

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@sonarqubecloud
Copy link

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (7)
Aquality.Selenium/src/Aquality.Selenium/Aquality.Selenium.csproj (1)

94-94: Aquality.Selenium.Core 3.5.0 bump: confirm Selenium.WebDriver 4.35.0 alignment

The Core bump makes sense for the DevTools API changes. Please verify that Aquality.Selenium.Core 3.5.0 pins or ranges to Selenium.WebDriver 4.35.0 (or newer) so this library can’t accidentally resolve an older WebDriver via transitive deps. If Core doesn’t enforce that, consider explicitly pinning here.

If needed, add an explicit reference:

   <ItemGroup>
-    <PackageReference Include="Aquality.Selenium.Core" Version="3.5.0" />
+    <PackageReference Include="Aquality.Selenium.Core" Version="3.5.0" />
+    <!-- Ensure WebDriver 4.35.0 is used if not enforced by Core -->
+    <PackageReference Include="Selenium.WebDriver" Version="4.35.0" />
     <PackageReference Include="WebDriverManager" Version="2.17.6" />
   </ItemGroup>
Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/UITest.cs (1)

11-12: Centralized retry config: good; consider broader accessibility

Defining RetriesCount/Group once is clean. If you ever need to use these constants from fixtures that don’t inherit UITest, switch to protected internal (or internal) and reference statically from a shared static class.

-        protected const int RetriesCount = 5;
-        protected const string RetriesGroup = "Flaky";
+        protected internal const int RetriesCount = 5;
+        protected internal const string RetriesGroup = "Flaky";
Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/BrowserTabsTests.cs (1)

145-153: Retry added; reduce flakiness at the source with deterministic waits in helper

Adding Retry is fine, but the flake likely comes from timing around tab creation. Strengthen CheckSwitchingBy to wait for the new handle(s) rather than relying on immediate availability, and you can likely drop the Retry.

Apply this refactor to the helper (outside the changed hunk) to wait for handles both after opening the external link and after the switchMethod runs:

-        private void CheckSwitchingBy(int expectedTabCount, Action switchMethod)
-        {
-            var tabHandle = Tabs.CurrentHandle;
-            Assert.That(tabHandle, Is.Not.Empty);
-            WelcomeForm.ClickElementalSelenium();
-            var newTabHandle = Tabs.Handles.Last();
-            switchMethod.Invoke();
-            Assert.That(Tabs.CurrentHandle, Is.EqualTo(newTabHandle), "Browser should be switched to correct tab");
-            Assert.That(Tabs.Handles.Count, Is.EqualTo(expectedTabCount), "Number of tabs should be correct");
-        }
+        private void CheckSwitchingBy(int expectedTabCount, Action switchMethod)
+        {
+            var originalHandle = Tabs.CurrentHandle;
+            Assert.That(originalHandle, Is.Not.Empty);
+
+            var initialCount = Tabs.Handles.Count;
+            WelcomeForm.ClickElementalSelenium();
+
+            // Wait until the link actually opens a new tab
+            Assert.That(() => Tabs.Handles.Count, Is.EqualTo(initialCount + 1).After(5000).PollEvery(100));
+            var newTabHandle = Tabs.Handles.Last();
+
+            switchMethod.Invoke();
+
+            // If switchMethod opens/closes tabs, wait for the final expected count
+            Assert.That(() => Tabs.Handles.Count, Is.EqualTo(expectedTabCount).After(5000).PollEvery(100));
+            Assert.That(Tabs.CurrentHandle, Is.EqualTo(newTabHandle), "Browser should be switched to correct tab");
+        }

If this stabilizes the test, consider removing Retry on this method to keep signal-to-noise high in CI.

Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/Elements/MultiChoiceBoxTests.cs (1)

37-37: Retry categorized as Flaky: consider applying at class level (if most tests here are flaky)

If multiple tests in this fixture exhibit the same instability pattern, you can reduce duplication and make intent clearer by decorating the class with [Category(RetriesGroup)] and keep per-test Retry only where needed. Otherwise, current selective use on this single test is fine.

-    internal class MultiChoiceBoxTests : UITest
+    [Category(RetriesGroup)]
+    internal class MultiChoiceBoxTests : UITest
Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/HiddenElementsTests.cs (1)

52-71: Retries added for flaky hidden-elements check — consider lightweight logging before refresh to aid triage

The retry metadata aligns with the PR pattern. Since the test already has an inline recovery (Refresh + second wait), a small log entry when the first wait fails would help diagnose sporadic failures without changing behavior.

Apply this diff to add a debug line before the refresh:

                 {
-                    var result = element.State.WaitForNotDisplayed();
+                    var result = element.State.WaitForNotDisplayed();
                     if (!result)
                     {
+                        TestContext.WriteLine($"Element still displayed after initial wait. Refreshing and retrying... Element: {element}");
                         AqualityServices.Browser.Refresh();
                         result = element.State.WaitForNotDisplayed();
                     }
                     return result;
                 }));
Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/BrowserTests.cs (1)

229-253: Use TotalSeconds in message; optionally reset implicit wait to avoid side-effects

  • The failure message uses elapsedTime.Seconds, which prints only the seconds component, not the full duration. Prefer TotalSeconds.
  • Consider restoring the implicit wait to a baseline in a finally block so subsequent tests aren’t influenced.

Apply these diffs:

  1. Improve the assertion message:
-                Assert.That(elapsedTime, Is.LessThan(waitTime.Add(TimeSpan.FromSeconds(2))), 
-                    $"Elapsed time should be less than implicit timeout + 2 sec(accuracy). Elapsed time: {elapsedTime.Seconds}");
+                Assert.That(elapsedTime, Is.LessThan(waitTime.Add(TimeSpan.FromSeconds(2))), 
+                    $"Elapsed time should be less than implicit timeout + 2 sec (accuracy). Elapsed time: {elapsedTime.TotalSeconds:F2}s");
  1. Reset implicit wait after the check:
             try
             {
                 browser.Driver.FindElement(By.Id("not_exist_element"));
             } 
             catch (NoSuchElementException)
             {
                 elapsedTime = stopwatch.Elapsed;
             }
+            finally
+            {
+                // Reset to baseline to avoid leaking this setting into other tests
+                browser.SetImplicitWaitTimeout(TimeSpan.Zero);
+            }
Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/DevToolsEmulationTests.cs (1)

62-67: Reduce verbosity when mixing V139 default with V138-specific params

You intentionally pass V138-specific settings to validate cross-version handling. To keep it readable, add a namespace alias and use it here.

Apply these diffs:

  1. Add an alias near the existing using directives:
+using V138Emulation = OpenQA.Selenium.DevTools.V138.Emulation;
  1. Use the alias in the parameter construction:
-                var parameters = new OpenQA.Selenium.DevTools.V138.Emulation.SetDeviceMetricsOverrideCommandSettings
+                var parameters = new V138Emulation.SetDeviceMetricsOverrideCommandSettings
                 {
-                    DisplayFeature = new OpenQA.Selenium.DevTools.V138.Emulation.DisplayFeature
+                    DisplayFeature = new V138Emulation.DisplayFeature
                     {
-                        Orientation = OpenQA.Selenium.DevTools.V138.Emulation.DisplayFeatureOrientationValues.Horizontal
+                        Orientation = V138Emulation.DisplayFeatureOrientationValues.Horizontal
                     },
                     Width = width,
                     Height = height,
                     Mobile = isMobile,
                     DeviceScaleFactor = scaleFactor
                 };
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 84e2ae6 and 0fddb41.

📒 Files selected for processing (11)
  • Aquality.Selenium/src/Aquality.Selenium/Aquality.Selenium.csproj (1 hunks)
  • Aquality.Selenium/src/Aquality.Selenium/Aquality.Selenium.xml (0 hunks)
  • Aquality.Selenium/src/Aquality.Selenium/Browsers/DevToolsHandling.cs (0 hunks)
  • Aquality.Selenium/tests/Aquality.Selenium.Tests/Aquality.Selenium.Tests.csproj (1 hunks)
  • Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/BrowserTabsTests.cs (1 hunks)
  • Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/BrowserTests.cs (2 hunks)
  • Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/DevToolsEmulationTests.cs (5 hunks)
  • Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/Elements/MultiChoiceBoxTests.cs (1 hunks)
  • Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/HiddenElementsTests.cs (1 hunks)
  • Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/ImageLocatorTests.cs (1 hunks)
  • Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/UITest.cs (1 hunks)
💤 Files with no reviewable changes (2)
  • Aquality.Selenium/src/Aquality.Selenium/Browsers/DevToolsHandling.cs
  • Aquality.Selenium/src/Aquality.Selenium/Aquality.Selenium.xml
🧰 Additional context used
🧠 Learnings (3)
📓 Common learnings
Learnt from: mialeska
PR: aquality-automation/aquality-selenium-dotnet#270
File: Aquality.Selenium/src/Aquality.Selenium/Browsers/DevToolsEmulationExtensions.cs:3-4
Timestamp: 2025-05-28T19:52:19.309Z
Learning: DevTools V137 namespaces (OpenQA.Selenium.DevTools.V137.DOM and OpenQA.Selenium.DevTools.V137.Emulation) are available and working in Selenium WebDriver 4.33.0 for .NET projects.
📚 Learning: 2024-10-09T11:11:38.254Z
Learnt from: mialeska
PR: aquality-automation/aquality-selenium-dotnet#264
File: Aquality.Selenium/src/Aquality.Selenium.Images/Aquality.Selenium.Images.csproj:41-48
Timestamp: 2024-10-09T11:11:38.254Z
Learning: In `Aquality.Selenium.Images.csproj`, different versions of `OpenCvSharp4` package references are acceptable because the packages are compatible.

Applied to files:

  • Aquality.Selenium/tests/Aquality.Selenium.Tests/Aquality.Selenium.Tests.csproj
  • Aquality.Selenium/src/Aquality.Selenium/Aquality.Selenium.csproj
📚 Learning: 2025-05-28T19:52:19.309Z
Learnt from: mialeska
PR: aquality-automation/aquality-selenium-dotnet#270
File: Aquality.Selenium/src/Aquality.Selenium/Browsers/DevToolsEmulationExtensions.cs:3-4
Timestamp: 2025-05-28T19:52:19.309Z
Learning: DevTools V137 namespaces (OpenQA.Selenium.DevTools.V137.DOM and OpenQA.Selenium.DevTools.V137.Emulation) are available and working in Selenium WebDriver 4.33.0 for .NET projects.

Applied to files:

  • Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/DevToolsEmulationTests.cs
🧬 Code graph analysis (5)
Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/Elements/MultiChoiceBoxTests.cs (1)
Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/BrowserTabsTests.cs (15)
  • Test (21-29)
  • Test (31-39)
  • Test (41-49)
  • Test (51-56)
  • Test (58-64)
  • Test (66-79)
  • Test (81-94)
  • Test (96-103)
  • Test (105-112)
  • Test (114-121)
  • Test (123-132)
  • Test (134-143)
  • Test (145-153)
  • Test (155-163)
  • Test (165-169)
Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/ImageLocatorTests.cs (1)
Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/DevToolsEmulationTests.cs (11)
  • Test (30-40)
  • Test (42-48)
  • Test (50-55)
  • Test (57-78)
  • Test (96-103)
  • Test (105-120)
  • Test (147-159)
  • Test (161-176)
  • Test (178-189)
  • Test (191-205)
  • Test (207-214)
Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/BrowserTabsTests.cs (1)
Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/DevToolsEmulationTests.cs (11)
  • Test (30-40)
  • Test (42-48)
  • Test (50-55)
  • Test (57-78)
  • Test (96-103)
  • Test (105-120)
  • Test (147-159)
  • Test (161-176)
  • Test (178-189)
  • Test (191-205)
  • Test (207-214)
Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/HiddenElementsTests.cs (1)
Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/BrowserTests.cs (16)
  • Test (16-23)
  • Test (25-32)
  • Test (34-52)
  • Test (54-62)
  • Test (64-77)
  • Test (79-85)
  • Test (87-92)
  • Test (94-101)
  • Test (103-122)
  • Test (124-130)
  • Test (137-144)
  • Test (146-154)
  • Test (156-185)
  • Test (187-201)
  • Test (203-217)
  • Test (219-227)
Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/DevToolsEmulationTests.cs (2)
Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/BrowserTabsTests.cs (13)
  • Test (21-29)
  • Test (31-39)
  • Test (41-49)
  • Test (51-56)
  • Test (58-64)
  • Test (66-79)
  • Test (81-94)
  • Test (96-103)
  • Test (105-112)
  • Test (114-121)
  • Test (123-132)
  • Test (134-143)
  • Test (145-153)
Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/ImageLocatorTests.cs (1)
  • Test (14-41)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: aquality-automation.aquality-selenium-dotnet (test Run tests)
  • GitHub Check: aquality-automation.aquality-selenium-dotnet (test Analyze code with SonarQube)
🔇 Additional comments (7)
Aquality.Selenium/tests/Aquality.Selenium.Tests/Aquality.Selenium.Tests.csproj (1)

32-33: NUnit 4.4.0 + Adapter 5.1.0 – Manual Verification Needed

Before merging, please manually confirm that:

  • RetryAttribute is still exposed in nunit.framework in NUnit 4.4.0.
  • NUnit3TestAdapter 5.1.0 can discover and run NUnit 4.4.0 tests targeting .NET 8 under Microsoft.NET.Test.Sdk 17.14.1 without any discovery or execution errors.
  • There are no breaking changes in NUnit 4.4.0 that affect CategoryAttribute or delayed constraints (e.g. Assert.That(...).After(...)).

If you encounter any issues:

  • Bump the Test SDK or NUnit3TestAdapter version as needed.
  • Adjust or remove any unsupported attributes or APIs.

To understand the full impact, scan for Retry usage across the suite:

#!/bin/bash
# List all tests using Retry across the solution
rg -nP '\[(Test|TestCase)[^\]]*Retry\(' -g 'Aquality.Selenium/tests/**' -C1

—otherwise, we risk intermittent failures slipping through CI.

Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/ImageLocatorTests.cs (1)

14-41: Add Retry/Category to image-based test — good stability improvement

Marking this image-recognition test as Flaky with retries matches the typical instability of visual assertions across environments. No logic concerns found.

Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/BrowserTests.cs (1)

103-122: Async JS timing test: Retry/Category addition looks good

The retry metadata is appropriate for timing-sensitive assertions. The current tolerances (±1s op slack) are reasonable.

Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/DevToolsEmulationTests.cs (4)

96-103: GeoLocation override test — Retry/Category addition is appropriate

Good call to mark as Flaky and add retries for a test that depends on browser + site permissions timing.


147-159: UserAgent/Language override test — Retry/Category addition looks good

Fits the broader retry rollout; the assertions remain clear and side-effect free.


8-8: Please verify DevTools V139 support in Selenium.WebDriver 4.35.0

I’m not able to confirm offline whether the OpenQA.Selenium.DevTools.V139.Emulation namespace is shipped in the 4.35.0 .NET package. Could you:

  • Inspect the contents of your Selenium.WebDriver.dll (e.g., via ILSpy/dnSpy) to see if there’s an OpenQA.Selenium.DevTools.V139 folder with Emulation.
  • Check the official release notes or API docs for Selenium 4.35.0 on GitHub to confirm which CDP versions are bundled.
  • If V139 isn’t present, fall back to the highest available CDP version (e.g., V138) and update the using/import accordingly.

This will ensure the test references a namespace that actually exists in the shipped package.


105-121: C# 12 empty collection expression is supported by net8.0

The test project targets net8.0, which defaults to C# 12 and therefore supports the [] collection expression for an empty argument list. No change is needed.

@mialeska mialeska merged commit c45cc40 into master Aug 26, 2025
6 checks passed
@github-project-automation github-project-automation bot moved this from In progress to Done in Aquality Selenium Aug 26, 2025
@mialeska mialeska deleted the update-to-selenium-4.35.0 branch August 26, 2025 12:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dotnet enhancement New feature or request

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants