Unable to locate element by div class





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







0















Trying to check if the element set focus to using class header matching by text and getting error unable to locate the element. I know the header title which is 'My Details' in this example, and using this title, how to locate the element?



<div class="attribute-group-header card__header">
<h3 class="attribute-group-title card__header-title">My Details</h3>
</div>


Element should be focused //div[contains(.,'My Details')









share|improve this question























  • you may try: $(".attribute-group-header card__header .attribute-group-title card__header-title")

    – user10068329
    Nov 17 '18 at 3:24











  • Nguyen - did you mean to replace the dot inside the contains with this? Didn't work though, same error

    – Sarah
    Nov 17 '18 at 3:44











  • What @AnNguyen has given you in the comment is a css selector - e.g. if you try it, the locator should be css:.attribute-group-header card__header .attribute-group-title card__header-title. Have in mind though class selectors tend to return multiple results (a lot of elements in the page may have the same classes).

    – Todor Minakov
    Nov 17 '18 at 6:42











  • @Sarah what exactly is the problem now? The title of the question is how to locate through a class, you continue the element is not located through it, and tried with its text; the xpath in the locator looks ok, it should match the element. So what issue are you having - the element is still not located with it, or the kw Element should be focused is failing as it is not in focus? Please edit your question so its clearer what's the problem you're facing.

    – Todor Minakov
    Nov 17 '18 at 6:47













  • Thanks for the explanation Todor. You were right, with the css selector my test returned multiple objects, that was the reason I was trying to locate the element by its text.

    – Sarah
    Nov 17 '18 at 11:34


















0















Trying to check if the element set focus to using class header matching by text and getting error unable to locate the element. I know the header title which is 'My Details' in this example, and using this title, how to locate the element?



<div class="attribute-group-header card__header">
<h3 class="attribute-group-title card__header-title">My Details</h3>
</div>


Element should be focused //div[contains(.,'My Details')









share|improve this question























  • you may try: $(".attribute-group-header card__header .attribute-group-title card__header-title")

    – user10068329
    Nov 17 '18 at 3:24











  • Nguyen - did you mean to replace the dot inside the contains with this? Didn't work though, same error

    – Sarah
    Nov 17 '18 at 3:44











  • What @AnNguyen has given you in the comment is a css selector - e.g. if you try it, the locator should be css:.attribute-group-header card__header .attribute-group-title card__header-title. Have in mind though class selectors tend to return multiple results (a lot of elements in the page may have the same classes).

    – Todor Minakov
    Nov 17 '18 at 6:42











  • @Sarah what exactly is the problem now? The title of the question is how to locate through a class, you continue the element is not located through it, and tried with its text; the xpath in the locator looks ok, it should match the element. So what issue are you having - the element is still not located with it, or the kw Element should be focused is failing as it is not in focus? Please edit your question so its clearer what's the problem you're facing.

    – Todor Minakov
    Nov 17 '18 at 6:47













  • Thanks for the explanation Todor. You were right, with the css selector my test returned multiple objects, that was the reason I was trying to locate the element by its text.

    – Sarah
    Nov 17 '18 at 11:34














0












0








0








Trying to check if the element set focus to using class header matching by text and getting error unable to locate the element. I know the header title which is 'My Details' in this example, and using this title, how to locate the element?



<div class="attribute-group-header card__header">
<h3 class="attribute-group-title card__header-title">My Details</h3>
</div>


Element should be focused //div[contains(.,'My Details')









share|improve this question














Trying to check if the element set focus to using class header matching by text and getting error unable to locate the element. I know the header title which is 'My Details' in this example, and using this title, how to locate the element?



<div class="attribute-group-header card__header">
<h3 class="attribute-group-title card__header-title">My Details</h3>
</div>


Element should be focused //div[contains(.,'My Details')






robotframework selenium2library






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 17 '18 at 3:07









SarahSarah

376




