Skip to content

Commit

Permalink
Updated examples
Browse files Browse the repository at this point in the history
  • Loading branch information
ziflex committed Jul 23, 2019
1 parent 14c487c commit 996d565
Show file tree
Hide file tree
Showing 17 changed files with 23 additions and 21 deletions.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"]')
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion examples/click.fql
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
3 changes: 3 additions & 0 deletions examples/download.fql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
LET data = DOWNLOAD("https://github.com/MontFerret/ferret/raw/master/assets/logo.png")

RETURN { type: "png", data }
2 changes: 1 addition & 1 deletion examples/dynamic-page.fql
Original file line number Diff line number Diff line change
@@ -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)

Expand Down
2 changes: 1 addition & 1 deletion examples/inner_text_all.fql
Original file line number Diff line number Diff line change
@@ -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)

Expand Down
2 changes: 1 addition & 1 deletion examples/input.fql
Original file line number Diff line number Diff line change
@@ -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"]')
Expand Down
2 changes: 1 addition & 1 deletion examples/navigate.fql
Original file line number Diff line number Diff line change
@@ -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

Expand Down
2 changes: 1 addition & 1 deletion examples/navigate_back.fql
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
2 changes: 1 addition & 1 deletion examples/navigate_back_2.fql
Original file line number Diff line number Diff line change
@@ -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")
Expand Down
2 changes: 1 addition & 1 deletion examples/navigate_forward.fql
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
2 changes: 1 addition & 1 deletion examples/navigate_forward_2.fql
Original file line number Diff line number Diff line change
@@ -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")
Expand Down
4 changes: 2 additions & 2 deletions examples/pagination.fql
Original file line number Diff line number Diff line change
@@ -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"]')
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion examples/pagination_uncontrolled.fql
Original file line number Diff line number Diff line change
@@ -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"]')
Expand Down
3 changes: 0 additions & 3 deletions examples/screenshot.fql

This file was deleted.

2 changes: 1 addition & 1 deletion examples/value.fql
Original file line number Diff line number Diff line change
@@ -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'
2 changes: 1 addition & 1 deletion examples/wait_class.fql
Original file line number Diff line number Diff line change
@@ -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")
Expand Down
2 changes: 1 addition & 1 deletion examples/wait_class_doc.fql
Original file line number Diff line number Diff line change
@@ -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")
Expand Down

0 comments on commit 996d565

Please sign in to comment.