mirror of
https://github.com/MontFerret/ferret.git
synced 2024-12-16 11:37:36 +02:00
2643321e0f
* Switched to Lab for e2e tests * Switched to binary * Updated lab installation * Updated use of Lab installer * updates * Changed lab installation path * Updated use of installer * Works * Added additional functions * Updated some tests * Updated go.sum * Works * Refactored assertions * Added tests for testing.True * Added tests for testing.None * Added tests for testing.Lte * Added tests for testing.Lt * Added generic consturctor * Added tests for testing.Len * Added tests for testing.Gte * Added tests for testing.Gt * Added tests for testing.False * Added tests for testing.Empty * Added tests for testing.Fail * Added tests for testing.Equal * Added tests for testing.Include * Updated urls in static page tests * Fixed namespace unit tests * Fixed unit test for testing.Len * Updated E2E scripts * Updaes * Updated Chrome in CI/CD * Added e2e for example test click.fql * Added suite cases for example scripts * Updated examples * Updated * Added type assertions * Updated Chrome opts and disabled headers and cookies related tests * Fixed iframes example * Increased timeouts in navigation examples * Updated value example * Updated comments * Disabled cookies examples * Fixed static url * Disabled headers examples * Disabled UA test * Simplified wait logic * Added base testing module * Fixes after codereview * Disabled failing tests
41 lines
1.5 KiB
Plaintext
41 lines
1.5 KiB
Plaintext
LET baseURL = 'https://www.amazon.com/'
|
|
LET amazon = DOCUMENT(baseURL, { driver: "cdp" })
|
|
|
|
INPUT(amazon, '#twotabsearchtextbox', @criteria)
|
|
CLICK(amazon, '.nav-search-submit input[type="submit"]')
|
|
WAIT_NAVIGATION(amazon)
|
|
|
|
LET resultListSelector = '#s-results-list-atf'
|
|
LET resultItemSelector = '[data-component-type="s-search-result"]'
|
|
LET nextBtnSelector = 'ul.a-pagination .a-last a'
|
|
LET priceWholeSelector = '.a-price-whole'
|
|
LET priceFracSelector = '.a-price-fraction'
|
|
|
|
LET result = (
|
|
FOR pageNum IN PAGINATION(amazon, nextBtnSelector)
|
|
LIMIT @pages
|
|
|
|
LET wait = pageNum > 0 ? WAIT_NAVIGATION(amazon, 20000) : false
|
|
LET waitSelector = wait ? WAIT_ELEMENT(amazon, resultListSelector) : false
|
|
|
|
LET items = (
|
|
FOR el IN ELEMENTS(amazon, resultItemSelector)
|
|
LET hasPrice = ELEMENT_EXISTS(el, priceWholeSelector)
|
|
LET priceWholeTxt = hasPrice ? FIRST(REGEX_MATCH(INNER_TEXT(el, priceWholeSelector), "[0-9]+")) : "0"
|
|
LET priceFracTxt = hasPrice ? FIRST(REGEX_MATCH(INNER_TEXT(el, priceFracSelector), "[0-9]+")) : "00"
|
|
LET price = TO_FLOAT(priceWholeTxt + "." + priceFracTxt)
|
|
LET anchor = ELEMENT(el, "a")
|
|
|
|
PRINT(priceWholeTxt, priceFracTxt)
|
|
|
|
RETURN {
|
|
url: baseURL + anchor.attributes.href,
|
|
title: INNER_TEXT(el, 'h2'),
|
|
price
|
|
}
|
|
)
|
|
|
|
RETURN items
|
|
)
|
|
|
|
RETURN FLATTEN(result) |