How to get row number, such that row should contains a specific text in protractor












0















I am using protractor-cucumber framework.I need to click on a 'td' element in a row of a table.Among the all table rows, i am deciding to click on a row, such that row should contains a specific text(lets say "published").i am able to get that text but the click function is implemented on other column of that row.So i need to take the row number of that text containing so that using this row count i will be able to click on the other column element which having the click function.Below is the html code for one of the table row.



<tr class="K7hAcc QwxBBf" for="iBW8sb0" jsshadow="">
<td class="XgRaPc AB6Eee RdU54d IRKtVe PLK3Id hhyjHe">
<content class="zRhise">
<a class="GRgXff sV" href="https://business.google.com/dashboard/l/16047977676197040292">
<span class="j5emz">Cavender's Boot City</span><br>
<span class="D0EYxd">303 NW Loop 410, San Antonio, TX 78216, United States</span>
</a></content></td>
<td class="XgRaPc AB6Eee RdU54d IRKtVe">
<content class="zRhise"><svg viewBox="0 0 24 24" class="zQoJdc P6t5mb"><path d="M0 0h24v24H0z" fill="none"></path><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-2 15l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z"></path></svg>
<span class="StcyZc">Published</span>
</content></td>
<td class="XgRaPc AB6Eee RdU54d IRKtVe">
<content class="zRhise"><div class="ypExpf"></div>
</content></td>
</tr>


Thanks in advance.










