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 aPage
object.columnName
- A column from which value is project to the result.queryTerms
- Condition terms to select rows in a table.normalizer
- ABinaryOperator
to 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 class
A builder class forTableQuery
.static final record
A 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 aTableQuery
record class. -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of thecolumnName
record component.final boolean
Indicates whether some other object is "equal to" this one.final int
hashCode()
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 thenormalizer
record component.List
<com.microsoft.playwright.Locator> perform
(com.microsoft.playwright.Page page) Performs the query on the givenpage
.Returns the value of thequeryTerms
record component.static TableQuery.Builder
A method from which you can start building a query.Returns the value of thetableName
record component.toString()
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 aTableQuery
record class.- Parameters:
tableName
- the value for thetableName
record componentcolumnName
- the value for thecolumnName
record componentqueryTerms
- the value for thequeryTerms
record componentnormalizer
- the value for thenormalizer
record component
-
-
Method Details
-
toString
-
select
A method from which you can start building a query. ABuilder
class object, which holdscolumnName
as 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
.
-
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 thecolumnName
record component.- Returns:
- the value of the
columnName
record component
-
queryTerms
Returns the value of thequeryTerms
record component.- Returns:
- the value of the
queryTerms
record component
-
normalizer
public BiFunction<List<com.microsoft.playwright.Locator>, List<com.microsoft.playwright.Locator>, List<com.microsoft.playwright.Locator>> normalizer()Returns the value of thenormalizer
record component.- Returns:
- the value of the
normalizer
record component
-