|
19 | 19 | (defn find-method [s]
|
20 | 20 | (str/replace (re-find #"^[^\(]+" s) #"^page\." ""))
|
21 | 21 |
|
| 22 | +(defn find-methods [s] |
| 23 | + (vec (drop 1 (str/split s #"\." )))) |
| 24 | + |
| 25 | +(defn swap-paren-position [s] |
| 26 | + (let [method-name (re-find #"^[^\(]+" s)] |
| 27 | + (-> (str "(." method-name " " (str/replace s (re-pattern (str"^" method-name "\\(")) "")) |
| 28 | + (str/replace #" \)" ")")))) |
| 29 | + |
22 | 30 | (defn parse-page-method [s]
|
23 | 31 | (if (str/starts-with? s "page")
|
24 |
| - (let [method (find-method s)] |
25 |
| - (-> s |
26 |
| - (str/replace (re-pattern (str "page." method "\\((.+)\\)")) "$1") |
27 |
| - js-quote->cl-string |
28 |
| - (as-> $ (clojure.pprint/cl-format nil "(.~A page ~A)" method $)))) |
| 32 | + (let [method (find-method s) |
| 33 | + methods (mapv (comp swap-paren-position js-quote->cl-string) (find-methods s))] |
| 34 | + |
| 35 | + (-> s |
| 36 | + (as-> $ (clojure.pprint/cl-format nil "(-> page ~A)" (str/join " " methods))))) |
29 | 37 | s))
|
30 | 38 |
|
31 | 39 | (defn expect-page-url? [s]
|
|
44 | 52 | (str/join "\n"))))
|
45 | 53 |
|
46 | 54 | (comment
|
47 |
| - (let [s "// Go to http://localhost:8000/ |
48 |
| - await page.goto('http://localhost:8000/'); |
49 |
| - // Click text=Wealth Management |
50 |
| - await page.click('text=Wealth Management'); |
51 |
| - // Click text=Swiss Francs CHF |
52 |
| - await page.click('text=Swiss Francs CHF'); |
53 |
| - // Click text=Performance CurrencyUS $Euro €Swiss Francs CHFFund Selection >> p |
54 |
| - await page.click('text=Performance CurrencyUS $Euro €Swiss Francs CHFFund Selection >> p'); |
55 |
| - await expect(page).toHaveURL('http://localhost:8000/#/funds'); |
56 |
| - // Click [aria-label=\"next page\"] |
57 |
| - await page.click('[aria-label=\"next page\"]'); |
58 |
| - // Click text=Vontobel Asia Pacific Equity |
59 |
| - await page.click('text=Vontobel Asia Pacific Equity'); |
60 |
| - await expect(page).toHaveURL('http://localhost:8000/#/fund/30102303100_1_10311111_1/overview'); |
61 |
| - // Click button[role=\"tab\"]:has-text(\"Insights\") |
62 |
| - await page.click('button[role=\"tab\"]:has-text(\"Insights\")'); |
63 |
| - await expect(page).toHaveURL('http://localhost:8000/#/fund/30102303100_1_10311111_1/insights'); |
64 |
| - // Click button[role=\"tab\"]:has-text(\"ESG\") |
65 |
| - await page.click('button[role=\"tab\"]:has-text(\"ESG\")'); |
66 |
| - await expect(page).toHaveURL('http://localhost:8000/#/fund/30102303100_1_10311111_1/esg'); |
67 |
| - // Click button[role=\"tab\"]:has-text(\"Risk\") |
68 |
| - await page.click('button[role=\"tab\"]:has-text(\"Risk\")'); |
69 |
| - await expect(page).toHaveURL('http://localhost:8000/#/fund/30102303100_1_10311111_1/analytics'); |
70 |
| - // Click button:has-text(\"Selection\") |
71 |
| - await page.click('button:has-text(\"Selection\")'); |
72 |
| - await expect(page).toHaveURL('http://localhost:8000/#/funds');"] |
73 |
| - (println (str/join "\n" (code->clj s)))) |
| 55 | + (let [s " |
| 56 | + await page.locator('button[role=\"tab\"]:has-text(\"Style\")').click(); |
| 57 | + await page.locator('button[role=\"tab\"]:has-text(\"Style\")').first().click(); |
| 58 | +"] |
| 59 | + #_(println (str/join "\n" (code->clj s))) |
| 60 | + (println (code->clj s)) |
| 61 | + ) |
| 62 | + |
74 | 63 | (clojure.pprint/cl-format nil "(.click page ~A)" "hello")
|
75 | 64 | (clojure.pprint/cl-format nil "(.~A page ~A)" "hello" "world"))
|
0 commit comments