I am writing acceptance tests using Selenium + WebdriverIO. And I have some problems with that - I can't click on this link
client.click('a[href=#admin/'+ transactionId + ']')
transactionId - it is a variable which contains ID of transaction. My HTML code:
<div class="ui-data-table">
<thead>...</thead>
<tbody>
<tr><td class="tac">
<span class="tooltip" title="Transaction"><i class="icon-transaction"></i></span>
</td>
<td class="tac no-break">Today 10:23</td>
<td class="break-all"></td>
<td class="tac">
N/A
</td>
<td>Artem</td>
<td class="tac">
<span class="tooltip" title="Pending">
<i class="icon-clock"></i>
</span>
</td>
<td class="break-all">Artem Arsenowitch</td>
<td class="tac">
<a href="#admin/aceb3f65-4078-4f47-8850-95ac9135fad3"><i class="icon-arrow-circle-right"></i></a>
</td></tr>
<tr>...</tr>
<tr>...</tr>
<tr>...</tr>
<tr>...</tr>
<tr>...</tr>
<tr>...</tr>
</tbody>
</div>
Every "tr" tag has the same structure as you can see above and "a" tag with appropriate id inside href attribute. The main problem consist in this code:
('a[href=#admin/'+ transactionId + ']')
because it returns
(a[href=#admin/undefined])
Girish Sortur Thanks for you answers, but I found only one solution using this code:
.getAttribute("p.tac", "transaction-id")
.then(function(attr){
transactionId = attr;
transactionURL = 'a[href="#admin/'+ transactionId + '"]';
})
.click('a[href="#admin"]')
.waitForExist("div.ui-data-table", 10000).then(function(){
client.click(transactionURL)//That is working now
})