share|improve this question





























    0















    I am using protractor-cucumber framework.I need to click on a 'td' element in a row of a table.Among the all table rows, i am deciding to click on a row, such that row should contains a specific text(lets say "published").i am able to get that text but the click function is implemented on other column of that row.So i need to take the row number of that text containing so that using this row count i will be able to click on the other column element which having the click function.Below is the html code for one of the table row.



    <tr class="K7hAcc QwxBBf" for="iBW8sb0" jsshadow="">
    <td class="XgRaPc AB6Eee RdU54d IRKtVe PLK3Id hhyjHe">
    <content class="zRhise">
    <a class="GRgXff sV" href="https://business.google.com/dashboard/l/16047977676197040292">
    <span class="j5emz">Cavender's Boot City</span><br>
    <span class="D0EYxd">303 NW Loop 410, San Antonio, TX 78216, United States</span>
    </a></content></td>
    <td class="XgRaPc AB6Eee RdU54d IRKtVe">
    <content class="zRhise"><svg viewBox="0 0 24 24" class="zQoJdc P6t5mb"><path d="M0 0h24v24H0z" fill="none"></path><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-2 15l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z"></path></svg>
    <span class="StcyZc">Published</span>
    </content></td>
    <td class="XgRaPc AB6Eee RdU54d IRKtVe">
    <content class="zRhise"><div class="ypExpf"></div>
    </content></td>
    </tr>


    Thanks in advance.










    share|improve this question



























      0












      0








      0








      I am using protractor-cucumber framework.I need to click on a 'td' element in a row of a table.Among the all table rows, i am deciding to click on a row, such that row should contains a specific text(lets say "published").i am able to get that text but the click function is implemented on other column of that row.So i need to take the row number of that text containing so that using this row count i will be able to click on the other column element which having the click function.Below is the html code for one of the table row.



      <tr class="K7hAcc QwxBBf" for="iBW8sb0" jsshadow="">
      <td class="XgRaPc AB6Eee RdU54d IRKtVe PLK3Id hhyjHe">
      <content class="zRhise">
      <a class="GRgXff sV" href="https://business.google.com/dashboard/l/16047977676197040292">
      <span class="j5emz">Cavender's Boot City</span><br>
      <span class="D0EYxd">303 NW Loop 410, San Antonio, TX 78216, United States</span>
      </a></content></td>
      <td class="XgRaPc AB6Eee RdU54d IRKtVe">
      <content class="zRhise"><svg viewBox="0 0 24 24" class="zQoJdc P6t5mb"><path d="M0 0h24v24H0z" fill="none"></path><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-2 15l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z"></path></svg>
      <span class="StcyZc">Published</span>
      </content></td>
      <td class="XgRaPc AB6Eee RdU54d IRKtVe">
      <content class="zRhise"><div class="ypExpf"></div>
      </content></td>
      </tr>


      Thanks in advance.










      share|improve this question
















      I am using protractor-cucumber framework.I need to click on a 'td' element in a row of a table.Among the all table rows, i am deciding to click on a row, such that row should contains a specific text(lets say "published").i am able to get that text but the click function is implemented on other column of that row.So i need to take the row number of that text containing so that using this row count i will be able to click on the other column element which having the click function.Below is the html code for one of the table row.



      <tr class="K7hAcc QwxBBf" for="iBW8sb0" jsshadow="">
      <td class="XgRaPc AB6Eee RdU54d IRKtVe PLK3Id hhyjHe">
      <content class="zRhise">
      <a class="GRgXff sV" href="https://business.google.com/dashboard/l/16047977676197040292">
      <span class="j5emz">Cavender's Boot City</span><br>
      <span class="D0EYxd">303 NW Loop 410, San Antonio, TX 78216, United States</span>
      </a></content></td>
      <td class="XgRaPc AB6Eee RdU54d IRKtVe">
      <content class="zRhise"><svg viewBox="0 0 24 24" class="zQoJdc P6t5mb"><path d="M0 0h24v24H0z" fill="none"></path><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-2 15l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z"></path></svg>
      <span class="StcyZc">Published</span>
      </content></td>
      <td class="XgRaPc AB6Eee RdU54d IRKtVe">
      <content class="zRhise"><div class="ypExpf"></div>
      </content></td>
      </tr>


      Thanks in advance.







      protractor cucumberjs






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 26 '18 at 7:59







      Devleena

















      asked Nov 26 '18 at 6:58









      DevleenaDevleena

      979




      979
























          2 Answers
          2






          active

          oldest

          votes


















          0














          <ul>
          <li class="pet">Dog</li>
          <li class="pet">Cat</li>
          </ul>
          Code
          // Returns the li for the dog, but not cat.
          var dog = element(by.cssContainingText('.pet', 'Dog'));


          Refer the above code. Make sure you have the correct CSS and replace Dog with Published.



          Hope it helps you






          share|improve this answer
























          • Great thanks..i have implemented below code and its working. var row=element(by.cssContainingText("table tr","Published")); row.element(by.css("td:nth-child(2) content")).click();

            – Devleena
            Nov 26 '18 at 7:59



















          0














          You can use XPath in this case, something like:



          var yourvariable = element(by.xpath('//span[text()="Published"]/ancestor::td'));


          PS. It's not CSS code, it's HTML






          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%2f53476077%2fhow-to-get-row-number-such-that-row-should-contains-a-specific-text-in-protract%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









            0














            <ul>
            <li class="pet">Dog</li>
            <li class="pet">Cat</li>
            </ul>
            Code
            // Returns the li for the dog, but not cat.
            var dog = element(by.cssContainingText('.pet', 'Dog'));


            Refer the above code. Make sure you have the correct CSS and replace Dog with Published.



            Hope it helps you






            share|improve this answer
























            • Great thanks..i have implemented below code and its working. var row=element(by.cssContainingText("table tr","Published")); row.element(by.css("td:nth-child(2) content")).click();

              – Devleena
              Nov 26 '18 at 7:59
















            0














            <ul>
            <li class="pet">Dog</li>
            <li class="pet">Cat</li>
            </ul>
            Code
            // Returns the li for the dog, but not cat.
            var dog = element(by.cssContainingText('.pet', 'Dog'));


            Refer the above code. Make sure you have the correct CSS and replace Dog with Published.



            Hope it helps you






            share|improve this answer
























            • Great thanks..i have implemented below code and its working. var row=element(by.cssContainingText("table tr","Published")); row.element(by.css("td:nth-child(2) content")).click();

              – Devleena
              Nov 26 '18 at 7:59














            0












            0








            0







            <ul>
            <li class="pet">Dog</li>
            <li class="pet">Cat</li>
            </ul>
            Code
            // Returns the li for the dog, but not cat.
            var dog = element(by.cssContainingText('.pet', 'Dog'));


            Refer the above code. Make sure you have the correct CSS and replace Dog with Published.



            Hope it helps you






            share|improve this answer













            <ul>
            <li class="pet">Dog</li>
            <li class="pet">Cat</li>
            </ul>
            Code
            // Returns the li for the dog, but not cat.
            var dog = element(by.cssContainingText('.pet', 'Dog'));


            Refer the above code. Make sure you have the correct CSS and replace Dog with Published.



            Hope it helps you







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Nov 26 '18 at 7:18









            MadhanMadhan

            28219




            28219













            • Great thanks..i have implemented below code and its working. var row=element(by.cssContainingText("table tr","Published")); row.element(by.css("td:nth-child(2) content")).click();

              – Devleena
              Nov 26 '18 at 7:59



















            • Great thanks..i have implemented below code and its working. var row=element(by.cssContainingText("table tr","Published")); row.element(by.css("td:nth-child(2) content")).click();

              – Devleena
              Nov 26 '18 at 7:59

















            Great thanks..i have implemented below code and its working. var row=element(by.cssContainingText("table tr","Published")); row.element(by.css("td:nth-child(2) content")).click();

            – Devleena
            Nov 26 '18 at 7:59





            Great thanks..i have implemented below code and its working. var row=element(by.cssContainingText("table tr","Published")); row.element(by.css("td:nth-child(2) content")).click();

            – Devleena
            Nov 26 '18 at 7:59













            0














            You can use XPath in this case, something like:



            var yourvariable = element(by.xpath('//span[text()="Published"]/ancestor::td'));


            PS. It's not CSS code, it's HTML






            share|improve this answer




























              0














              You can use XPath in this case, something like:



              var yourvariable = element(by.xpath('//span[text()="Published"]/ancestor::td'));


              PS. It's not CSS code, it's HTML






              share|improve this answer


























                0












                0








                0







                You can use XPath in this case, something like:



                var yourvariable = element(by.xpath('//span[text()="Published"]/ancestor::td'));


                PS. It's not CSS code, it's HTML






                share|improve this answer













                You can use XPath in this case, something like:



                var yourvariable = element(by.xpath('//span[text()="Published"]/ancestor::td'));


                PS. It's not CSS code, it's HTML







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 26 '18 at 7:23









                technodeathtechnodeath

                973




                973






























                    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%2f53476077%2fhow-to-get-row-number-such-that-row-should-contains-a-specific-text-in-protract%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

                    A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks

                    Calculate evaluation metrics using cross_val_predict sklearn

                    Insert data from modal to MySQL (multiple modal on website)