web UI test automation using etaoin and Clojure, how to fill/find relative elements?



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















In html page contains input tag and label tag, I locate label tag using its text and by using that I want to locate and fill out input tag.



e.g



<div class="el-form-item is-error is-required">
<label for="address.streetAddress.text" class="el-form-item__label">
Specify your shipping address
</label>
<div class="el-form-item__content">
<input type="text" autocomplete="off" required="required" placeholder="" class="el-input__inner">
</div>
</div>




From etaoin docs,



(query driver :fn/has-text "Specify your shipping address")


Above code gives me label element using which I want to fill out input value.



I don't know how other frameworks like selenium solves this problem.



Also I can't use any css attributes to look out for input tag.



Any help will be appreciated










share|improve this question






















  • If you can locate element by XPath then use //label[.="Specify your shipping address"]/following-sibling::div/input

    – Andersson
    Nov 16 '18 at 12:48











  • The easiest way would be to add either a unique ID or CSS class to the desired input element.

    – Alan Thompson
    Nov 16 '18 at 17:42

















0















In html page contains input tag and label tag, I locate label tag using its text and by using that I want to locate and fill out input tag.



e.g



<div class="el-form-item is-error is-required">
<label for="address.streetAddress.text" class="el-form-item__label">
Specify your shipping address
</label>
<div class="el-form-item__content">
<input type="text" autocomplete="off" required="required" placeholder="" class="el-input__inner">
</div>
</div>




From etaoin docs,



(query driver :fn/has-text "Specify your shipping address")


Above code gives me label element using which I want to fill out input value.



I don't know how other frameworks like selenium solves this problem.



Also I can't use any css attributes to look out for input tag.



Any help will be appreciated










share|improve this question






















  • If you can locate element by XPath then use //label[.="Specify your shipping address"]/following-sibling::div/input

    – Andersson
    Nov 16 '18 at 12:48











  • The easiest way would be to add either a unique ID or CSS class to the desired input element.

    – Alan Thompson
    Nov 16 '18 at 17:42













0












0








0








In html page contains input tag and label tag, I locate label tag using its text and by using that I want to locate and fill out input tag.



e.g



<div class="el-form-item is-error is-required">
<label for="address.streetAddress.text" class="el-form-item__label">
Specify your shipping address
</label>
<div class="el-form-item__content">
<input type="text" autocomplete="off" required="required" placeholder="" class="el-input__inner">
</div>
</div>




From etaoin docs,



(query driver :fn/has-text "Specify your shipping address")


Above code gives me label element using which I want to fill out input value.



I don't know how other frameworks like selenium solves this problem.



Also I can't use any css attributes to look out for input tag.



Any help will be appreciated










share|improve this question














In html page contains input tag and label tag, I locate label tag using its text and by using that I want to locate and fill out input tag.



e.g



<div class="el-form-item is-error is-required">
<label for="address.streetAddress.text" class="el-form-item__label">
Specify your shipping address
</label>
<div class="el-form-item__content">
<input type="text" autocomplete="off" required="required" placeholder="" class="el-input__inner">
</div>
</div>




From etaoin docs,



(query driver :fn/has-text "Specify your shipping address")


Above code gives me label element using which I want to fill out input value.



I don't know how other frameworks like selenium solves this problem.



Also I can't use any css attributes to look out for input tag.



Any help will be appreciated







selenium clojure automation automated-tests






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 16 '18 at 12:44









anishanish

4613822




4613822












  • If you can locate element by XPath then use //label[.="Specify your shipping address"]/following-sibling::div/input

    – Andersson
    Nov 16 '18 at 12:48











  • The easiest way would be to add either a unique ID or CSS class to the desired input element.

    – Alan Thompson
    Nov 16 '18 at 17:42

















  • If you can locate element by XPath then use //label[.="Specify your shipping address"]/following-sibling::div/input

    – Andersson
    Nov 16 '18 at 12:48











  • The easiest way would be to add either a unique ID or CSS class to the desired input element.

    – Alan Thompson
    Nov 16 '18 at 17:42
















If you can locate element by XPath then use //label[.="Specify your shipping address"]/following-sibling::div/input

– Andersson
Nov 16 '18 at 12:48





If you can locate element by XPath then use //label[.="Specify your shipping address"]/following-sibling::div/input

– Andersson
Nov 16 '18 at 12:48













The easiest way would be to add either a unique ID or CSS class to the desired input element.

– Alan Thompson
Nov 16 '18 at 17:42





The easiest way would be to add either a unique ID or CSS class to the desired input element.

– Alan Thompson
Nov 16 '18 at 17:42












1 Answer
1






active

oldest

votes


















-1














I don't know how to do this in etaoin, but use can use the Forest library to manipulate plain hiccup/html if that will help.