376













  • you may try: $(".attribute-group-header card__header .attribute-group-title card__header-title")

    – user10068329
    Nov 17 '18 at 3:24











  • Nguyen - did you mean to replace the dot inside the contains with this? Didn't work though, same error

    – Sarah
    Nov 17 '18 at 3:44











  • What @AnNguyen has given you in the comment is a css selector - e.g. if you try it, the locator should be css:.attribute-group-header card__header .attribute-group-title card__header-title. Have in mind though class selectors tend to return multiple results (a lot of elements in the page may have the same classes).

    – Todor Minakov
    Nov 17 '18 at 6:42











  • @Sarah what exactly is the problem now? The title of the question is how to locate through a class, you continue the element is not located through it, and tried with its text; the xpath in the locator looks ok, it should match the element. So what issue are you having - the element is still not located with it, or the kw Element should be focused is failing as it is not in focus? Please edit your question so its clearer what's the problem you're facing.

    – Todor Minakov
    Nov 17 '18 at 6:47













  • Thanks for the explanation Todor. You were right, with the css selector my test returned multiple objects, that was the reason I was trying to locate the element by its text.

    – Sarah
    Nov 17 '18 at 11:34



















  • you may try: $(".attribute-group-header card__header .attribute-group-title card__header-title")

    – user10068329
    Nov 17 '18 at 3:24











  • Nguyen - did you mean to replace the dot inside the contains with this? Didn't work though, same error

    – Sarah
    Nov 17 '18 at 3:44











  • What @AnNguyen has given you in the comment is a css selector - e.g. if you try it, the locator should be css:.attribute-group-header card__header .attribute-group-title card__header-title. Have in mind though class selectors tend to return multiple results (a lot of elements in the page may have the same classes).

    – Todor Minakov
    Nov 17 '18 at 6:42











  • @Sarah what exactly is the problem now? The title of the question is how to locate through a class, you continue the element is not located through it, and tried with its text; the xpath in the locator looks ok, it should match the element. So what issue are you having - the element is still not located with it, or the kw Element should be focused is failing as it is not in focus? Please edit your question so its clearer what's the problem you're facing.

    – Todor Minakov
    Nov 17 '18 at 6:47













  • Thanks for the explanation Todor. You were right, with the css selector my test returned multiple objects, that was the reason I was trying to locate the element by its text.

    – Sarah
    Nov 17 '18 at 11:34

















you may try: $(".attribute-group-header card__header .attribute-group-title card__header-title")

– user10068329
Nov 17 '18 at 3:24





you may try: $(".attribute-group-header card__header .attribute-group-title card__header-title")

– user10068329
Nov 17 '18 at 3:24













Nguyen - did you mean to replace the dot inside the contains with this? Didn't work though, same error

– Sarah
Nov 17 '18 at 3:44





Nguyen - did you mean to replace the dot inside the contains with this? Didn't work though, same error

– Sarah
Nov 17 '18 at 3:44













What @AnNguyen has given you in the comment is a css selector - e.g. if you try it, the locator should be css:.attribute-group-header card__header .attribute-group-title card__header-title. Have in mind though class selectors tend to return multiple results (a lot of elements in the page may have the same classes).

– Todor Minakov
Nov 17 '18 at 6:42





What @AnNguyen has given you in the comment is a css selector - e.g. if you try it, the locator should be css:.attribute-group-header card__header .attribute-group-title card__header-title. Have in mind though class selectors tend to return multiple results (a lot of elements in the page may have the same classes).

– Todor Minakov
Nov 17 '18 at 6:42













@Sarah what exactly is the problem now? The title of the question is how to locate through a class, you continue the element is not located through it, and tried with its text; the xpath in the locator looks ok, it should match the element. So what issue are you having - the element is still not located with it, or the kw Element should be focused is failing as it is not in focus? Please edit your question so its clearer what's the problem you're facing.

– Todor Minakov
Nov 17 '18 at 6:47







@Sarah what exactly is the problem now? The title of the question is how to locate through a class, you continue the element is not located through it, and tried with its text; the xpath in the locator looks ok, it should match the element. So what issue are you having - the element is still not located with it, or the kw Element should be focused is failing as it is not in focus? Please edit your question so its clearer what's the problem you're facing.

– Todor Minakov
Nov 17 '18 at 6:47















Thanks for the explanation Todor. You were right, with the css selector my test returned multiple objects, that was the reason I was trying to locate the element by its text.

– Sarah
Nov 17 '18 at 11:34





Thanks for the explanation Todor. You were right, with the css selector my test returned multiple objects, that was the reason I was trying to locate the element by its text.

– Sarah
Nov 17 '18 at 11:34












2 Answers
2






active

oldest

votes


















2














To locate the h3 in your example code, use this xpath //h3[contains(text(),'My Details')]



To locate the div which has card__header in class, use this xpath //div[contains(@class,'card__header')]






