How to Define main DIV if one of it childs consist of some text? Using c# & seleniumHow do I get a consistent byte representation of strings in C# without manually specifying an encoding?How to maximize the browser window in Selenium WebDriver (Selenium 2) using C#?How to select an option from drop down using Selenium WebDriver C#?How do I find an element that contains specific text in Selenium Webdriver (Python)?selenium InternetExporerDriver some elements click not consistently diringNullPointerException at initializing WebElements with @FindBy, using TestNG + Java + PageFactoryhow to get text present between html tags like <div>text</div> using selenium C#How to extract text from child Text Nodes - SeleniumCount some nodes by Selenium, using xpath. C#

Citing CPLEX 12.9

If I travelled back in time to invest in X company to make a fortune, roughly what is the probability that it would fail?

Job interview by video at home and privacy concerns

How do French and other Romance language speakers cope with the movable do system?

Why is there such a singular place for bird watching?

Realistically, how much do you need to start investing?

Generating numbers with cubes

How dangerous are my worn rims?

Why is music is taught by reading sheet music?

Duck, duck, gone!

Digital Bananas

How to say "respectively" in German when listing (enumerating) things

Everyone Gets a Window Seat

IEEE 754 square root with Newton-Raphson

What did the Federation give the Prophets in exchange for access to the wormhole in DS9?

Is it appropriate to "shop" through high-impact journals before sending the paper to more specialized journals?

Giving a good fancy look to a simple table

Rank-one positive decomposition for a entry-wise positive positive definite matrix

Is "weekend warrior" derogatory?

Lighthouse Alternatives

Did Joe Biden "stop a prosecution" into his son in Ukraine? And did he brag about stopping the prosecution?

Filter by pills/buttons instead of using a select - angular

Knights and Knaves: What does C say?

Can Fabled Passage generate two mana with Amulet of Vigor?



How to Define main DIV if one of it childs consist of some text? Using c# & selenium


How do I get a consistent byte representation of strings in C# without manually specifying an encoding?How to maximize the browser window in Selenium WebDriver (Selenium 2) using C#?How to select an option from drop down using Selenium WebDriver C#?How do I find an element that contains specific text in Selenium Webdriver (Python)?selenium InternetExporerDriver some elements click not consistently diringNullPointerException at initializing WebElements with @FindBy, using TestNG + Java + PageFactoryhow to get text present between html tags like <div>text</div> using selenium C#How to extract text from child Text Nodes - SeleniumCount some nodes by Selenium, using xpath. C#






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty
margin-bottom:0;









1















The main DIV consist of text in one of it's childs & consist of button i need to click if text is present. How can i define the main div to continue work with this if one of it's childs strictly consist of text i need?



Structure seems like:



<Div class="Green"> (Main Div i mentioned in description)
<Div class="Yel">
<Div class="Ora">
<Div class="Pur">
<span>text must be present</span>


I need to define main div , to proceed with this by findelement. then.










share|improve this question
























  • why you don't close div element <div> </div> ??

    – Muath
    Mar 28 at 21:23

















1















The main DIV consist of text in one of it's childs & consist of button i need to click if text is present. How can i define the main div to continue work with this if one of it's childs strictly consist of text i need?



Structure seems like:



<Div class="Green"> (Main Div i mentioned in description)
<Div class="Yel">
<Div class="Ora">
<Div class="Pur">
<span>text must be present</span>


I need to define main div , to proceed with this by findelement. then.










share|improve this question
























  • why you don't close div element <div> </div> ??

    – Muath
    Mar 28 at 21:23













1












1








1








The main DIV consist of text in one of it's childs & consist of button i need to click if text is present. How can i define the main div to continue work with this if one of it's childs strictly consist of text i need?



Structure seems like:



<Div class="Green"> (Main Div i mentioned in description)
<Div class="Yel">
<Div class="Ora">
<Div class="Pur">
<span>text must be present</span>


I need to define main div , to proceed with this by findelement. then.










share|improve this question














The main DIV consist of text in one of it's childs & consist of button i need to click if text is present. How can i define the main div to continue work with this if one of it's childs strictly consist of text i need?



Structure seems like:



<Div class="Green"> (Main Div i mentioned in description)
<Div class="Yel">
<Div class="Ora">
<Div class="Pur">
<span>text must be present</span>


I need to define main div , to proceed with this by findelement. then.







c# selenium-webdriver






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 28 at 21:17









GeorgeGeorge

13 bronze badges




13 bronze badges















  • why you don't close div element <div> </div> ??

    – Muath
    Mar 28 at 21:23

















  • why you don't close div element <div> </div> ??

    – Muath
    Mar 28 at 21:23
















why you don't close div element <div> </div> ??

– Muath
Mar 28 at 21:23





why you don't close div element <div> </div> ??

– Muath
Mar 28 at 21:23












