Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
vikas_agarwal
Frequent Visitor

Data Test Id for Web Elements

Hi,

 

For Desktop:

How we can add test id to the Page Visuals?

 

For Apps:

How we can add test id to the menu options?

 

or any other alternative to make automation smooth?

3 REPLIES 3
vikas_agarwal
Frequent Visitor

document.getElementsByClassName("visualContainerGroup")

gives all the visuals on the page.

 

In Developer Tools,

I also see name attribute being part of the div, looks like auto generated.

 

I further checked in (report.json) .pbib file that name is generated when the instance is created, seems it is same  as div attribute value.

data-testid are present with common values.

For e.g. if we want to get the title of a card.

document.getElementsByName("d6c41b97a22e0323e04d")[0].querySelectorAll("[data-testid='visual-title']");

where d6c41b97a22e0323e04d is a name field.

 

Can someone confirm, this is the right way or other standard way (API) exists?

vikas_agarwal
Frequent Visitor

Hi Yolo,

 

You can check more details about test id on:

https://www.educative.io/answers/what-is-the-data-testid-attribute-in-testing

 

Let's take a simple use case of a card visual.

From the Testing perspective. Testcase will verify Title, Text value. 

Interested path will be to search element id (or data-testid) by the card and then sub sections.

v-xinruzhu-msft
Community Support
Community Support

Hi @vikas_agarwal 

What is the testid you want to display, can you provide some sample data or the output you want? so that can provide more suggestion for you.

 

Best Regards!

Yolo Zhu

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

AugPowerBI_Carousel

Power BI Monthly Update - August 2024

Check out the August 2024 Power BI update to learn about new features.

August Carousel

Fabric Community Update - August 2024

Find out what's new and trending in the Fabric Community.