How do I select a particular dynamic div, using Selenium when I don't have a unique id or name? -


only content of div unique. so, in following dynamically generated html, "my article-1245" unique:

 <div class="col-md-4 article">  <h2>       article-1245      <a href="delete/6" class="btn btn-xs btn-danger article-btn pull-right hide fade in">delete</a>      <a href="edit/6" class="btn btn-xs btn-info article-btn pull-right hide fade in">edit</a>  </h2>      <p>o ephemeral text! here today, gone tomorrow. not terribly important, necessary</p>  </div> 

how select edit/delete link of specific div, using selenium? asserttext/verifytext requires element locator, not have unique id/name (out of control). there many such div blocks, other content text, dynamically generated.

any appreciated.

if text 'my article' appears each time, may use following:

//for delete driver.findelement(by.xpath("//h2[contains(text(),'my article-')]/a[text()='delete']")); //for edit driver.findelement(by.xpath("//h2[contains(text(),'my article-')]/a[text()='edit']")); 

hope meets requirement :)


Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -