Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8951011
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T13:34:10+00:00 2026-06-15T13:34:10+00:00

I need to detect when the url in the browser changes whether it was

  • 0

I need to detect when the url in the browser changes whether it was because of click on a link, a form post or I changed the url in code.

I need it because I’m creating an object to represent the page and I need to dispose recreate it when the url changes.

Here is what I have tried so far:

private string _pageUrl;
protected T _page = default(T);
protected T Page
{
    get
    {
        if (_page == null || UrlHasChanged())
        {
            _page = GetPage<T>();
            SetPageUrl();
        }
        return _page;
    }
}

private bool UrlHasChanged()
{
    var driver = Session.GetDriver();
    return driver.Url != _pageUrl;
}

public void SetPageUrl()
{
    _pageUrl = Session.GetDriver().Url;
}

This works in most cases but it fails when the test goes forward a page and then goes back to the initial page.

I need a way to detect when the url changes so I can reset the _page field.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T13:34:11+00:00Added an answer on June 15, 2026 at 1:34 pm

    I’m a Java developer, so, I search in the C# documentation what looked similar to the Java API. I think you should use the EventFiringWebDriver :

    EventFiringWebDriver firingDriver = new EventFiringWebDriver(driver);
    firingDriver.NavigatingBack += new EventHandler<WebDriverNavigationEventArgs>(...);
    firingDriver.NavigatedBack += new EventHandler<WebDriverNavigationEventArgs>(...);
    firingDriver.NavigatingForward += new EventHandler<WebDriverNavigationEventArgs>(...);
    firingDriver.NavigatedForward += new EventHandler<WebDriverNavigationEventArgs>(...);
    

    I looked at the unit tests and I found this one that may be useful for you :
    http://selenium.googlecode.com/svn/trunk/dotnet/test/WebDriver.Support.Tests/Events/EventFiringWebDriverTest.cs

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to write regex in this code to detect id on url like
I need to detect and eval the Javascript code contained in a string. The
I need to detect if a post contains a specific category from a JSONP
In a .NET application I am writing, I need to detect whether a particular
For my web app I need a way to detect whether the application has
This function disables the default action for a link, and changes the URL using
how can me detect movie title from url.. http://www.mysite.com/2430-Moonrise-Kingdom.aspx http://www.mysite.com/2405-Dark-Shadows.aspx http://www.mysite.com/2415-Madagascar-3-Europes-Most-Wanted.aspx I need to
I need to detect all the red pixels in an image using Java. What
I need to detect IE7 (and IE6) using the user agent string: I have
I need to detect android device orientation change without playing manually with sensor data,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.