Write a monitoring tool with selenium+java
<p>Good day!
I have an idea about using selenium as short-time monitoring tool. For example, need to check for an two-three hours about some table values changing.</p>
<p>I've got in mind a cycle &quot;while&quot;, where i set up timer how long need to monitor values, and then print them for easy compare.</p>
<blockquote>
<p>2016.04.26  |  160789  186491  0.76%  05:28:56</p>
<p>2016.04.26  |  160789  186491  0.76%  05:30:56</p>
</blockquote>
<p>But I think there is better, smart solution. But i can't figure out how.</p>
<pre><code>    open(projectUrl);

    int timer = 120;
    int i = 1;
    int iterations = 50;
    
    String var1 = $(&quot;cssSelector1&quot;).getText();

    while (i&lt;iterations) {
      open(projectUrl);
      var1 = $(&quot;cssSelector1&quot;).getText();
      if (!$(&quot;cssSelector1&quot;).getText().equals(var1)) {

         System.out.print(
         var1+&quot;  |  &quot;+
         $(&quot;cssSelector2&quot;).getText()+&quot;  &quot;+
         $(&quot;cssSelector3&quot;).getText()+&quot;  &quot;+
         $(&quot;cssSelector4&quot;).getText()+&quot;  &quot;);
      
         Date dNow = new Date( );
         SimpleDateFormat ft = new SimpleDateFormat (&quot;hh:mm:ss&quot;);
         System.out.println(ft.format(dNow));

      }

      sleep(timer*1000);
      i++;

    }
</code></pre>
<p>Now it's done, and works like I want. When var1 changes, update var1, then write value. And cycling again. Upper code works fine.</p>