Skip to main content

ProgressBarElement

Playwright element wrapper for <vaadin-progress-bar> supporting value/min/max setters and assertions and indeterminate state.

Component Tag

vaadin-progress-bar

Implements

  • HasThemeElement - Theme variant support
  • HasStyleElement - CSS class and style management

Constructor

locator
Locator
required
Playwright locator for the <vaadin-progress-bar> element

Property Methods

getValue

Current numeric value parsed from aria-valuenow.
double getValue()
Returns the current progress value.

setValue

Set the progress bar value.
void setValue(double value)
value
double
Progress value to set

getMin

Get the minimum value.
Double getMin()
Returns the min value, or null if not set.

setMin

Set the minimum value.
void setMin(double min)
min
double
Minimum value to set

getMax

Get the maximum value.
Double getMax()
Returns the max value, or null if not set.

setMax

Set the maximum value.
void setMax(double max)
max
double
Maximum value to set

isIndeterminate

Whether the bar is indeterminate.
boolean isIndeterminate()

setIndeterminate

Set the indeterminate state.
void setIndeterminate(boolean indeterminate)
indeterminate
boolean
Whether to show indeterminate state

Assertion Methods

assertValue

Assert that the numeric value matches.
void assertValue(Double expected)
expected
Double
Expected value, or null to assert undefined

assertMin

Assert that min matches the expected value.
void assertMin(double min)
min
double
Expected minimum value

assertMax

Assert that max matches the expected value.
void assertMax(double max)
max
double
Expected maximum value

assertIndeterminate

Assert indeterminate state.
void assertIndeterminate()

assertNotIndeterminate

Assert not indeterminate.
void assertNotIndeterminate()

Usage Examples

Basic Progress Bar

ProgressBarElement progressBar = new ProgressBarElement(page.locator("#progress-bar"));
progressBar.assertVisible();
progressBar.assertValue(0.5);
progressBar.assertNotIndeterminate();

Indeterminate Progress Bar

ProgressBarElement progressBar = new ProgressBarElement(
    page.locator("#indeterminate-progress-bar")
);
progressBar.assertVisible();
progressBar.assertIndeterminate();

Progress Bar with Min/Max

ProgressBarElement progressBar = new ProgressBarElement(
    page.locator("#min-max-progress-bar")
);

progressBar.assertMin(10.50);
progressBar.assertMax(100);
progressBar.assertValue(50.0);

Update Progress Value

ProgressBarElement progressBar = new ProgressBarElement(page.locator("#progress-bar"));

progressBar.setValue(0.75);
progressBar.assertValue(0.75);

double currentValue = progressBar.getValue();
assertEquals(0.75, currentValue, 0.01);

Set Min and Max

ProgressBarElement progressBar = new ProgressBarElement(page.locator("#progress-bar"));

progressBar.setMin(0);
progressBar.assertMin(0.0);

progressBar.setMax(200);
progressBar.assertMax(200.0);

progressBar.setValue(100);
progressBar.assertValue(100.0);

Toggle Indeterminate State

ProgressBarElement progressBar = new ProgressBarElement(page.locator("#progress-bar"));

progressBar.assertNotIndeterminate();

progressBar.setIndeterminate(true);
progressBar.assertIndeterminate();

boolean isIndeterminate = progressBar.isIndeterminate();
assertTrue(isIndeterminate);

Check Progress State

ProgressBarElement progressBar = new ProgressBarElement(page.locator("#progress-bar"));

if (progressBar.isIndeterminate()) {
    System.out.println("Progress is indeterminate");
} else {
    double value = progressBar.getValue();
    double max = progressBar.getMax();
    double percent = (value / max) * 100;
    System.out.println("Progress: " + percent + "%");
}

Progress Bar with Theme

ProgressBarElement progressBar = new ProgressBarElement(page.locator("#progress-bar"));
progressBar.assertTheme("success");
progressBar.assertValue(1.0);

Build docs developers (and LLMs) love