title: How to catch the dynamic xpath id in Rselenium R
body: <p>I have a problem about one dynamic xpath
  I tried to use different way to solve the problem but, I didn't find a great solution yet.</p>
  
  <p>The problem is that I have to use an xpath that, unfortunately, is dynamic and it hasn't never the same length.</p>
  
  <p>Here the part of the html code that generate a click</p>
  
  <pre><code>   &lt;div class="field"&gt;
          &lt;a onclick="sendGaSearch();" class="ui button rounded" style="background- 
   color: #3fa9f5;" id="id1a2" href="javascript:;"&gt;
  </code></pre>
  
  <p>In this case the id is <code>"id1a2"</code>, but if I refresh the page the code will be different.</p>
  
  <p>I find this solution, but doesn't work always, because the length of <code>id="id1a2"</code> be different. </p>
  
  <p>My solution is: </p>
  
  <pre><code>  cod_html&lt;-webElem$getPageSource()
    x&lt;-str_match(cod_html, ".^*ui button rounded ([^\\.]*)\\..*")[,2]
    cod_c&lt;-str_sub(x, 42,47)
    cod_c2&lt;-paste0("//*[@id=",'"', cod_c,'"',"]")
    webElem &lt;- remote_driver$findElement(using = "xpath",cod_c2)
    webElem$clickElement()
  </code></pre>
  
  <p>The part of the html code that I extract form the page is this: </p>
  
  <pre><code> "\" style=\"background-color: #3fa9f5;\" id=\"id1a2\"
   href=\"javascript:;\"&gt;\n\t\t\t\t\t\t\tSearch\n\t\t\t\t\t\t&lt;/a&gt;\n\t\t\t\t\t&lt;/div&gt;\n\n\t\t\t\t&lt;/form&gt;\n\t\t\t\t\n\t\t\t\t&lt;script
  </code></pre>
  
  <p>Somebody could help me to solve this. </p>
  
  <p>Thank you in advance.</p>