• Blog
  • Info Support
  • Career
  • Training
  • International Group
  • Info Support
  • Blog
  • Career
  • Training
  • International Group
  • Search
logo InfoSupport
  • Latest blogs
  • Popular blogs
  • Experts
      • Alles
      • Bloggers
      • Speakers
  • Meet us
  • About us
    • nl
    • en
    • .NET
    • Advanced Analytics
    • Agile
    • Akka
    • Alexa
    • Algorithms
    • Api's
    • Architectuur
    • Artificial Intelligence
    • ATDD
    • Augmented Reality
    • AWS
    • Azure
    • Big Data
    • Blockchain
    • Business Intelligence
    • Cloud
    • Code Combat
    • Cognitive Services
    • Communicatie
    • Containers
    • Continuous Delivery
    • CQRS
    • Cyber Security
    • Dapr
    • Data
    • Data & Analystics
    • Data Science
    • Data Warehousing
    • Databricks
    • DevOps
    • Digital Days
    • Docker
    • eHealth
    • Enterprise Architecture
    • Hacking
    • Infrastructure & Hosting
    • Innovatie
    • Integration
    • Internet of Things
    • Java
    • Machine Learning
    • Microservices
    • Microsoft
    • Microsoft Bot Framework
    • Microsoft Data Platform
    • Mobile Development
    • Mutation Testing
    • Open source
    • Pepper
    • Power BI
    • Privacy & Ethiek
    • Python
    • Quality Assistance & Test
    • Quality Assurance & Test
    • Requirements Management
    • Scala
    • Scratch
    • Security
    • SharePoint
    • Software Architecture
    • Software development
    • Software Factory
    • SQL Server
    • SSL
    • Start-up
    • Startup thinking
    • Stryker
    • Test Quality
    • Testing
    • TLS
    • TypeScript
    • Various
    • Web Development
    • Web-scale IT
    • Xamarin
    • Alles
    • Bloggers
    • Speakers
Home » How to find controls in new Tabs of your browser with CodedUI
  • How to find controls in new Tabs of your browser with CodedUI

    • By Marcel de Vries
    • Various 8 years ago
    • Various 0 comments
    • Various Various
    How to find controls in new Tabs of your browser with CodedUI

    *Moved to: http://fluentbytes.com/how-to-find-controls-in-new-tabs-of-your-browser-with-codedui/

    One question I got recently is if it is possible to find controls on secondary tabs that are created by an application when using CodedUI. the answer is yes and I thought it would be handy to write up how to make this happen.

    For purpose of the sample I create a simple ASP.NET MVC website and changed the default page to have a link button that creates a new page in a second tab.

    The page looks as follows:

    image

    When I click the button, then a new tab is opened and that will show the following page:

    image

    As you can see I have done a lot of work to make the page look pretty Smile but that was not the purpose, it is to get the point across how to find the Html on the second tab.

    The way you do this is as follows:

    • You first start your test, by using the BrowserWindow class and call Launch to start the browser.
    • Next you find the HtmlHyperlink to execute the click on the button.
    • Now you have the second tab show up, and to locate that tab, you can use the BrowserWindow class again. this time you use the static method Locate and pass it in the title of the document you try to find. In my case that new tab has the Title “New Tab”
    • This locate method, returns a new BrowserWindow object that I can use in my subsequent searches for controls. So to find the text on the page I can create an HtmlDiv object, pass it in the SearchProperty Id with the value of “itemToFind” and get the InnerText value of the control to assert in my test.

    The code looks as follows:

    [TestMethod]
    public void TestMultiTabBrowser()
    {
        var browserWIndow = BrowserWindow.Launch("http://localhost:7032/");
    
        // Search for the hyperlink button to open up a new tab
        HtmlHyperlink link = new HtmlHyperlink(browserWIndow);
        link.SearchProperties.Add(HtmlHyperlink.PropertyNames.Id , "newTabHyperlink");
    
        Mouse.Click(link);
    
        // now the new tab should be shown, locate that new window and find the inner text
    
        var browsertab = BrowserWindow.Locate("New Tab");
    
        // now locate the div and compare the inner text
    
        HtmlDiv itemtofindOnNewTab = new HtmlDiv(browsertab);
        itemtofindOnNewTab.SearchProperties.Add(HtmlDiv.PropertyNames.Id, "itemToFind");
    
        Assert.IsTrue(itemtofindOnNewTab.InnerText == "This is the inner text ");
    
    }
    

    And that is it, this is the way to create tests that can work with with multiple tabs in your browser

    I have the sample project up here for you to download and test yourself.

    If you want to learn more about CodedUI and how this technology works, you might want to check out my course at Pluralsight on CodedUI. You can find it here and even watch it for free if you don’t have an account, by applying for a Trial.

    hope this helps,
    Marcel

    Follow my new blog on http://fluentbytes.com

    Share this

