How do I get the text from the li tagGetting text from a nodeHow to get a single text node in Selenium WebDriverHow to get text from input tag?Unable to get Text from a Span tag in WebDriverSelenium java code: How to read text from hidden element that contain many tagsHow to get 'translate' text value from an Angular tag using selenium JavaUnable to retrieve the text inside the div tag even when the tag is identifiedNot able to get text which is not inside any tag Using seleniumHow to get the text from the <text> tag using seleniumhow to get text under p tag ignoring inner span tag text using java seleniumget text from textarea tag

Are the players on the same team as the DM?

What would be the challenges to taking off and landing a typical passenger jet at FL300?

Examples of topos that are not ordinary spaces

How to determine car loan length as a function of how long I plan to keep a car

Algorithms vs LP or MIP

I don't have the theoretical background in my PhD topic. I can't justify getting the degree

Ensuring all network services on a device use strong TLS cipher suites

Prove your innocence

How do I, an introvert, communicate to my friend and only colleague, an extrovert, that I want to spend my scheduled breaks without them?

Is it possible to generate a leveled character in borderlands 2?

You have 3 cakes. Everytime you eat one, there's 17% chance the number of cakes is reset to 3. Find average number of cakes eaten?

Why isn't "I've" a proper response?

How do you harvest carrots in creative mode?

Is there any music source code for sound chips?

Nothing like a good ol' game of ModTen

The Knight's estate

Pythagorean triple with hypotenuse a power of 2

Is there any practical application for performing a double Fourier transform? ...or an inverse Fourier transform on a time-domain input?

Is a player able to change alignment midway through an adventure?

Are modern clipless shoes and pedals that much better than toe clips and straps?

What is a CirKle Word™?

How much authority do teachers get from *In Loco Parentis*?

Why did MS-DOS applications built using Turbo Pascal fail to start with a division by zero error on faster systems?

An interview question: What's the number of String objects being created?



How do I get the text from the li tag


Getting text from a nodeHow to get a single text node in Selenium WebDriverHow to get text from input tag?Unable to get Text from a Span tag in WebDriverSelenium java code: How to read text from hidden element that contain many tagsHow to get 'translate' text value from an Angular tag using selenium JavaUnable to retrieve the text inside the div tag even when the tag is identifiedNot able to get text which is not inside any tag Using seleniumHow to get the text from the <text> tag using seleniumhow to get text under p tag ignoring inner span tag text using java seleniumget text from textarea tag






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








-3















How do I get the text from the li tag? I want to find the text "Password is required." only, not the text inside strong tag.



<li><strong>Error:</strong> Password is required.</li>









share|improve this question





















  • 1





    Can you please provide the html and your code ?

    – Pritam Maske
    Mar 27 at 16:19






  • 2





    Possible duplicate of Getting text from a node

    – SiKing
    Mar 27 at 19:23











  • Update the question with a bit more of the outerHTML

    – DebanjanB
    Mar 28 at 8:03

















-3















How do I get the text from the li tag? I want to find the text "Password is required." only, not the text inside strong tag.



<li><strong>Error:</strong> Password is required.</li>









share|improve this question





















  • 1





    Can you please provide the html and your code ?

    – Pritam Maske
    Mar 27 at 16:19






  • 2





    Possible duplicate of Getting text from a node

    – SiKing
    Mar 27 at 19:23











  • Update the question with a bit more of the outerHTML

    – DebanjanB
    Mar 28 at 8:03













-3












-3








-3








How do I get the text from the li tag? I want to find the text "Password is required." only, not the text inside strong tag.



<li><strong>Error:</strong> Password is required.</li>









share|improve this question
















How do I get the text from the li tag? I want to find the text "Password is required." only, not the text inside strong tag.



<li><strong>Error:</strong> Password is required.</li>






selenium-webdriver






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 27 at 17:34









Jason Aller

3,23710 gold badges32 silver badges33 bronze badges




3,23710 gold badges32 silver badges33 bronze badges










asked Mar 27 at 15:57









vdhanorkarvdhanorkar

12 bronze badges




12 bronze badges










  • 1





    Can you please provide the html and your code ?

    – Pritam Maske
    Mar 27 at 16:19






  • 2





    Possible duplicate of Getting text from a node

    – SiKing
    Mar 27 at 19:23











  • Update the question with a bit more of the outerHTML

    – DebanjanB
    Mar 28 at 8:03












  • 1





    Can you please provide the html and your code ?

    – Pritam Maske
    Mar 27 at 16:19






  • 2





    Possible duplicate of Getting text from a node

    – SiKing
    Mar 27 at 19:23











  • Update the question with a bit more of the outerHTML

    – DebanjanB
    Mar 28 at 8:03







1




1





Can you please provide the html and your code ?

– Pritam Maske
Mar 27 at 16:19





Can you please provide the html and your code ?

– Pritam Maske
Mar 27 at 16:19




2




2





Possible duplicate of Getting text from a node

– SiKing
Mar 27 at 19:23





Possible duplicate of Getting text from a node

– SiKing
Mar 27 at 19:23













Update the question with a bit more of the outerHTML

– DebanjanB
Mar 28 at 8:03





Update the question with a bit more of the outerHTML

– DebanjanB
Mar 28 at 8:03












2 Answers
2






active

oldest

votes


















0















You need to show your code for somebody to give a complete answer. I guess that you already know how to do something like the following



WebElement something = driver.FindElement(By.CssSelector(?))
string s = something.Text;


The next bit seems to be where you are stuck. There you need to parse the string s. That is nothing to do with Selenium-Webdriver. You could do something like



string[] s2 = s.split(new string[] ">","<");


were the last element in s2 would be your answer here. This would be totally non generic though. Is this a situation in which you always want to purge html?






share|improve this answer
































    0















    Here is the method developed in python.



    def get_text_exclude_children(element):
    return driver.execute_script(
    """
    var parent = arguments[0];
    var child = parent.firstChild;
    var textValue = "";
    while(child)
    if (child.nodeType === Node.TEXT_NODE)
    textValue += child.textContent;
    child = child.nextSibling;

    return textValue;""",
    element).strip()


    How to use in this:



    liElement = driver.find_element_by_xpath("//li")
    liOnlyText = get_text_exclude_children(liElement)
    print(liOnlyText)


    Please use your possible strategy to get the element, this method need an element from which you need the text (without children text).






    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%2f55381534%2fhow-do-i-get-the-text-from-the-li-tag%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















      You need to show your code for somebody to give a complete answer. I guess that you already know how to do something like the following



      WebElement something = driver.FindElement(By.CssSelector(?))
      string s = something.Text;


      The next bit seems to be where you are stuck. There you need to parse the string s. That is nothing to do with Selenium-Webdriver. You could do something like



      string[] s2 = s.split(new string[] ">","<");


      were the last element in s2 would be your answer here. This would be totally non generic though. Is this a situation in which you always want to purge html?






      share|improve this answer





























        0















        You need to show your code for somebody to give a complete answer. I guess that you already know how to do something like the following



        WebElement something = driver.FindElement(By.CssSelector(?))
        string s = something.Text;


        The next bit seems to be where you are stuck. There you need to parse the string s. That is nothing to do with Selenium-Webdriver. You could do something like



        string[] s2 = s.split(new string[] ">","<");


        were the last element in s2 would be your answer here. This would be totally non generic though. Is this a situation in which you always want to purge html?






        share|improve this answer



























          0














          0










          0









          You need to show your code for somebody to give a complete answer. I guess that you already know how to do something like the following



          WebElement something = driver.FindElement(By.CssSelector(?))
          string s = something.Text;


          The next bit seems to be where you are stuck. There you need to parse the string s. That is nothing to do with Selenium-Webdriver. You could do something like



          string[] s2 = s.split(new string[] ">","<");


          were the last element in s2 would be your answer here. This would be totally non generic though. Is this a situation in which you always want to purge html?






          share|improve this answer













          You need to show your code for somebody to give a complete answer. I guess that you already know how to do something like the following



          WebElement something = driver.FindElement(By.CssSelector(?))
          string s = something.Text;


          The next bit seems to be where you are stuck. There you need to parse the string s. That is nothing to do with Selenium-Webdriver. You could do something like



          string[] s2 = s.split(new string[] ">","<");


          were the last element in s2 would be your answer here. This would be totally non generic though. Is this a situation in which you always want to purge html?







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 27 at 18:29









          SlightlyKosumiSlightlyKosumi

          1864 silver badges16 bronze badges




          1864 silver badges16 bronze badges


























              0















              Here is the method developed in python.



              def get_text_exclude_children(element):
              return driver.execute_script(
              """
              var parent = arguments[0];
              var child = parent.firstChild;
              var textValue = "";
              while(child)
              if (child.nodeType === Node.TEXT_NODE)
              textValue += child.textContent;
              child = child.nextSibling;

              return textValue;""",
              element).strip()


              How to use in this:



              liElement = driver.find_element_by_xpath("//li")
              liOnlyText = get_text_exclude_children(liElement)
              print(liOnlyText)


              Please use your possible strategy to get the element, this method need an element from which you need the text (without children text).






              share|improve this answer





























                0















                Here is the method developed in python.



                def get_text_exclude_children(element):
                return driver.execute_script(
                """
                var parent = arguments[0];
                var child = parent.firstChild;
                var textValue = "";
                while(child)
                if (child.nodeType === Node.TEXT_NODE)
                textValue += child.textContent;
                child = child.nextSibling;

                return textValue;""",
                element).strip()


                How to use in this:



                liElement = driver.find_element_by_xpath("//li")
                liOnlyText = get_text_exclude_children(liElement)
                print(liOnlyText)


                Please use your possible strategy to get the element, this method need an element from which you need the text (without children text).






                share|improve this answer



























                  0














                  0










                  0









                  Here is the method developed in python.



                  def get_text_exclude_children(element):
                  return driver.execute_script(
                  """
                  var parent = arguments[0];
                  var child = parent.firstChild;
                  var textValue = "";
                  while(child)
                  if (child.nodeType === Node.TEXT_NODE)
                  textValue += child.textContent;
                  child = child.nextSibling;

                  return textValue;""",
                  element).strip()


                  How to use in this:



                  liElement = driver.find_element_by_xpath("//li")
                  liOnlyText = get_text_exclude_children(liElement)
                  print(liOnlyText)


                  Please use your possible strategy to get the element, this method need an element from which you need the text (without children text).






                  share|improve this answer













                  Here is the method developed in python.



                  def get_text_exclude_children(element):
                  return driver.execute_script(
                  """
                  var parent = arguments[0];
                  var child = parent.firstChild;
                  var textValue = "";
                  while(child)
                  if (child.nodeType === Node.TEXT_NODE)
                  textValue += child.textContent;
                  child = child.nextSibling;

                  return textValue;""",
                  element).strip()


                  How to use in this:



                  liElement = driver.find_element_by_xpath("//li")
                  liOnlyText = get_text_exclude_children(liElement)
                  print(liOnlyText)


                  Please use your possible strategy to get the element, this method need an element from which you need the text (without children text).







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Mar 28 at 0:02









                  supputurisupputuri

                  6,3402 gold badges8 silver badges24 bronze badges




                  6,3402 gold badges8 silver badges24 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%2f55381534%2fhow-do-i-get-the-text-from-the-li-tag%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권, 지리지 충청도 공주목 은진현