TabElement
Playwright element wrapper for <vaadin-tab> within a TabSheet or Tabs component.
Component Tag
vaadin-tab
vaadin-tabs - Parent tabs container
Constructor
Playwright locator for the <vaadin-tab> element
Static Factory Methods
getTabByText
Get a tab by visible text within a scope.
TabElement.getTabByText(Locator locator, String summary)
Scope to search within (typically tabsheet or tabs element)
getSelectedTab
Get the currently selected tab within a scope.
TabElement.getSelectedTab(Locator locator)
Scope to search within (typically tabsheet or tabs element)
Methods
isSelected
Whether the tab is currently selected.
select
Select the tab by clicking it.
getLabel
Get the tab label text.
Assertion Methods
assertSelected
Assert that the tab is selected.
assertNotSelected
Assert that the tab is not selected.
Usage Examples
Basic Tab Selection
TabSheetElement tabSheet = TabSheetElement.get(page);
TabElement tab = tabSheet.getTab("Details");
tab.assertNotSelected();
tab.select();
tab.assertSelected();
Check Tab Label
TabElement tab = tabSheet.getTab("Settings");
String label = tab.getLabel();
assertEquals("Settings", label);
Verify Selected Tab
TabSheetElement tabSheet = TabSheetElement.get(page);
TabElement selectedTab = tabSheet.getSelectedTab();
if (selectedTab.isSelected()) {
String label = selectedTab.getLabel();
System.out.println("Currently viewing: " + label);
}
Switch Between Tabs
TabSheetElement tabSheet = TabSheetElement.get(page);
TabElement overview = tabSheet.getTab("Overview");
TabElement details = tabSheet.getTab("Details");
overview.assertSelected();
details.assertNotSelected();
details.select();
overview.assertNotSelected();
details.assertSelected();
Use Static Factory Methods
Locator tabsLocator = page.locator("vaadin-tabsheet").first();
// Get by text
TabElement tab = TabElement.getTabByText(tabsLocator, "Settings");
tab.select();
// Get selected
TabElement selected = TabElement.getSelectedTab(tabsLocator);
assertEquals("Settings", selected.getLabel());