Marcel de Vries

View profile

IT Training at Info Support

Which training fits you?

Consultancy

Consultancy

Related blogs

  • Video Conferencing en OBS Studio koppelen: online prese…

    Video Conferencing en OBS Studio koppelen: online prese… Maaike Brouwer - 1 year ago

  • Verantwoordelijkheid pakken in jouw eigen persoonlijke …

    Verantwoordelijkheid pakken in jouw eigen persoonlijke … Stephan Versteegh - 1 year ago

  • Tips voor als je gaat afstuderen

    Tips voor als je gaat afstuderen Bart Renders - 2 years ago

Related downloads

  • Beslisboom voor een rechtmatig ‘kopietje productie’

  • Klantreferentie: Remmicom zet wetgeving om in intellige…

  • Klantreferentie RDW: Samenwerken voor veilig en vertrou…

  • Klantreferentie BeFrank: Strategische IT voor een innov…

  • Wie durft te experimenteren met data in de zorg?

Related videos

  • mijnverzekeringenopeenrij.nl

    mijnverzekeringenopeenrij.nl

  • Winnaar | Innovation Projects 2017

    Winnaar | Innovation Projects 2017

  • Explore | Info Support & HAN & Poliskluis

    Explore | Info Support & HAN & Poliskluis

  • LifeApps bij HagaZiekenhuis

    LifeApps bij HagaZiekenhuis

  • Info Support | Bedrijfsfilm

    Info Support | Bedrijfsfilm

Nieuwsbrief

* verplichte velden

Contact

  • Head office NL
  • Kruisboog 42
  • 3905 TG Veenendaal
  • T +31 318 552020
  • Call
  • Mail
  • Directions
  • Head office BE
  • Generaal De Wittelaan 17
  • bus 30 2800 Mechelen
  • T +32 15 286370
  • Call
  • Mail
  • Directions

Follow us

  • Twitter
  • Facebook
  • Linkedin
  • Youtube

Newsletter

Sign in

Extra

  • Media Library
  • Disclaimer
  • Algemene voorwaarden
  • ISHBS Webmail
  • Extranet
Beheer cookie toestemming
Deze website maakt gebruik van Functionele en Analytische cookies voor website optimalisatie en statistieken.
Functioneel
Altijd actief
De technische opslag of toegang is strikt noodzakelijk voor het legitieme doel het gebruik mogelijk te maken van een specifieke dienst waarom de abonnee of gebruiker uitdrukkelijk heeft gevraagd, of met als enig doel de uitvoering van de transmissie van een communicatie over een elektronisch communicatienetwerk.
Voorkeuren
De technische opslag of toegang is noodzakelijk voor het legitieme doel voorkeuren op te slaan die niet door de abonnee of gebruiker zijn aangevraagd.
Statistieken
De technische opslag of toegang die uitsluitend voor statistische doeleinden wordt gebruikt. De technische opslag of toegang die uitsluitend wordt gebruikt voor anonieme statistische doeleinden. Zonder dagvaarding, vrijwillige naleving door uw Internet Service Provider, of aanvullende gegevens van een derde partij, kan informatie die alleen voor dit doel wordt opgeslagen of opgehaald gewoonlijk niet worden gebruikt om je te identificeren.
Marketing
De technische opslag of toegang is nodig om gebruikersprofielen op te stellen voor het verzenden van reclame, of om de gebruiker op een website of over verschillende websites te volgen voor soortgelijke marketingdoeleinden.
Beheer opties Beheer diensten Beheer leveranciers Lees meer over deze doeleinden
Voorkeuren
{title} {title} {title}