seleniumhq.github.io icon indicating copy to clipboard operation
seleniumhq.github.io copied to clipboard

Added one more way for navigation in NavigationTest.cs for C#

Open Rupesh253 opened this issue 1 year ago • 4 comments

User description

Added one more possibility for Navigation

Thanks for contributing to the Selenium site and documentation! A PR well described will help maintainers to review and merge it quickly

Before submitting your PR, please check our contributing guidelines. Avoid large PRs, and help reviewers by making them as simple and short as possible.

Description

Motivation and Context

Types of changes

  • [x] Change to the site (I have double-checked the Netlify deployment, and my changes look good)
  • [x] Code example added (and I also added the example to all translated languages)
  • [x] Improved translation
  • [x] Added new translation (and I also added a notice to each document missing translation)

Checklist

  • [x] I have read the contributing document.
  • [x] I have used hugo to render the site/docs locally and I am sure it works.

PR Type

enhancement, documentation


Description

  • Enhanced the NavigationTest.cs by adding comments to clarify the usage of different navigation methods.
  • Introduced an additional example demonstrating the use of driver.Navigate().GoToUrl() with a Uri argument.
  • Improved documentation within the code to aid understanding of navigation options in Selenium.

Changes walkthrough 📝

Relevant files
Enhancement
NavigationTest.cs
Enhance navigation test with additional example and comments

examples/dotnet/SeleniumDocs/Interactions/NavigationTest.cs

  • Added comments explaining the usage of driver.Url and
    driver.Navigate().GoToUrl().
  • Introduced an additional example using driver.Navigate().GoToUrl()
    with a Uri argument.
  • +5/-2     

    💡 PR-Agent usage: Comment /help "your question" on any pull request to receive relevant information

    Rupesh253 avatar Oct 14 '24 14:10 Rupesh253

    Deploy request for selenium-dev pending review.

    Visit the deploys page to approve it

    Name Link
    Latest commit add1d0c3360184ed7ea412410e16dfa7683ca541

    netlify[bot] avatar Oct 14 '24 14:10 netlify[bot]

    CLA assistant check
    Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
    You have signed the CLA already but the status is still pending? Let us recheck it.

    CLAassistant avatar Oct 14 '24 14:10 CLAassistant

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    ⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
    🧪 No relevant tests
    🔒 No security concerns identified
    ⚡ Recommended focus areas for review

    Code Duplication
    The PR introduces duplicate navigation to the same URL ("https://selenium.dev") using different methods. This might lead to confusion and unnecessary test execution time. Consider removing one of the navigation calls or using different URLs to demonstrate the various navigation methods.

    Commented Code
    There is a commented-out line of code demonstrating an additional navigation method. Consider either removing this line or uncommenting it if it's meant to be part of the example.

    qodo-code-review[bot] avatar Oct 14 '24 14:10 qodo-code-review[bot]

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Score
    Possible issue
    Add a wait condition after navigation to ensure the page has loaded before assertions

    Consider adding a small delay or wait condition after navigation to ensure the page
    has loaded before performing assertions. This can help prevent flaky tests.

    examples/dotnet/SeleniumDocs/Interactions/NavigationTest.cs [20-25]

     driver.Navigate().GoToUrl("https://selenium.dev");
    +
    +WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));
    +wait.Until(d => d.Title.Contains("Selenium"));
     
     var title = driver.Title;
     Assert.AreEqual("Selenium", title);
    
    • [ ] Apply this suggestion
    Suggestion importance[1-10]: 9

    Why: Adding a wait condition is crucial for ensuring that the page has fully loaded before performing assertions, which can prevent flaky tests and improve test reliability.

    9
    Best practice
    Use a constant for repeated URL values to improve maintainability and reduce errors

    Consider using a constant or configuration value for the URL instead of hardcoding
    it multiple times. This improves maintainability and reduces the risk of typos.

    examples/dotnet/SeleniumDocs/Interactions/NavigationTest.cs [18-22]

    -driver.Url = "https://selenium.dev";
    -driver.Navigate().GoToUrl("https://selenium.dev");
    -//driver.Navigate().GoToUrl(new Uri("https://selenium.dev"));
    +const string SeleniumUrl = "https://selenium.dev";
    +driver.Url = SeleniumUrl;
    +driver.Navigate().GoToUrl(SeleniumUrl);
    +//driver.Navigate().GoToUrl(new Uri(SeleniumUrl));
    
    • [ ] Apply this suggestion
    Suggestion importance[1-10]: 8

    Why: This suggestion improves code maintainability by using a constant for the URL, reducing the risk of typos and making it easier to update the URL in one place if needed.

    8

    💡 Need additional feedback ? start a PR chat

    qodo-code-review[bot] avatar Oct 14 '24 14:10 qodo-code-review[bot]

    Hi @Rupesh253,

    Thank you for your contribution!

    I appreciate the effort to clarify the differences between driver.Url and driver.Navigate().GoToUrl. However, for the context provided, our goal is to show the usage of both driver.Url and driver.Navigate().GoToUrl, without detailing the types of arguments they accept. Including the additional notes on Uri and string arguments may add unnecessary complexity for our intended audience in docs.

    For simplicity and consistency, we'll keep the original explanations focused on basic usage examples. Thanks again for the suggestion, and we welcome further contributions!

    harsha509 avatar Nov 01 '24 14:11 harsha509

    Closing as Not Planned!

    harsha509 avatar Nov 01 '24 15:11 harsha509