1
0
mirror of https://github.com/MontFerret/ferret.git synced 2025-02-03 13:11:45 +02:00

Updated examples

This commit is contained in:
Tim Voronov 2019-07-23 14:55:26 -04:00
parent 14c487ca46
commit 996d565191
17 changed files with 23 additions and 21 deletions

View File

@ -37,7 +37,9 @@ Once the page gets loaded, we iterate over all elements in search results and as
The final for loop filters out empty elements that might be because of inaccurate use of selectors.
```aql
LET google = DOCUMENT("https://www.google.com/", true)
LET google = DOCUMENT("https://www.google.com/", {
driver: "cdp"
})
INPUT(google, 'input[name="q"]', "ferret", 25)
CLICK(google, 'input[name="btnK"]')
@ -180,7 +182,7 @@ Once ```ferret``` knows how to communicate with Chrome, you can use a function `
Welcome to Ferret REPL
Please use `exit` or `Ctrl-D` to exit this program.
>%
>LET doc = DOCUMENT('https://soundcloud.com/charts/top', true)
>LET doc = DOCUMENT('https://soundcloud.com/charts/top', { driver: "cdp" })
>WAIT_ELEMENT(doc, '.chartTrack__details', 5000)
>LET tracks = ELEMENTS(doc, '.chartTrack__details')
>FOR track IN tracks
@ -197,7 +199,7 @@ Please use `exit` or `Ctrl-D` to exit this program.
Welcome to Ferret REPL
Please use `exit` or `Ctrl-D` to exit this program.
>%
>LET doc = DOCUMENT("https://github.com/", true)
>LET doc = DOCUMENT("https://github.com/", { driver: "cdp" })
>LET btn = ELEMENT(doc, ".HeaderMenu a")
>CLICK(btn)

View File

@ -1,4 +1,4 @@
LET doc = DOCUMENT("https://github.com/", true)
LET doc = DOCUMENT("https://github.com/", { driver: "cdp" })
LET btn = ELEMENT(doc, ".HeaderMenu a")
CLICK(btn)

3
examples/download.fql Normal file
View File

@ -0,0 +1,3 @@
LET data = DOWNLOAD("https://github.com/MontFerret/ferret/raw/master/assets/logo.png")
RETURN { type: "png", data }

View File

@ -1,4 +1,4 @@
LET doc = DOCUMENT('https://soundcloud.com/charts/top', true)
LET doc = DOCUMENT('https://soundcloud.com/charts/top', { driver: "cdp" })
WAIT_ELEMENT(doc, '.chartTrack__details', 5000)

View File

@ -1,4 +1,4 @@
LET doc = DOCUMENT('https://soundcloud.com/charts/top', true)
LET doc = DOCUMENT('https://soundcloud.com/charts/top', { driver: "cdp" })
WAIT_ELEMENT(doc, '.chartTrack__details', 5000)

View File

@ -1,4 +1,4 @@
LET google = DOCUMENT("https://www.google.com/", true)
LET google = DOCUMENT("https://www.google.com/", { driver: "cdp" })
INPUT(google, 'input[name="q"]', "ferret", 25)
CLICK(google, 'input[name="btnK"]')

View File

@ -1,4 +1,4 @@
LET doc = DOCUMENT("https://github.com/", true)
LET doc = DOCUMENT("https://github.com/", { driver: "cdp" })
LET main = ELEMENT(doc, '.application-main')
LET mainTxt = main.innerText

View File

@ -1,5 +1,5 @@
LET origin = "https://github.com/"
LET doc = DOCUMENT(origin, true)
LET doc = DOCUMENT(origin, { driver: "cdp" })
NAVIGATE(doc, "https://github.com/features")
NAVIGATE_BACK(doc)

View File

@ -1,5 +1,5 @@
LET origin = "https://github.com/"
LET doc = DOCUMENT(origin, true)
LET doc = DOCUMENT(origin, { driver: "cdp" })
NAVIGATE(doc, "https://github.com/features")
NAVIGATE(doc, "https://github.com/business")

View File

@ -1,6 +1,6 @@
LET origin = "https://github.com/"
LET target = "https://github.com/features"
LET doc = DOCUMENT(origin, true)
LET doc = DOCUMENT(origin, { driver: "cdp" })
NAVIGATE(doc, target)
NAVIGATE_BACK(doc)

View File

@ -1,4 +1,4 @@
LET doc = DOCUMENT("https://github.com/", true)
LET doc = DOCUMENT("https://github.com/", { driver: "cdp" })
NAVIGATE(doc, "https://github.com/features")
NAVIGATE(doc, "https://github.com/enterprise")

View File

@ -1,4 +1,4 @@
LET amazon = DOCUMENT('https://www.amazon.com/', true)
LET amazon = DOCUMENT('https://www.amazon.com/', { driver: "cdp" })
INPUT(amazon, '#twotabsearchtextbox', @criteria)
CLICK(amazon, '.nav-search-submit input[type="submit"]')
@ -17,7 +17,7 @@ LET pages = LENGTH(pagers) > 0 ? TO_INT(INNER_TEXT(LAST(pagers))) : 0
LET result = (
FOR pageNum IN 1..pages
LET clicked = pageNum == 1 ? false : CLICK(amazon, nextBtnSelector)
LET wait = clicked ? WAIT_NAVIGATION(amazon) : false
LET wait = ELEMENT_EXISTS(amazon, nextBtnSelector) ? WAIT_NAVIGATION(amazon) : false
LET waitSelector = wait ? WAIT_ELEMENT(amazon, resultListSelector) : false
PRINT("page:", pageNum, "clicked", clicked)

View File

@ -1,4 +1,4 @@
LET amazon = DOCUMENT('https://www.amazon.com/', true)
LET amazon = DOCUMENT('https://www.amazon.com/', { driver: "cdp" })
INPUT(amazon, '#twotabsearchtextbox', @criteria)
CLICK(amazon, '.nav-search-submit input[type="submit"]')

View File

@ -1,3 +0,0 @@
LET data = SCREENSHOT("https://github.com/MontFerret/ferret/raw/master/assets/logo.png")
RETURN { type: "png", data }

View File

@ -1,4 +1,4 @@
LET doc = DOCUMENT("https://www.yandex.com/search/?text=foobar", true)
LET doc = DOCUMENT("https://www.yandex.com/search/?text=foobar", { driver: "cdp" })
LET input = ELEMENT(doc, 'input[type="search"]')
RETURN input.value ? input.value : 'value not defined'

View File

@ -1,4 +1,4 @@
LET doc = DOCUMENT("http://getbootstrap.com/docs/4.1/components/collapse/", true)
LET doc = DOCUMENT("http://getbootstrap.com/docs/4.1/components/collapse/", { driver: "cdp" })
LET el = ELEMENT(doc, "#collapseTwo")
CLICK(doc, "#headingTwo > h5 > button")

View File

@ -1,4 +1,4 @@
LET doc = DOCUMENT("http://getbootstrap.com/docs/4.1/components/collapse/", true)
LET doc = DOCUMENT("http://getbootstrap.com/docs/4.1/components/collapse/", { driver: "cdp" })
CLICK(doc, "#headingTwo > h5 > button")
WAIT_CLASS(doc, "#collapseTwo", "show")