Вот контекст:
Я тестирую функцию удаления из приложения.Когда выбран запрос на удаление, появляется всплывающее окно, чтобы подтвердить или нет действие.Когда я нажимаю кнопку [ДА], страница обновляется с удаленным элементом.Для этого код вызывает функцию в файле JavaScript.
Когда я пытаюсь воспроизвести это действие с помощью Robot Framework, мне удается нажать кнопку [ДА], страница обновляется, но элемент, который должен быть удален, всегда присутствует.Похоже, что Robot Framework не собирается автоматически выполнять код удаления javascript.
Сценарий My Robot Framework:
#We wait for the confirmation pop-up to appear
Wait Until Element Is Visible xpath=//div[@tabindex="-1"]
#Click on the [YES] button
Click Element xpath=//button[@tabindex="1"]
Код всплывающего окна:
<div class="sweet-alert showSweetAlert visible" tabindex="-1" data-custom-class="" data-has-cancel-button="true" data-has-confirm-button="true" data-allow-outside-click="false" data-has-done-function="true" data-animation="pop" data-timer="null" style="display: block; margin-top: -154px;"><div class="sa-icon sa-error" style="display: none;">
<span class="sa-x-mark">
<span class="sa-line sa-left"></span>
<span class="sa-line sa-right"></span>
</span>
</div><div class="sa-icon sa-warning pulseWarning" style="display: block;">
<span class="sa-body pulseWarningIns"></span>
<span class="sa-dot pulseWarningIns"></span>
</div><div class="sa-icon sa-info" style="display: none;"></div><div class="sa-icon sa-success" style="display: none;">
<span class="sa-line sa-tip"></span>
<span class="sa-line sa-long"></span>
<div class="sa-placeholder"></div>
<div class="sa-fix"></div>
</div><div class="sa-icon sa-custom" style="display: none;"></div><h2>Are you sure you want to delete this item ?</h2>
<p class="lead text-muted "></p>
<div class="form-group">
<input class="form-control" tabindex="3" placeholder="" type="text">
<span class="sa-input-error help-block">
<span class="glyphicon glyphicon-exclamation-sign"></span> <span class="sa-help-text">Not valid</span>
</span>
</div><div class="sa-button-container">
<button class="cancel btn btn-lg btn-default" tabindex="2" style="display: inline-block;">No</button>
<div class="sa-confirm-button-container">
<button class="confirm btn btn-lg confirm-button-class" tabindex="1" style="display: inline-block;">Yes</button><div class="la-ball-fall">
<div></div>
<div></div>
<div></div>
</div>
</div>
</div></div>
И код JavaScript:
function deleteTenant(tenant) {
swal({
title: $filter('translate')('alerts.swal.DELETE_Q'),
showCancelButton: true,
type: "warning",
confirmButtonClass: "confirm-button-class",
confirmButtonText: $filter('translate')('alerts.swal.DELETE_CONFRIM'),
cancelButtonText: $filter('translate')('alerts.swal.DELETE_CANCEL'),
closeOnConfirm: true,
closeOnCancel: true,
animation: true,
showLoaderOnConfirm: true
},
function (isConfirm) {
if (isConfirm) {
TenantsService.deleteTenant(tenant.id).then(function (result) {
if (result.status === 500 || result.status === 403) {
ToastService.showError('Something went wrong !');
} else {
$scope.tenants.splice($scope.tenants.indexOf(tenant), 1);
ToastService.showSuccess('Tenant [' + tenant.name + '] deleted successfully');
setPage(1);
}
})
.catch(function (err) {
//console.log(err);
});
} else {}
});
}
Я читаю разные статьи, не находя подходящего решения.
Я также торговал с разработчиком проекта, и кажется, что это предел Robot Framework.
Сетевая трассировка после нажатия кнопки YES:
{
"log": {
"version": "1.1",
"creator": {
"name": "Firefox",
"version": "62.0.3"
},
"browser": {
"name": "Firefox",
"version": "62.0.3"
},
"pages": [
{
"startedDateTime": "2018-10-09T10:23:43.079+02:00",
"id": "page_1",
"title": "smart tracking",
"pageTimings": {
"onContentLoad": -31330,
"onLoad": -31319
}
}
],
"entries": [
{
"pageref": "page_1",
"startedDateTime": "2018-10-09T10:23:43.079+02:00",
"request": {
"bodySize": 0,
"method": "DELETE",
"url": "https://127.0.0.1:9000/admin/v0/tenants/583",
"httpVersion": "HTTP/1.1",
"headers": [
{
"name": "Host",
"value": "127.0.0.1:9000"
},
{
"name": "User-Agent",
"value": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:62.0) Gecko/20100101 Firefox/62.0"
},
{
"name": "Accept",
"value": "application/json, text/plain, */*"
},
{
"name": "Accept-Language",
"value": "fr,fr-FR;q=0.8,en-US;q=0.5,en;q=0.3"
},
{
"name": "Accept-Encoding",
"value": "gzip, deflate, br"
},
{
"name": "Referer",
"value": "https://127.0.0.1:9000/"
},
{
"name": "X-XSRF-TOKEN",
"value": "71dee234-01f2-4722-9c8d-9856885238ca"
},
{
"name": "Cookie",
"value": "XSRF-TOKEN=71dee234-01f2-4722-9c8d-9856885238ca; X-XSRF-SECURE-TOKEN=71dee234-01f2-4722-9c8d-9856885238ca; X-TOKEN=eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE1MzkxMTY1NzcsInVzZXJfbmFtZSI6ImJpbGwiLCJhdXRob3JpdGllcyI6WyJST0xFX0dQIl0sImp0aSI6Ijc0Njc0MThlLWYyMjAtNGFjYi05ODIwLTFjY2I3ZWQ5YjljNSIsImNsaWVudF9pZCI6ImJyb3dzZXIiLCJzY29wZSI6WyJleHRlcm5hbCJdfQ.cT0BEUCvITaa6M1t3rY7LKWfZ87u6-uZPji0uwMXj5y1ppnfX5-vGR81yRc-gMPBl-3ULARC_MaaFpfXn1EtD5vjau6mqWMlZBCzPR9GT7XystxhdpZbAENbsiAaVbu37w2TG1qimvL402Brh8xoBXBb4HG1oadOWv_MlOhIyeWdZ7RrBpAcpK2cTcmWvr1RRDOxorVT_vjiLe01sIh2-M4DuvhmqK-oHHZssMulIuZIOTClIMtyY2Y7vY0Wik1eJ-hQ0mkjBT_ae0VMXPv4ESnEj0QNTRi5zciV24MIAtDlnAhEm3lk2MGA0nX2e4GHvD8P8RSy8DHeSY68D7VvwQ; SESSION-ID=245295400"
},
{
"name": "Connection",
"value": "keep-alive"
}
],
"cookies": [
{
"name": "XSRF-TOKEN",
"value": "71dee234-01f2-4722-9c8d-9856885238ca"
},
{
"name": "X-XSRF-SECURE-TOKEN",
"value": "71dee234-01f2-4722-9c8d-9856885238ca"
},
{
"name": "X-TOKEN",
"value": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE1MzkxMTY1NzcsInVzZXJfbmFtZSI6ImJpbGwiLCJhdXRob3JpdGllcyI6WyJST0xFX0dQIl0sImp0aSI6Ijc0Njc0MThlLWYyMjAtNGFjYi05ODIwLTFjY2I3ZWQ5YjljNSIsImNsaWVudF9pZCI6ImJyb3dzZXIiLCJzY29wZSI6WyJleHRlcm5hbCJdfQ.cT0BEUCvITaa6M1t3rY7LKWfZ87u6-uZPji0uwMXj5y1ppnfX5-vGR81yRc-gMPBl-3ULARC_MaaFpfXn1EtD5vjau6mqWMlZBCzPR9GT7XystxhdpZbAENbsiAaVbu37w2TG1qimvL402Brh8xoBXBb4HG1oadOWv_MlOhIyeWdZ7RrBpAcpK2cTcmWvr1RRDOxorVT_vjiLe01sIh2-M4DuvhmqK-oHHZssMulIuZIOTClIMtyY2Y7vY0Wik1eJ-hQ0mkjBT_ae0VMXPv4ESnEj0QNTRi5zciV24MIAtDlnAhEm3lk2MGA0nX2e4GHvD8P8RSy8DHeSY68D7VvwQ"
},
{
"name": "SESSION-ID",
"value": "245295400"
}
],
"queryString": [],
"headersSize": 1127
},
"response": {
"status": 500,
"statusText": "Internal Server Error",
"httpVersion": "HTTP/1.1",
"headers": [
{
"name": "server",
"value": "ecstatic-3.2.0"
},
{
"name": "x-content-type-options",
"value": "nosniff"
},
{
"name": "x-xss-protection",
"value": "1; mode=block"
},
{
"name": "cache-control",
"value": "no-cache, no-store, max-age=0, must-revalidate"
},
{
"name": "pragma",
"value": "no-cache"
},
{
"name": "expires",
"value": "0"
},
{
"name": "x-frame-options",
"value": "DENY"
},
{
"name": "x-application-context",
"value": "application:8443"
},
{
"name": "content-type",
"value": "application/json;charset=UTF-8"
},
{
"name": "transfer-encoding",
"value": "chunked"
},
{
"name": "date",
"value": "Tue, 09 Oct 2018 08:23:43 GMT"
},
{
"name": "connection",
"value": "close"
}
],
"cookies": [],
"content": {
"mimeType": "application/json; charset=UTF-8",
"size": 346,
"text": "{\"timestamp\":1539073423358,\"status\":500,\"error\":\"Internal Server Error\",\"exception\":\"org.springframework.dao.DataIntegrityViolationException\",\"message\":\"could not execute statement; SQL [n/a]; constraint [null]; nested exception is org.hibernate.exception.ConstraintViolationException: could not execute statement\",\"path\":\"/admin/v0/tenants/583\"}"
},
"redirectURL": "",
"headersSize": 415,
"bodySize": 761
},
"cache": {},
"timings": {
"blocked": 2,
"dns": 0,
"connect": 2,
"ssl": 33,
"send": 0,
"wait": 246,
"receive": 0
},
"time": 283,
"_securityState": "secure",
"serverIPAddress": "127.0.0.1",
"connection": "9000"
}
]
}
}
Не могли бы вы обойти обходной путь, чтобы добавить в мой сценарий Robot Framework?
Заранее благодарю за помощь