(with-debug-hid
(with-forest (new-forest)
(let [root-hid (add-tree-hiccup
[:div :class :some-div-1
[:div :class :some-div-2
[:label "Some Junk"]
[:div :class :some-div-3
[:label "Specify your shipping address"]
[:div :class :some-div-4
[:input :type "text" :autocomplete "off" :required "required"
:placeholder "" :class "el-input__inner"]]]]])


We want to find the :input node in the same :div as the :label node with text "Specify your shipping address". We then find its parent, and use the parent as the beginning of a new search for the desired :input node:



label-path (only (find-paths root-hid [:** :tag :label :value "Specify your shipping address"]))
parent-div-hid (-> label-path reverse second)
shipping-address-input-hid (find-hid parent-div-hid [:div :div :input])


Unit test show it working:



(is= label-path [:0006 :0005 :0004 :0001])
(is= parent-div-hid :0004)
(is= (hid->hiccup shipping-address-input-hid)
[:input :type "text", :autocomplete "off", :required "required",
:placeholder "", :class "el-input__inner"])
(value-set shipping-address-input-hid "1234 Main St")
(is= (hid->hiccup shipping-address-input-hid)
[:input :type "text", :autocomplete "off", :required "required",
:placeholder "", :class "el-input__inner"
"1234 Main St"])


We can output the final modified tree:



(hid->hiccup root-hid) =>
[:div
:class :some-div-1
[:div
:class :some-div-2
[:label "Some Junk"]
[:div
:class :some-div-3
[:label "Specify your shipping address"]
[:div
:class :some-div-4
[:input
:type "text",
:autocomplete "off",
:required "required",
:placeholder "",
:class "el-input__inner"
"1234 Main St"]]]]]


You can also see a lightning talk from Clojure Conj 2017.






share|improve this answer

























    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53338190%2fweb-ui-test-automation-using-etaoin-and-clojure-how-to-fill-find-relative-eleme%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    -1














    I don't know how to do this in etaoin, but use can use the Forest library to manipulate plain hiccup/html if that will help.



    (with-debug-hid
    (with-forest (new-forest)
    (let [root-hid (add-tree-hiccup
    [:div :class :some-div-1
    [:div :class :some-div-2
    [:label "Some Junk"]
    [:div :class :some-div-3
    [:label "Specify your shipping address"]
    [:div :class :some-div-4
    [:input :type "text" :autocomplete "off" :required "required"
    :placeholder "" :class "el-input__inner"]]]]])


    We want to find the :input node in the same :div as the :label node with text "Specify your shipping address". We then find its parent, and use the parent as the beginning of a new search for the desired :input node:



    label-path (only (find-paths root-hid [:** :tag :label :value "Specify your shipping address"]))
    parent-div-hid (-> label-path reverse second)
    shipping-address-input-hid (find-hid parent-div-hid [:div :div :input])


    Unit test show it working:



    (is= label-path [:0006 :0005 :0004 :0001])
    (is= parent-div-hid :0004)
    (is= (hid->hiccup shipping-address-input-hid)
    [:input :type "text", :autocomplete "off", :required "required",
    :placeholder "", :class "el-input__inner"])
    (value-set shipping-address-input-hid "1234 Main St")
    (is= (hid->hiccup shipping-address-input-hid)
    [:input :type "text", :autocomplete "off", :required "required",
    :placeholder "", :class "el-input__inner"
    "1234 Main St"])


    We can output the final modified tree:



    (hid->hiccup root-hid) =>
    [:div
    :class :some-div-1
    [:div
    :class :some-div-2
    [:label "Some Junk"]
    [:div
    :class :some-div-3
    [:label "Specify your shipping address"]
    [:div
    :class :some-div-4
    [:input
    :type "text",
    :autocomplete "off",
    :required "required",
    :placeholder "",
    :class "el-input__inner"
    "1234 Main St"]]]]]


    You can also see a lightning talk from Clojure Conj 2017.






    share|improve this answer





























      -1














      I don't know how to do this in etaoin, but use can use the Forest library to manipulate plain hiccup/html if that will help.



      (with-debug-hid
      (with-forest (new-forest)
      (let [root-hid (add-tree-hiccup
      [:div :class :some-div-1
      [:div :class :some-div-2
      [:label "Some Junk"]
      [:div :class :some-div-3
      [:label "Specify your shipping address"]
      [:div :class :some-div-4
      [:input :type "text" :autocomplete "off" :required "required"
      :placeholder "" :class "el-input__inner"]]]]])


      We want to find the :input node in the same :div as the :label node with text "Specify your shipping address". We then find its parent, and use the parent as the beginning of a new search for the desired :input node:



      label-path (only (find-paths root-hid [:** :tag :label :value "Specify your shipping address"]))
      parent-div-hid (-> label-path reverse second)
      shipping-address-input-hid (find-hid parent-div-hid [:div :div :input])


      Unit test show it working:



      (is= label-path [:0006 :0005 :0004 :0001])
      (is= parent-div-hid :0004)
      (is= (hid->hiccup shipping-address-input-hid)
      [:input :type "text", :autocomplete "off", :required "required",
      :placeholder "", :class "el-input__inner"])
      (value-set shipping-address-input-hid "1234 Main St")
      (is= (hid->hiccup shipping-address-input-hid)
      [:input :type "text", :autocomplete "off", :required "required",
      :placeholder "", :class "el-input__inner"
      "1234 Main St"])


      We can output the final modified tree:



      (hid->hiccup root-hid) =>
      [:div
      :class :some-div-1
      [:div
      :class :some-div-2
      [:label "Some Junk"]
      [:div
      :class :some-div-3
      [:label "Specify your shipping address"]
      [:div
      :class :some-div-4
      [:input
      :type "text",
      :autocomplete "off",
      :required "required",
      :placeholder "",
      :class "el-input__inner"
      "1234 Main St"]]]]]


      You can also see a lightning talk from Clojure Conj 2017.






      share|improve this answer



























        -1












        -1








        -1







        I don't know how to do this in etaoin, but use can use the Forest library to manipulate plain hiccup/html if that will help.



        (with-debug-hid
        (with-forest (new-forest)
        (let [root-hid (add-tree-hiccup
        [:div :class :some-div-1
        [:div :class :some-div-2
        [:label "Some Junk"]
        [:div :class :some-div-3
        [:label "Specify your shipping address"]
        [:div :class :some-div-4
        [:input :type "text" :autocomplete "off" :required "required"
        :placeholder "" :class "el-input__inner"]]]]])


        We want to find the :input node in the same :div as the :label node with text "Specify your shipping address". We then find its parent, and use the parent as the beginning of a new search for the desired :input node:



        label-path (only (find-paths root-hid [:** :tag :label :value "Specify your shipping address"]))
        parent-div-hid (-> label-path reverse second)
        shipping-address-input-hid (find-hid parent-div-hid [:div :div :input])


        Unit test show it working:



        (is= label-path [:0006 :0005 :0004 :0001])
        (is= parent-div-hid :0004)
        (is= (hid->hiccup shipping-address-input-hid)
        [:input :type "text", :autocomplete "off", :required "required",
        :placeholder "", :class "el-input__inner"])
        (value-set shipping-address-input-hid "1234 Main St")
        (is= (hid->hiccup shipping-address-input-hid)
        [:input :type "text", :autocomplete "off", :required "required",
        :placeholder "", :class "el-input__inner"
        "1234 Main St"])


        We can output the final modified tree:



        (hid->hiccup root-hid) =>
        [:div
        :class :some-div-1
        [:div
        :class :some-div-2
        [:label "Some Junk"]
        [:div
        :class :some-div-3
        [:label "Specify your shipping address"]
        [:div
        :class :some-div-4
        [:input
        :type "text",
        :autocomplete "off",
        :required "required",
        :placeholder "",
        :class "el-input__inner"
        "1234 Main St"]]]]]


        You can also see a lightning talk from Clojure Conj 2017.






        share|improve this answer















        I don't know how to do this in etaoin, but use can use the Forest library to manipulate plain hiccup/html if that will help.



        (with-debug-hid
        (with-forest (new-forest)
        (let [root-hid (add-tree-hiccup
        [:div :class :some-div-1
        [:div :class :some-div-2
        [:label "Some Junk"]
        [:div :class :some-div-3
        [:label "Specify your shipping address"]
        [:div :class :some-div-4
        [:input :type "text" :autocomplete "off" :required "required"
        :placeholder "" :class "el-input__inner"]]]]])


        We want to find the :input node in the same :div as the :label node with text "Specify your shipping address". We then find its parent, and use the parent as the beginning of a new search for the desired :input node:



        label-path (only (find-paths root-hid [:** :tag :label :value "Specify your shipping address"]))
        parent-div-hid (-> label-path reverse second)
        shipping-address-input-hid (find-hid parent-div-hid [:div :div :input])


        Unit test show it working:



        (is= label-path [:0006 :0005 :0004 :0001])
        (is= parent-div-hid :0004)
        (is= (hid->hiccup shipping-address-input-hid)
        [:input :type "text", :autocomplete "off", :required "required",
        :placeholder "", :class "el-input__inner"])
        (value-set shipping-address-input-hid "1234 Main St")
        (is= (hid->hiccup shipping-address-input-hid)
        [:input :type "text", :autocomplete "off", :required "required",
        :placeholder "", :class "el-input__inner"
        "1234 Main St"])


        We can output the final modified tree:



        (hid->hiccup root-hid) =>
        [:div
        :class :some-div-1
        [:div
        :class :some-div-2
        [:label "Some Junk"]
        [:div
        :class :some-div-3
        [:label "Specify your shipping address"]
        [:div
        :class :some-div-4
        [:input
        :type "text",
        :autocomplete "off",
        :required "required",
        :placeholder "",
        :class "el-input__inner"
        "1234 Main St"]]]]]


        You can also see a lightning talk from Clojure Conj 2017.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Nov 17 '18 at 23:30

























        answered Nov 16 '18 at 17:47









        Alan ThompsonAlan Thompson

        14.4k22534




        14.4k22534





























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53338190%2fweb-ui-test-automation-using-etaoin-and-clojure-how-to-fill-find-relative-eleme%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Top Tejano songwriter Luis Silva dead of heart attack at 64

            ReactJS Fetched API data displays live - need Data displayed static

            政党