mirror of
https://github.com/MontFerret/ferret.git
synced 2025-02-03 13:11:45 +02:00
Updated examples
This commit is contained in:
parent
14c487ca46
commit
996d565191
@ -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)
|
||||
|
@ -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
3
examples/download.fql
Normal file
@ -0,0 +1,3 @@
|
||||
LET data = DOWNLOAD("https://github.com/MontFerret/ferret/raw/master/assets/logo.png")
|
||||
|
||||
RETURN { type: "png", data }
|
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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"]')
|
||||
|
@ -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
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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")
|
||||
|
@ -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)
|
||||
|
@ -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")
|
||||
|
@ -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)
|
||||
|
@ -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"]')
|
||||
|
@ -1,3 +0,0 @@
|
||||
LET data = SCREENSHOT("https://github.com/MontFerret/ferret/raw/master/assets/logo.png")
|
||||
|
||||
RETURN { type: "png", data }
|
@ -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'
|
@ -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")
|
||||
|
@ -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")
|
||||
|
Loading…
x
Reference in New Issue
Block a user