I have some table:
Title 1 | Title 2 | Title 3 |
--------------------------------------------------
string value 1 | string value 2 | string value 3 |
--------------------------------------------------
string value 4 | string value 5 | string value 6 |
and some step:
“And click on its < name>”, where < name> can be anything from first column.
So, how I can found needed element and click on its?
Table code
<div id="grid" class="k-grid k-widget" data-role="grid" tabindex="0" style="">
<div class="k-grid-header" style="padding-right: 17px;">
<div class="k-grid-header-wrap">
<table cellspacing="0">
<colgroup>
<col style="width: 30px;">
<col style="width: 300px;">
<col>
<col style="width: 200px;">
</colgroup>
<thead>
<tr>
<th class="k-header" data-title="ID" data-field="id">ID</th>
<th class="k-header" data-title="Наименование" data-field="name" data-role="sortable" data-dir="asc">
<a class="k-link" href="#">
2nd part
Наименование
<span class="k-icon k-arrow-up"></span>
</a>
</th>
<th class="k-header" data-title="Описание" data-field="description">Описание</th>
<th class="k-header" data-field="undefined" data-role="sortable">
</tr>
</thead>
</table>
</div>
</div>
3rd part
<div class="k-grid-content">
<table class="k-focusable k-selectable" cellspacing="0" data-role="selectable">
<colgroup>
<col style="width: 30px;">
<col style="width: 300px;">
<col>
<col style="width: 200px;">
</colgroup>
<tbody>
<tr data-uid="72c59bdf-8622-43c6-91bf-7a2a05ca59b1">
<td>5</td>
<td>1</td>
<td>1</td>
<td>
</tr>
4th part
<tr class="k-alt" data-uid="f8d1ef8c-07b0-4e79-9c42-4c6db2d943d0">
<td>6</td>
<td>1</td>
<td>1</td>
<td>
</tr>
<tr data-uid="241a4a4b-7147-46fe-ad55-f865de4a8285">
<td>8</td>
<td>789</td>
<td>987</td>
<td>
</tr>
<tr class="k-alt" data-uid="73bf8ea7-c4f0-49f9-8e8b-41d88b13212d">
<td>7</td>
<td>test</td>
<td>test</td>
<td>
</tr>
5th
<tr data-uid="63db0ec1-5a5a-40be-9fa0-b467ff2b43d3">
<td>4</td>
<td>Второй процесс</td>
<td>null</td>
<td>
</tr>
<tr class="k-alt" data-uid="68fe2d62-5ccb-472b-b7b9-8ee95159deff">
<td>1</td>
<td>Заявление1</td>
<td>управление заявлениями</td>
<td>
</tr>
</tbody>
</table>
</div>
6th
<div class="k-pager-wrap k-grid-pager" data-role="pager">
<ul class="k-pager k-reset k-numeric">
<li>
<span class="k-state-active">1</span>
</li>
</ul>
</div>
</div>
I partly understood what you are trying to do. You want to click on elements on your page based on the text values. To do this you will have to find elements on the page with the text you want to click on. For example – If you want to click on some element with the text = “Mike”
Use the following code –
Now you will get an WebElement to click on with the text “Mike”.
So now –
ele.click();Another thing I want to mention is that your HTML code is not well formed(i.e does not have proper opening and closing tags). Having a well formed HTML will make interacting with elements on your web page easier when using selenium.