How to populate field fields that have the same class

I am testing a site form with clj-webdriver. I want to know how to use a function (input-text)if the form fields have the same class.

From the definition, (input-text)he gives "Enter a string sin the first form element found with the request q." Since each field has the same class and when I give,

(input-text ".class")

It fills only the first field. Is there a way to differentiate all fields with one class?

Form fields have only classand typeas selectors.

thank

+4
source share
2 answers

input-text fills only the first match.

quick-fill, .

,:.

(quick-fill {".class" "s"})

/

: " 2 3. " - ", ".object ". , , , .

, find-elements. :

(find-elements {:class ".class"})

".class", .

, input-text . , , map-indexed, (doall - , , doall ):

(defn fill!
  "Fills all elements with class class with increasing numbers."
  [class]
  (let [elements (find-elements {:class class})]
    (doall
     (map-indexed (fn [index element]
                    (input-text element (str index)))
                  elements))))

(fill! ".class").

, .

+3

(find-elements [webelement by]), "webelements matching a given by`.

, https://github.com/semperos/clj-webdriver/wiki/Introduction%3A-Taxi, :


(defn css-finder
  "Given a CSS query `q`, return a lazy seq of the elements found by calling `find-elements` with `by-css`. If `q` is an `Element`, it is returned unchanged."
  [q]
  (if (element? q)
    q
    (core/find-elements *driver* {:css q})))
0

Source: https://habr.com/ru/post/1657807/


All Articles