[Solved] Javascript stops when searching for string in innerHTML


I was able to fix your code. This a working version.

Just remove the comment of the line

 //element.click();

Ok no how it works?

  1. First, we search for all the elements that has these three classes v.content-card-entry.fcb-row.fcb-clear as shown this line:

    rows = document.querySelectorAll('.content-card-entry.fcb-row.fcb-clear');
    
  2. Then we search for the elements that has a parent span and are span. This replaced your children implementation with:

    row.querySelectorAll('span > span');
    
  3. Now we can get the id of this label. Remember according to your HTML you will find 4 kinds of labels and the Label4 is the one that contains the price. Then you verify that it has an innerHTML value and done.

    var IDString = label.id;
        if (IDString.includes("Label4")) {
        if (label.innerHTML == amount) {
            ...
        }
    }
    

You can replace the variable amount="60,00 €"; with any other value.

Viel Glück.

(function() {
  'use strict';
  var ClickID, IDString, anfang, clickstring, ende, amount, rows;
  anfang = 'ctl00_ContentMiddle_TicketList1_GridView1_';
  ende="_LinkButton1";
  amount="60,00 €";
  
  rows = document.querySelectorAll('.content-card-entry.fcb-row.fcb-clear');
  rows.forEach(function(row) {
    var labels = row.querySelectorAll('span > span');
    labels.forEach(function(label) {
      var IDString = label.id;
      if (IDString.includes("Label4")) {
        if (label.innerHTML == amount) {
          ClickID = IDString.substr(42, 5);
          clickstring = anfang + ClickID + ende;        
          var element = document.getElementById(clickstring);
          console.log('Click on: ' + clickstring);
          //element.click();
          return;
        }
      }
    });
  });
 location.reload();
})();
<div>
  <table cellspacing="0" rules="rows" id="ctl00_ContentMiddle_TicketList1_GridView1" style="border-width:0px;width:100%;border-collapse:collapse;">
    <tr>
      <th scope="col">&nbsp;</th>
    </tr>
    <tr>
      <td>
        <p id="ctl00_ContentMiddle_TicketList1_GridView1_ctl03_P1" class="content-card-entry fcb-row fcb-clear">
          <span class="content-card-entry-value fcb-gr-3 fcb-gr-3@small">
                                            <span id="ctl00_ContentMiddle_TicketList1_GridView1_ctl03_Label1">101</span>
          </span>
          <span class="content-card-entry-value fcb-gr-3 fcb-gr-3@small">
                                            <span id="ctl00_ContentMiddle_TicketList1_GridView1_ctl03_Label2">16</span>
          </span>
          <span class="content-card-entry-value fcb-gr-3 fcb-gr-3@small">
                                            <span id="ctl00_ContentMiddle_TicketList1_GridView1_ctl03_Label3">21</span>
          </span>
          <span class="content-card-entry-value fcb-gr-3 fcb-gr-3@small">
                                            <span id="ctl00_ContentMiddle_TicketList1_GridView1_ctl03_Label4">70,00 €</span>
          </span>
        </p>
        <p id="ctl00_ContentMiddle_TicketList1_GridView1_ctl03_P5" class="content-card-entry fcb-row fcb-clear" style="text-align:right;">
          <span class="content-card-entry-value fcb-gr-12 fcb-gr-12@small">
                                                <a id="ctl00_ContentMiddle_TicketList1_GridView1_ctl03_LinkButton1" class="button small cart-buttons-second-button" Autopostback="false" href="javascript:__doPostBack(&#39;ctl00$ContentMiddle$TicketList1$GridView1$ctl03$LinkButton1&#39;,&#39;&#39;)">In den&nbsp;Warenkorb</a>
                                            </span>
        </p>
        <hr />
      </td>
    </tr>
    <tr>
      <td>
        <p id="ctl00_ContentMiddle_TicketList1_GridView1_ctl04_P1" class="content-card-entry fcb-row fcb-clear">
          <span class="content-card-entry-value fcb-gr-3 fcb-gr-3@small">
                                            <span id="ctl00_ContentMiddle_TicketList1_GridView1_ctl04_Label1">107</span>
          </span>
          <span class="content-card-entry-value fcb-gr-3 fcb-gr-3@small">
                                            <span id="ctl00_ContentMiddle_TicketList1_GridView1_ctl04_Label2">14</span>
          </span>
          <span class="content-card-entry-value fcb-gr-3 fcb-gr-3@small">
                                            <span id="ctl00_ContentMiddle_TicketList1_GridView1_ctl04_Label3">23</span>
          </span>
          <span class="content-card-entry-value fcb-gr-3 fcb-gr-3@small">
                                            <span id="ctl00_ContentMiddle_TicketList1_GridView1_ctl04_Label4">70,00 €</span>
          </span>
        </p>
        <p id="ctl00_ContentMiddle_TicketList1_GridView1_ctl04_P5" class="content-card-entry fcb-row fcb-clear" style="text-align:right;">
          <span class="content-card-entry-value fcb-gr-12 fcb-gr-12@small">
                                                <a id="ctl00_ContentMiddle_TicketList1_GridView1_ctl04_LinkButton1" class="button small cart-buttons-second-button" Autopostback="false" href="javascript:__doPostBack(&#39;ctl00$ContentMiddle$TicketList1$GridView1$ctl04$LinkButton1&#39;,&#39;&#39;)">In den&nbsp;Warenkorb</a>
                                            </span>
        </p>
        <hr />
      </td>
    </tr>
    <tr>
      <td>
        <p id="ctl00_ContentMiddle_TicketList1_GridView1_ctl05_P1" class="content-card-entry fcb-row fcb-clear">
          <span class="content-card-entry-value fcb-gr-3 fcb-gr-3@small">
                                            <span id="ctl00_ContentMiddle_TicketList1_GridView1_ctl05_Label1">326</span>
          </span>
          <span class="content-card-entry-value fcb-gr-3 fcb-gr-3@small">
                                            <span id="ctl00_ContentMiddle_TicketList1_GridView1_ctl05_Label2">6</span>
          </span>
          <span class="content-card-entry-value fcb-gr-3 fcb-gr-3@small">
                                            <span id="ctl00_ContentMiddle_TicketList1_GridView1_ctl05_Label3">16</span>
          </span>
          <span class="content-card-entry-value fcb-gr-3 fcb-gr-3@small">
                                            <span id="ctl00_ContentMiddle_TicketList1_GridView1_ctl05_Label4">60,00 €</span>
          </span>
        </p>
        <p id="ctl00_ContentMiddle_TicketList1_GridView1_ctl05_P5" class="content-card-entry fcb-row fcb-clear" style="text-align:right;">
          <span class="content-card-entry-value fcb-gr-12 fcb-gr-12@small">
                                                <a id="ctl00_ContentMiddle_TicketList1_GridView1_ctl05_LinkButton1" class="button small cart-buttons-second-button" Autopostback="false" href="javascript:__doPostBack(&#39;ctl00$ContentMiddle$TicketList1$GridView1$ctl05$LinkButton1&#39;,&#39;&#39;)">In den&nbsp;Warenkorb</a>
                                            </span>
        </p>
        <hr />
      </td>
    </tr>
    <tr>
      <td>
        <p id="ctl00_ContentMiddle_TicketList1_GridView1_ctl06_P1" class="content-card-entry fcb-row fcb-clear">
          <span class="content-card-entry-value fcb-gr-3 fcb-gr-3@small">
                                            <span id="ctl00_ContentMiddle_TicketList1_GridView1_ctl06_Label1">313</span>
          </span>
          <span class="content-card-entry-value fcb-gr-3 fcb-gr-3@small">
                                            <span id="ctl00_ContentMiddle_TicketList1_GridView1_ctl06_Label2">18</span>
          </span>
          <span class="content-card-entry-value fcb-gr-3 fcb-gr-3@small">
                                            <span id="ctl00_ContentMiddle_TicketList1_GridView1_ctl06_Label3">18</span>
          </span>
          <span class="content-card-entry-value fcb-gr-3 fcb-gr-3@small">
                                            <span id="ctl00_ContentMiddle_TicketList1_GridView1_ctl06_Label4">35,00 €</span>
          </span>
        </p>
        <p id="ctl00_ContentMiddle_TicketList1_GridView1_ctl06_P5" class="content-card-entry fcb-row fcb-clear" style="text-align:right;">
          <span class="content-card-entry-value fcb-gr-12 fcb-gr-12@small">
                                                <a id="ctl00_ContentMiddle_TicketList1_GridView1_ctl06_LinkButton1" class="button small cart-buttons-second-button" Autopostback="false" href="javascript:__doPostBack(&#39;ctl00$ContentMiddle$TicketList1$GridView1$ctl06$LinkButton1&#39;,&#39;&#39;)">In den&nbsp;Warenkorb</a>
                                            </span>
        </p>
        <hr />
      </td>
    </tr>
  </table>
</div>

solved Javascript stops when searching for string in innerHTML