1 Answer
1






active

oldest

votes


















0
















Have you tried the below.



Browser.FindElement(By.XPath("//div[@class='Green' and //span[normalize-space(.)='137']]//button[@class='needed_item']")).Click()


or



Browser.FindElement(By.XPath("//span[normalize-space(.)='137']/ancestor::div[@class='Green']//button[@class='needed_item']")).Click()


This xpath will first find the main div which have a span with 137 text. And then click on the button which have the class needed_item. Considered the below structure for the xpath.



<div @understand='main_div' @class='Green'>
<div @understand='child_div1'></div>
<div @understand='child_div2'>
<span @understand='target_span'> 137 </span>
</div>
<div @understand='child_div3></div>
<div @understand='div with button'>
<button @class='needed_item'>Target Button</button>
</div>
</div>


Let me know if there is any change in the structure.






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/4.0/"u003ecc by-sa 4.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%2f55406980%2fhow-to-define-main-div-if-one-of-it-childs-consist-of-some-text-using-c-sharp%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









    0
















    Have you tried the below.



    Browser.FindElement(By.XPath("//div[@class='Green' and //span[normalize-space(.)='137']]//button[@class='needed_item']")).Click()


    or



    Browser.FindElement(By.XPath("//span[normalize-space(.)='137']/ancestor::div[@class='Green']//button[@class='needed_item']")).Click()


    This xpath will first find the main div which have a span with 137 text. And then click on the button which have the class needed_item. Considered the below structure for the xpath.



    <div @understand='main_div' @class='Green'>
    <div @understand='child_div1'></div>
    <div @understand='child_div2'>
    <span @understand='target_span'> 137 </span>
    </div>
    <div @understand='child_div3></div>
    <div @understand='div with button'>
    <button @class='needed_item'>Target Button</button>
    </div>
    </div>


    Let me know if there is any change in the structure.






    share|improve this answer































      0
















      Have you tried the below.



      Browser.FindElement(By.XPath("//div[@class='Green' and //span[normalize-space(.)='137']]//button[@class='needed_item']")).Click()


      or



      Browser.FindElement(By.XPath("//span[normalize-space(.)='137']/ancestor::div[@class='Green']//button[@class='needed_item']")).Click()


      This xpath will first find the main div which have a span with 137 text. And then click on the button which have the class needed_item. Considered the below structure for the xpath.



      <div @understand='main_div' @class='Green'>
      <div @understand='child_div1'></div>
      <div @understand='child_div2'>
      <span @understand='target_span'> 137 </span>
      </div>
      <div @understand='child_div3></div>
      <div @understand='div with button'>
      <button @class='needed_item'>Target Button</button>
      </div>
      </div>


      Let me know if there is any change in the structure.






      share|improve this answer





























        0














        0










        0









        Have you tried the below.



        Browser.FindElement(By.XPath("//div[@class='Green' and //span[normalize-space(.)='137']]//button[@class='needed_item']")).Click()


        or



        Browser.FindElement(By.XPath("//span[normalize-space(.)='137']/ancestor::div[@class='Green']//button[@class='needed_item']")).Click()


        This xpath will first find the main div which have a span with 137 text. And then click on the button which have the class needed_item. Considered the below structure for the xpath.



        <div @understand='main_div' @class='Green'>
        <div @understand='child_div1'></div>
        <div @understand='child_div2'>
        <span @understand='target_span'> 137 </span>
        </div>
        <div @understand='child_div3></div>
        <div @understand='div with button'>
        <button @class='needed_item'>Target Button</button>
        </div>
        </div>


        Let me know if there is any change in the structure.






        share|improve this answer















        Have you tried the below.



        Browser.FindElement(By.XPath("//div[@class='Green' and //span[normalize-space(.)='137']]//button[@class='needed_item']")).Click()


        or



        Browser.FindElement(By.XPath("//span[normalize-space(.)='137']/ancestor::div[@class='Green']//button[@class='needed_item']")).Click()


        This xpath will first find the main div which have a span with 137 text. And then click on the button which have the class needed_item. Considered the below structure for the xpath.



        <div @understand='main_div' @class='Green'>
        <div @understand='child_div1'></div>
        <div @understand='child_div2'>
        <span @understand='target_span'> 137 </span>
        </div>
        <div @understand='child_div3></div>
        <div @understand='div with button'>
        <button @class='needed_item'>Target Button</button>
        </div>
        </div>


        Let me know if there is any change in the structure.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Mar 30 at 5:08

























        answered Mar 30 at 5:02









        supputurisupputuri

        7,0692 gold badges8 silver badges26 bronze badges




        7,0692 gold badges8 silver badges26 bronze badges

































            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%2f55406980%2fhow-to-define-main-div-if-one-of-it-childs-consist-of-some-text-using-c-sharp%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

            Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

            SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

            은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현