Class LocatorAssertionsImpl
- All Implemented Interfaces:
LocatorAssertions
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.microsoft.playwright.assertions.LocatorAssertions
LocatorAssertions.ContainsTextOptions, LocatorAssertions.HasAttributeOptions, LocatorAssertions.HasClassOptions, LocatorAssertions.HasCountOptions, LocatorAssertions.HasCSSOptions, LocatorAssertions.HasIdOptions, LocatorAssertions.HasJSPropertyOptions, LocatorAssertions.HasTextOptions, LocatorAssertions.HasValueOptions, LocatorAssertions.HasValuesOptions, LocatorAssertions.IsAttachedOptions, LocatorAssertions.IsCheckedOptions, LocatorAssertions.IsDisabledOptions, LocatorAssertions.IsEditableOptions, LocatorAssertions.IsEmptyOptions, LocatorAssertions.IsEnabledOptions, LocatorAssertions.IsFocusedOptions, LocatorAssertions.IsHiddenOptions, LocatorAssertions.IsInViewportOptions, LocatorAssertions.IsVisibleOptions -
Field Summary
Fields inherited from class com.microsoft.playwright.impl.AssertionsBase
actualLocator, isNot -
Constructor Summary
ConstructorsModifierConstructorDescriptionLocatorAssertionsImpl(Locator locator) privateLocatorAssertionsImpl(Locator locator, boolean isNot) -
Method Summary
Modifier and TypeMethodDescriptionvoidcontainsText(String[] strings, LocatorAssertions.ContainsTextOptions options) Ensures theLocatorpoints to an element that contains the given text.voidcontainsText(String text, LocatorAssertions.ContainsTextOptions options) Ensures theLocatorpoints to an element that contains the given text.voidcontainsText(Pattern[] patterns, LocatorAssertions.ContainsTextOptions options) Ensures theLocatorpoints to an element that contains the given text.voidcontainsText(Pattern pattern, LocatorAssertions.ContainsTextOptions options) Ensures theLocatorpoints to an element that contains the given text.private voidexpectTrue(String expression, String message, FrameExpectOptions options) private voidhasAttribute(String name, ExpectedTextValue expectedText, Object expectedValue, LocatorAssertions.HasAttributeOptions options) voidhasAttribute(String name, String text, LocatorAssertions.HasAttributeOptions options) Ensures theLocatorpoints to an element with given attribute.voidhasAttribute(String name, Pattern pattern, LocatorAssertions.HasAttributeOptions options) Ensures theLocatorpoints to an element with given attribute.voidhasClass(String[] strings, LocatorAssertions.HasClassOptions options) Ensures theLocatorpoints to an element with given CSS classes.voidhasClass(String text, LocatorAssertions.HasClassOptions options) Ensures theLocatorpoints to an element with given CSS classes.voidhasClass(Pattern[] patterns, LocatorAssertions.HasClassOptions options) Ensures theLocatorpoints to an element with given CSS classes.voidhasClass(Pattern pattern, LocatorAssertions.HasClassOptions options) Ensures theLocatorpoints to an element with given CSS classes.voidhasCount(int count, LocatorAssertions.HasCountOptions options) Ensures theLocatorresolves to an exact number of DOM nodes.private voidhasCSS(String name, ExpectedTextValue expectedText, Object expectedValue, LocatorAssertions.HasCSSOptions options) voidhasCSS(String name, String value, LocatorAssertions.HasCSSOptions options) Ensures theLocatorresolves to an element with the given computed CSS style.voidhasCSS(String name, Pattern pattern, LocatorAssertions.HasCSSOptions options) Ensures theLocatorresolves to an element with the given computed CSS style.voidhasId(String id, LocatorAssertions.HasIdOptions options) Ensures theLocatorpoints to an element with the given DOM Node ID.voidhasId(Pattern pattern, LocatorAssertions.HasIdOptions options) Ensures theLocatorpoints to an element with the given DOM Node ID.voidhasJSProperty(String name, Object value, LocatorAssertions.HasJSPropertyOptions options) Ensures theLocatorpoints to an element with given JavaScript property.voidhasText(String[] strings, LocatorAssertions.HasTextOptions options) Ensures theLocatorpoints to an element with the given text.voidhasText(String text, LocatorAssertions.HasTextOptions options) Ensures theLocatorpoints to an element with the given text.voidhasText(Pattern[] patterns, LocatorAssertions.HasTextOptions options) Ensures theLocatorpoints to an element with the given text.voidhasText(Pattern pattern, LocatorAssertions.HasTextOptions options) Ensures theLocatorpoints to an element with the given text.voidhasValue(String value, LocatorAssertions.HasValueOptions options) Ensures theLocatorpoints to an element with the given input value.voidhasValue(Pattern pattern, LocatorAssertions.HasValueOptions options) Ensures theLocatorpoints to an element with the given input value.voidhasValues(String[] values, LocatorAssertions.HasValuesOptions options) Ensures theLocatorpoints to multi-select/combobox (i.e.voidhasValues(Pattern[] patterns, LocatorAssertions.HasValuesOptions options) Ensures theLocatorpoints to multi-select/combobox (i.e.voidEnsures thatLocatorpoints to an attached DOM node.voidEnsures theLocatorpoints to a checked input.voidEnsures theLocatorpoints to a disabled element.voidEnsures theLocatorpoints to an editable element.voidisEmpty(LocatorAssertions.IsEmptyOptions options) Ensures theLocatorpoints to an empty editable element or to a DOM node that has no text.voidEnsures theLocatorpoints to an enabled element.voidEnsures theLocatorpoints to a focused DOM node.voidEnsures thatLocatoreither does not resolve to any DOM node, or resolves to a non-visible one.voidEnsures theLocatorpoints to an element that intersects viewport, according to the intersection observer API.voidnot()Makes the assertion check for the opposite condition.private static BooleanshouldIgnoreCase(Object options) Methods inherited from class com.microsoft.playwright.impl.AssertionsBase
expectedRegex, expectImpl, expectImpl, expectImplMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.microsoft.playwright.assertions.LocatorAssertions
containsText, containsText, containsText, containsText, hasAttribute, hasAttribute, hasClass, hasClass, hasClass, hasClass, hasCount, hasCSS, hasCSS, hasId, hasId, hasJSProperty, hasText, hasText, hasText, hasText, hasValue, hasValue, hasValues, hasValues, isAttached, isChecked, isDisabled, isEditable, isEmpty, isEnabled, isFocused, isHidden, isInViewport, isVisible
-
Constructor Details
-
LocatorAssertionsImpl
-
LocatorAssertionsImpl
-
-
Method Details
-
containsText
Description copied from interface:LocatorAssertionsEnsures theLocatorpoints to an element that contains the given text. You can use regular expressions for the value as well.**Usage**
assertThat(page.locator(".title")).containsText("substring");If you pass an array as an expected value, the expectations are:
- Locator resolves to a list of elements.
- Elements from a **subset** of this list contain text from the expected array, respectively.
- The matching subset of elements has the same order as the expected array.
- Each text value from the expected array is matched by some element from the list.
For example, consider the following list:
Let's see how we can use the assertion:
// ✓ Contains the right items in the right order assertThat(page.locator("ul > li")).containsText(new String[] {"Text 1", "Text 3", "Text 4"}); // ✖ Wrong order assertThat(page.locator("ul > li")).containsText(new String[] {"Text 3", "Text 2"}); // ✖ No item contains this text assertThat(page.locator("ul > li")).containsText(new String[] {"Some 33"}); // ✖ Locator points to the outer list element, not to the list items assertThat(page.locator("ul")).containsText(new String[] {"Text 3"});- Specified by:
containsTextin interfaceLocatorAssertions- Parameters:
text- Expected substring or RegExp or a list of those.
-
containsText
Description copied from interface:LocatorAssertionsEnsures theLocatorpoints to an element that contains the given text. You can use regular expressions for the value as well.**Usage**
assertThat(page.locator(".title")).containsText("substring");If you pass an array as an expected value, the expectations are:
- Locator resolves to a list of elements.
- Elements from a **subset** of this list contain text from the expected array, respectively.
- The matching subset of elements has the same order as the expected array.
- Each text value from the expected array is matched by some element from the list.
For example, consider the following list:
Let's see how we can use the assertion:
// ✓ Contains the right items in the right order assertThat(page.locator("ul > li")).containsText(new String[] {"Text 1", "Text 3", "Text 4"}); // ✖ Wrong order assertThat(page.locator("ul > li")).containsText(new String[] {"Text 3", "Text 2"}); // ✖ No item contains this text assertThat(page.locator("ul > li")).containsText(new String[] {"Some 33"}); // ✖ Locator points to the outer list element, not to the list items assertThat(page.locator("ul")).containsText(new String[] {"Text 3"});- Specified by:
containsTextin interfaceLocatorAssertions- Parameters:
pattern- Expected substring or RegExp or a list of those.
-
containsText
Description copied from interface:LocatorAssertionsEnsures theLocatorpoints to an element that contains the given text. You can use regular expressions for the value as well.**Usage**
assertThat(page.locator(".title")).containsText("substring");If you pass an array as an expected value, the expectations are:
- Locator resolves to a list of elements.
- Elements from a **subset** of this list contain text from the expected array, respectively.
- The matching subset of elements has the same order as the expected array.
- Each text value from the expected array is matched by some element from the list.
For example, consider the following list:
Let's see how we can use the assertion:
// ✓ Contains the right items in the right order assertThat(page.locator("ul > li")).containsText(new String[] {"Text 1", "Text 3", "Text 4"}); // ✖ Wrong order assertThat(page.locator("ul > li")).containsText(new String[] {"Text 3", "Text 2"}); // ✖ No item contains this text assertThat(page.locator("ul > li")).containsText(new String[] {"Some 33"}); // ✖ Locator points to the outer list element, not to the list items assertThat(page.locator("ul")).containsText(new String[] {"Text 3"});- Specified by:
containsTextin interfaceLocatorAssertions- Parameters:
strings- Expected substring or RegExp or a list of those.
-
containsText
Description copied from interface:LocatorAssertionsEnsures theLocatorpoints to an element that contains the given text. You can use regular expressions for the value as well.**Usage**
assertThat(page.locator(".title")).containsText("substring");If you pass an array as an expected value, the expectations are:
- Locator resolves to a list of elements.
- Elements from a **subset** of this list contain text from the expected array, respectively.
- The matching subset of elements has the same order as the expected array.
- Each text value from the expected array is matched by some element from the list.
For example, consider the following list:
Let's see how we can use the assertion:
// ✓ Contains the right items in the right order assertThat(page.locator("ul > li")).containsText(new String[] {"Text 1", "Text 3", "Text 4"}); // ✖ Wrong order assertThat(page.locator("ul > li")).containsText(new String[] {"Text 3", "Text 2"}); // ✖ No item contains this text assertThat(page.locator("ul > li")).containsText(new String[] {"Some 33"}); // ✖ Locator points to the outer list element, not to the list items assertThat(page.locator("ul")).containsText(new String[] {"Text 3"});- Specified by:
containsTextin interfaceLocatorAssertions- Parameters:
patterns- Expected substring or RegExp or a list of those.
-
hasAttribute
Description copied from interface:LocatorAssertionsEnsures theLocatorpoints to an element with given attribute.**Usage**
assertThat(page.locator("input")).hasAttribute("type", "text");- Specified by:
hasAttributein interfaceLocatorAssertions- Parameters:
name- Attribute name.text- Expected attribute value.
-
hasAttribute
public void hasAttribute(String name, Pattern pattern, LocatorAssertions.HasAttributeOptions options) Description copied from interface:LocatorAssertionsEnsures theLocatorpoints to an element with given attribute.**Usage**
assertThat(page.locator("input")).hasAttribute("type", "text");- Specified by:
hasAttributein interfaceLocatorAssertions- Parameters:
name- Attribute name.pattern- Expected attribute value.
-
hasAttribute
private void hasAttribute(String name, ExpectedTextValue expectedText, Object expectedValue, LocatorAssertions.HasAttributeOptions options) -
hasClass
Description copied from interface:LocatorAssertionsEnsures theLocatorpoints to an element with given CSS classes. This needs to be a full match or using a relaxed regular expression.**Usage**
assertThat(page.locator("#component")).hasClass(Pattern.compile("selected")); assertThat(page.locator("#component")).hasClass("selected row");Note that if array is passed as an expected value, entire lists of elements can be asserted:
assertThat(page.locator("list > .component")).hasClass(new String[] {"component", "component selected", "component"});- Specified by:
hasClassin interfaceLocatorAssertions- Parameters:
text- Expected class or RegExp or a list of those.
-
hasClass
Description copied from interface:LocatorAssertionsEnsures theLocatorpoints to an element with given CSS classes. This needs to be a full match or using a relaxed regular expression.**Usage**
assertThat(page.locator("#component")).hasClass(Pattern.compile("selected")); assertThat(page.locator("#component")).hasClass("selected row");Note that if array is passed as an expected value, entire lists of elements can be asserted:
assertThat(page.locator("list > .component")).hasClass(new String[] {"component", "component selected", "component"});- Specified by:
hasClassin interfaceLocatorAssertions- Parameters:
pattern- Expected class or RegExp or a list of those.
-
hasClass
Description copied from interface:LocatorAssertionsEnsures theLocatorpoints to an element with given CSS classes. This needs to be a full match or using a relaxed regular expression.**Usage**
assertThat(page.locator("#component")).hasClass(Pattern.compile("selected")); assertThat(page.locator("#component")).hasClass("selected row");Note that if array is passed as an expected value, entire lists of elements can be asserted:
assertThat(page.locator("list > .component")).hasClass(new String[] {"component", "component selected", "component"});- Specified by:
hasClassin interfaceLocatorAssertions- Parameters:
strings- Expected class or RegExp or a list of those.
-
hasClass
Description copied from interface:LocatorAssertionsEnsures theLocatorpoints to an element with given CSS classes. This needs to be a full match or using a relaxed regular expression.**Usage**
assertThat(page.locator("#component")).hasClass(Pattern.compile("selected")); assertThat(page.locator("#component")).hasClass("selected row");Note that if array is passed as an expected value, entire lists of elements can be asserted:
assertThat(page.locator("list > .component")).hasClass(new String[] {"component", "component selected", "component"});- Specified by:
hasClassin interfaceLocatorAssertions- Parameters:
patterns- Expected class or RegExp or a list of those.
-
hasCount
Description copied from interface:LocatorAssertionsEnsures theLocatorresolves to an exact number of DOM nodes.**Usage**
assertThat(page.locator("list > .component")).hasCount(3);- Specified by:
hasCountin interfaceLocatorAssertions- Parameters:
count- Expected count.
-
hasCSS
Description copied from interface:LocatorAssertionsEnsures theLocatorresolves to an element with the given computed CSS style.**Usage**
assertThat(page.getByRole(AriaRole.BUTTON)).hasCSS("display", "flex");- Specified by:
hasCSSin interfaceLocatorAssertions- Parameters:
name- CSS property name.value- CSS property value.
-
hasCSS
Description copied from interface:LocatorAssertionsEnsures theLocatorresolves to an element with the given computed CSS style.**Usage**
assertThat(page.getByRole(AriaRole.BUTTON)).hasCSS("display", "flex");- Specified by:
hasCSSin interfaceLocatorAssertions- Parameters:
name- CSS property name.pattern- CSS property value.
-
hasCSS
private void hasCSS(String name, ExpectedTextValue expectedText, Object expectedValue, LocatorAssertions.HasCSSOptions options) -
hasId
Description copied from interface:LocatorAssertionsEnsures theLocatorpoints to an element with the given DOM Node ID.**Usage**
assertThat(page.getByRole(AriaRole.TEXTBOX)).hasId("lastname");- Specified by:
hasIdin interfaceLocatorAssertions- Parameters:
id- Element id.
-
hasId
Description copied from interface:LocatorAssertionsEnsures theLocatorpoints to an element with the given DOM Node ID.**Usage**
assertThat(page.getByRole(AriaRole.TEXTBOX)).hasId("lastname");- Specified by:
hasIdin interfaceLocatorAssertions- Parameters:
pattern- Element id.
-
hasJSProperty
public void hasJSProperty(String name, Object value, LocatorAssertions.HasJSPropertyOptions options) Description copied from interface:LocatorAssertionsEnsures theLocatorpoints to an element with given JavaScript property. Note that this property can be of a primitive type as well as a plain serializable JavaScript object.**Usage**
assertThat(page.locator("input")).hasJSProperty("loaded", true);- Specified by:
hasJSPropertyin interfaceLocatorAssertions- Parameters:
name- Property name.value- Property value.
-
hasText
Description copied from interface:LocatorAssertionsEnsures theLocatorpoints to an element with the given text. You can use regular expressions for the value as well.**Usage**
assertThat(page.locator(".title")).hasText("Welcome, Test User"); assertThat(page.locator(".title")).hasText(Pattern.compile("Welcome, .*"));If you pass an array as an expected value, the expectations are:
- Locator resolves to a list of elements.
- The number of elements equals the number of expected values in the array.
- Elements from the list have text matching expected array values, one by one, in order.
For example, consider the following list:
Let's see how we can use the assertion:
// ✓ Has the right items in the right order assertThat(page.locator("ul > li")).hasText(new String[] {"Text 1", "Text 2", "Text 3"}); // ✖ Wrong order assertThat(page.locator("ul > li")).hasText(new String[] {"Text 3", "Text 2", "Text 1"}); // ✖ Last item does not match assertThat(page.locator("ul > li")).hasText(new String[] {"Text 1", "Text 2", "Text"}); // ✖ Locator points to the outer list element, not to the list items assertThat(page.locator("ul")).hasText(new String[] {"Text 1", "Text 2", "Text 3"});- Specified by:
hasTextin interfaceLocatorAssertions- Parameters:
text- Expected string or RegExp or a list of those.
-
hasText
Description copied from interface:LocatorAssertionsEnsures theLocatorpoints to an element with the given text. You can use regular expressions for the value as well.**Usage**
assertThat(page.locator(".title")).hasText("Welcome, Test User"); assertThat(page.locator(".title")).hasText(Pattern.compile("Welcome, .*"));If you pass an array as an expected value, the expectations are:
- Locator resolves to a list of elements.
- The number of elements equals the number of expected values in the array.
- Elements from the list have text matching expected array values, one by one, in order.
For example, consider the following list:
Let's see how we can use the assertion:
// ✓ Has the right items in the right order assertThat(page.locator("ul > li")).hasText(new String[] {"Text 1", "Text 2", "Text 3"}); // ✖ Wrong order assertThat(page.locator("ul > li")).hasText(new String[] {"Text 3", "Text 2", "Text 1"}); // ✖ Last item does not match assertThat(page.locator("ul > li")).hasText(new String[] {"Text 1", "Text 2", "Text"}); // ✖ Locator points to the outer list element, not to the list items assertThat(page.locator("ul")).hasText(new String[] {"Text 1", "Text 2", "Text 3"});- Specified by:
hasTextin interfaceLocatorAssertions- Parameters:
pattern- Expected string or RegExp or a list of those.
-
hasText
Description copied from interface:LocatorAssertionsEnsures theLocatorpoints to an element with the given text. You can use regular expressions for the value as well.**Usage**
assertThat(page.locator(".title")).hasText("Welcome, Test User"); assertThat(page.locator(".title")).hasText(Pattern.compile("Welcome, .*"));If you pass an array as an expected value, the expectations are:
- Locator resolves to a list of elements.
- The number of elements equals the number of expected values in the array.
- Elements from the list have text matching expected array values, one by one, in order.
For example, consider the following list:
Let's see how we can use the assertion:
// ✓ Has the right items in the right order assertThat(page.locator("ul > li")).hasText(new String[] {"Text 1", "Text 2", "Text 3"}); // ✖ Wrong order assertThat(page.locator("ul > li")).hasText(new String[] {"Text 3", "Text 2", "Text 1"}); // ✖ Last item does not match assertThat(page.locator("ul > li")).hasText(new String[] {"Text 1", "Text 2", "Text"}); // ✖ Locator points to the outer list element, not to the list items assertThat(page.locator("ul")).hasText(new String[] {"Text 1", "Text 2", "Text 3"});- Specified by:
hasTextin interfaceLocatorAssertions- Parameters:
strings- Expected string or RegExp or a list of those.
-
hasText
Description copied from interface:LocatorAssertionsEnsures theLocatorpoints to an element with the given text. You can use regular expressions for the value as well.**Usage**
assertThat(page.locator(".title")).hasText("Welcome, Test User"); assertThat(page.locator(".title")).hasText(Pattern.compile("Welcome, .*"));If you pass an array as an expected value, the expectations are:
- Locator resolves to a list of elements.
- The number of elements equals the number of expected values in the array.
- Elements from the list have text matching expected array values, one by one, in order.
For example, consider the following list:
Let's see how we can use the assertion:
// ✓ Has the right items in the right order assertThat(page.locator("ul > li")).hasText(new String[] {"Text 1", "Text 2", "Text 3"}); // ✖ Wrong order assertThat(page.locator("ul > li")).hasText(new String[] {"Text 3", "Text 2", "Text 1"}); // ✖ Last item does not match assertThat(page.locator("ul > li")).hasText(new String[] {"Text 1", "Text 2", "Text"}); // ✖ Locator points to the outer list element, not to the list items assertThat(page.locator("ul")).hasText(new String[] {"Text 1", "Text 2", "Text 3"});- Specified by:
hasTextin interfaceLocatorAssertions- Parameters:
patterns- Expected string or RegExp or a list of those.
-
hasValue
Description copied from interface:LocatorAssertionsEnsures theLocatorpoints to an element with the given input value. You can use regular expressions for the value as well.**Usage**
assertThat(page.locator("input[type=number]")).hasValue(Pattern.compile("[0-9]"));- Specified by:
hasValuein interfaceLocatorAssertions- Parameters:
value- Expected value.
-
hasValue
Description copied from interface:LocatorAssertionsEnsures theLocatorpoints to an element with the given input value. You can use regular expressions for the value as well.**Usage**
assertThat(page.locator("input[type=number]")).hasValue(Pattern.compile("[0-9]"));- Specified by:
hasValuein interfaceLocatorAssertions- Parameters:
pattern- Expected value.
-
hasValues
Description copied from interface:LocatorAssertionsEnsures theLocatorpoints to multi-select/combobox (i.e. aselectwith themultipleattribute) and the specified values are selected.**Usage**
For example, given the following element:
page.locator("id=favorite-colors").selectOption(["R", "G"]); assertThat(page.locator("id=favorite-colors")).hasValues(new Pattern[] { Pattern.compile("R"), Pattern.compile("G") });- Specified by:
hasValuesin interfaceLocatorAssertions- Parameters:
values- Expected options currently selected.
-
hasValues
Description copied from interface:LocatorAssertionsEnsures theLocatorpoints to multi-select/combobox (i.e. aselectwith themultipleattribute) and the specified values are selected.**Usage**
For example, given the following element:
page.locator("id=favorite-colors").selectOption(["R", "G"]); assertThat(page.locator("id=favorite-colors")).hasValues(new Pattern[] { Pattern.compile("R"), Pattern.compile("G") });- Specified by:
hasValuesin interfaceLocatorAssertions- Parameters:
patterns- Expected options currently selected.
-
isChecked
Description copied from interface:LocatorAssertionsEnsures theLocatorpoints to a checked input.**Usage**
assertThat(page.getByLabel("Subscribe to newsletter")).isChecked();- Specified by:
isCheckedin interfaceLocatorAssertions
-
isDisabled
Description copied from interface:LocatorAssertionsEnsures theLocatorpoints to a disabled element. Element is disabled if it has "disabled" attribute or is disabled via 'aria-disabled'. Note that only native control elements such as HTMLbutton,input,select,textarea,option,optgroupcan be disabled by setting "disabled" attribute. "disabled" attribute on other elements is ignored by the browser.**Usage**
assertThat(page.locator("button.submit")).isDisabled();- Specified by:
isDisabledin interfaceLocatorAssertions
-
isEditable
Description copied from interface:LocatorAssertionsEnsures theLocatorpoints to an editable element.**Usage**
assertThat(page.getByRole(AriaRole.TEXTBOX)).isEditable();- Specified by:
isEditablein interfaceLocatorAssertions
-
isEmpty
Description copied from interface:LocatorAssertionsEnsures theLocatorpoints to an empty editable element or to a DOM node that has no text.**Usage**
assertThat(page.locator("div.warning")).isEmpty();- Specified by:
isEmptyin interfaceLocatorAssertions
-
isEnabled
Description copied from interface:LocatorAssertionsEnsures theLocatorpoints to an enabled element.**Usage**
assertThat(page.locator("button.submit")).isEnabled();- Specified by:
isEnabledin interfaceLocatorAssertions
-
isFocused
Description copied from interface:LocatorAssertionsEnsures theLocatorpoints to a focused DOM node.**Usage**
assertThat(page.getByRole(AriaRole.TEXTBOX)).isFocused();- Specified by:
isFocusedin interfaceLocatorAssertions
-
isHidden
Description copied from interface:LocatorAssertionsEnsures thatLocatoreither does not resolve to any DOM node, or resolves to a non-visible one.**Usage**
assertThat(page.locator(".my-element")).isHidden();- Specified by:
isHiddenin interfaceLocatorAssertions
-
isInViewport
Description copied from interface:LocatorAssertionsEnsures theLocatorpoints to an element that intersects viewport, according to the intersection observer API.**Usage**
Locator locator = page.getByRole(AriaRole.BUTTON); // Make sure at least some part of element intersects viewport. assertThat(locator).isInViewport(); // Make sure element is fully outside of viewport. assertThat(locator).not().isInViewport(); // Make sure that at least half of the element intersects viewport. assertThat(locator).isInViewport(new LocatorAssertions.IsInViewportOptions().setRatio(0.5));- Specified by:
isInViewportin interfaceLocatorAssertions
-
isVisible
Description copied from interface:LocatorAssertionsEnsures thatLocatorpoints to an attached and visible DOM node.To check that at least one element from the list is visible, use
.invalid reference
Locator.first()**Usage**
// A specific element is visible. assertThat(page.getByText("Welcome")).isVisible(); // At least one item in the list is visible. asserThat(page.getByTestId("todo-item").first()).isVisible(); // At least one of the two elements is visible, possibly both. asserThat( page.getByRole(AriaRole.BUTTON, new Page.GetByRoleOptions().setName("Sign in")) .or(page.getByRole(AriaRole.BUTTON, new Page.GetByRoleOptions().setName("Sign up"))) .first() ).isVisible();- Specified by:
isVisiblein interfaceLocatorAssertions
-
expectTrue
-
not
Description copied from interface:LocatorAssertionsMakes the assertion check for the opposite condition. For example, this code tests that the Locator doesn't contain text"error":assertThat(locator).not().containsText("error");- Specified by:
notin interfaceLocatorAssertions
-
isAttached
Description copied from interface:LocatorAssertionsEnsures thatLocatorpoints to an attached DOM node.**Usage**
assertThat(page.getByText("Hidden text")).isAttached();- Specified by:
isAttachedin interfaceLocatorAssertions
-
shouldIgnoreCase
-