share|improve this answer
























  • Thanh - Now with //h3[contains(text(),'My Details')] my element is located but I am getting error - Element is not set to focus. My test is trying to validate when user clicks on a side menu link the specific link is accessed on the Page. I can't seem to find the right keyword to validate that the user navigated to the link section. Do you have any suggestion?

    – Sarah
    Nov 17 '18 at 11:29



















0














It worked fine with this keyword and the X-path reference. Thank you all for guiding me to find the solution



 Element should be enabled     //h3[contains(text(),'${MyLinkText}')]





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%2f53347835%2funable-to-locate-element-by-div-class%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    2














    To locate the h3 in your example code, use this xpath //h3[contains(text(),'My Details')]



    To locate the div which has card__header in class, use this xpath //div[contains(@class,'card__header')]






    share|improve this answer
























    • Thanh - Now with //h3[contains(text(),'My Details')] my element is located but I am getting error - Element is not set to focus. My test is trying to validate when user clicks on a side menu link the specific link is accessed on the Page. I can't seem to find the right keyword to validate that the user navigated to the link section. Do you have any suggestion?

      – Sarah
      Nov 17 '18 at 11:29
















    2














    To locate the h3 in your example code, use this xpath //h3[contains(text(),'My Details')]



    To locate the div which has card__header in class, use this xpath //div[contains(@class,'card__header')]






    share|improve this answer
























    • Thanh - Now with //h3[contains(text(),'My Details')] my element is located but I am getting error - Element is not set to focus. My test is trying to validate when user clicks on a side menu link the specific link is accessed on the Page. I can't seem to find the right keyword to validate that the user navigated to the link section. Do you have any suggestion?

      – Sarah
      Nov 17 '18 at 11:29














    2












    2








    2







    To locate the h3 in your example code, use this xpath //h3[contains(text(),'My Details')]



    To locate the div which has card__header in class, use this xpath //div[contains(@class,'card__header')]






    share|improve this answer













    To locate the h3 in your example code, use this xpath //h3[contains(text(),'My Details')]



    To locate the div which has card__header in class, use this xpath //div[contains(@class,'card__header')]







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Nov 17 '18 at 10:46









    thanh lethanh le

    1796




    1796













    • Thanh - Now with //h3[contains(text(),'My Details')] my element is located but I am getting error - Element is not set to focus. My test is trying to validate when user clicks on a side menu link the specific link is accessed on the Page. I can't seem to find the right keyword to validate that the user navigated to the link section. Do you have any suggestion?

      – Sarah
      Nov 17 '18 at 11:29



















    • Thanh - Now with //h3[contains(text(),'My Details')] my element is located but I am getting error - Element is not set to focus. My test is trying to validate when user clicks on a side menu link the specific link is accessed on the Page. I can't seem to find the right keyword to validate that the user navigated to the link section. Do you have any suggestion?

      – Sarah
      Nov 17 '18 at 11:29

















    Thanh - Now with //h3[contains(text(),'My Details')] my element is located but I am getting error - Element is not set to focus. My test is trying to validate when user clicks on a side menu link the specific link is accessed on the Page. I can't seem to find the right keyword to validate that the user navigated to the link section. Do you have any suggestion?

    – Sarah
    Nov 17 '18 at 11:29





    Thanh - Now with //h3[contains(text(),'My Details')] my element is located but I am getting error - Element is not set to focus. My test is trying to validate when user clicks on a side menu link the specific link is accessed on the Page. I can't seem to find the right keyword to validate that the user navigated to the link section. Do you have any suggestion?

    – Sarah
    Nov 17 '18 at 11:29













    0














    It worked fine with this keyword and the X-path reference. Thank you all for guiding me to find the solution



     Element should be enabled     //h3[contains(text(),'${MyLinkText}')]





    share|improve this answer




























      0














      It worked fine with this keyword and the X-path reference. Thank you all for guiding me to find the solution



       Element should be enabled     //h3[contains(text(),'${MyLinkText}')]





      share|improve this answer


























        0












        0








        0







        It worked fine with this keyword and the X-path reference. Thank you all for guiding me to find the solution



         Element should be enabled     //h3[contains(text(),'${MyLinkText}')]





        share|improve this answer













        It worked fine with this keyword and the X-path reference. Thank you all for guiding me to find the solution



         Element should be enabled     //h3[contains(text(),'${MyLinkText}')]






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 17 '18 at 12:07









        SarahSarah

        376




        376






























            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%2f53347835%2funable-to-locate-element-by-div-class%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

            Bressuire

            Vorschmack

            Quarantine