Get URL new window

2 posts, 0 answers
  1. Torch
    Torch avatar
    4 posts
    Member since:
    Aug 2012

    Posted 25 Jan 2013 Link to this post

    Browser: Google Chrome v.24

    On the page
    click on a link that opens in a new window.
    Need to get the address of the page that opens in a new window.

    Relying on the topic, click on the link using:

    Find.ById <HtmlAnchor> ("id_number"). MouseClick ();

    However, clicking the link does not occur.

    To retrieve and compare URL:
    WaitForNewBrowserConnect ("url", false, 1000);

    Tell me, please, as well as right-click on the link and then get the URL?

    P.S. Translated by Google Translate
  2. Plamen
    Admin
    Plamen avatar
    8 posts

    Posted 30 Jan 2013 Link to this post

    Hello Torch,

    Please read this article for a detailed explanation on how to handle HTML Pop-ups. Here is a sample code written against a local HTML file that contains the following link in it:
     
    <a href="http://www.bing.com"target="_blank"id="bing">Bing Popup</a>

    Manager.LaunchNewBrowser(BrowserType.InternetExplorer);
     
    ActiveBrowser.NavigateTo("C:\\Users\\peykov\\Desktop\\popup.html");
     
    Manager.SetNewBrowserTracking(true);
     
    //Open a new browser window
    Find.ById<HtmlAnchor>("bing").MouseClick();
     
    Manager.WaitForNewBrowserConnect("http://www.bing.com", true, 5000);
    Manager.SetNewBrowserTracking(false);
     
    //Write the URL of the new browser in the log
    Log.WriteLine(ActiveBrowser.Url);
     
    //Check whether the URL contains http://www.bing.com
    Assert.IsTrue(ActiveBrowser.Url.Contains("http://www.bing.com"));
     
    ActiveBrowser.Close();
     
    This short video demonstrates the execution of the code above.

    If you are still unable to get this to work, please provide access to your application and I'll be glad to assist you in writing the code. Alternatively you can record and send us a Fiddler trace using FiddlerCap, which is a good substitute for direct access. If you feel that this information is sensitive, you can submit a support ticket which is confidential, unlike this forum.

    Kind regards,
    Plamen
    the Telerik team
    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
Back to Top