Record Class TableQuery
java.lang.Object
java.lang.Record
jp.co.moneyforward.autotest.actions.web.TableQuery
- Record Components:
tableName- A locator string to specify a table within aPageobject.columnName- A column from which value is project to the result.queryTerms- Condition terms to select rows in a table.normalizer- ABinaryOperatorto normalize an incomplete row.
public record TableQuery(String tableName, String columnName, List<TableQuery.Term> queryTerms, BiFunction<List<com.microsoft.playwright.Locator>, List<com.microsoft.playwright.Locator>, List<com.microsoft.playwright.Locator>> normalizer)
extends Record
A class to query HTML table object as if it were an SQL relation. Note that this class is designed to select only one column.
void example() {
try (Playwright playwright = Playwright.create()) {
BrowserType chromium = playwright.chromium();
try (Browser browser = chromium.launch(new BrowserType.LaunchOptions().setHeadless(false))) {
Page page = browser.newPage();
page.navigate(testTableResourcePath());
//#js-ca-main-contents > table > thead
Locator l = TableQuery.select("事業者・年度の切替")
.from("body > table")
.where(term("事業者名", "abc-154206"))
.normalizeWith(normalizerFunction())
.build()
.perform(page)
.getFirst();
}
Limitation:
- The target HTML table must have unique headers (
th) for all columns. - Only "equal" condition is supported.
- Only conjunctions are supported.
In case you think these need to be improved, contact the development team of insdog.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classA builder class forTableQuery.static final recordA class that represents a term in a condition to select rows. -
Constructor Summary
ConstructorsConstructorDescriptionTableQuery(String tableName, String columnName, List<TableQuery.Term> queryTerms, BiFunction<List<com.microsoft.playwright.Locator>, List<com.microsoft.playwright.Locator>, List<com.microsoft.playwright.Locator>> normalizer) Creates an instance of aTableQueryrecord class. -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of thecolumnNamerecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.BiFunction<List<com.microsoft.playwright.Locator>, List<com.microsoft.playwright.Locator>, List<com.microsoft.playwright.Locator>> Returns the value of thenormalizerrecord component.List<com.microsoft.playwright.Locator> perform(com.microsoft.playwright.Page page) Performs the query on the givenpage.Returns the value of thequeryTermsrecord component.static TableQuery.BuilderA method from which you can start building a query.Returns the value of thetableNamerecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
TableQuery
public TableQuery(String tableName, String columnName, List<TableQuery.Term> queryTerms, BiFunction<List<com.microsoft.playwright.Locator>, List<com.microsoft.playwright.Locator>, List<com.microsoft.playwright.Locator>> normalizer) Creates an instance of aTableQueryrecord class.- Parameters:
tableName- the value for thetableNamerecord componentcolumnName- the value for thecolumnNamerecord componentqueryTerms- the value for thequeryTermsrecord componentnormalizer- the value for thenormalizerrecord component
-
-
Method Details
-
select
A method from which you can start building a query. ABuilderclass object, which holdscolumnNameas a column to project to the result will be returned.- Parameters:
columnName- A column to be projected into the result.- Returns:
- A builder object.
-
perform
Performs the query on the givenpage.- Parameters:
page- A page object on which this query will be performed.- Returns:
- A list of locators, each of whose enclosing row that satisfies the
terms.
-
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
tableName
-
columnName
Returns the value of thecolumnNamerecord component.- Returns:
- the value of the
columnNamerecord component
-
queryTerms
Returns the value of thequeryTermsrecord component.- Returns:
- the value of the
queryTermsrecord component
-
normalizer
public BiFunction<List<com.microsoft.playwright.Locator>, List<com.microsoft.playwright.Locator>, List<com.microsoft.playwright.Locator>> normalizer()Returns the value of thenormalizerrecord component.- Returns:
- the value of the
normalizerrecord component
-