Unable to click button on popup confirmation in Testcafe - testing

I want to click Yes on confirmation button, here's the script.
.click(Selector('button').withAttribute('class', 'btn btn-default').withText('Yes'))
But I got an error: The element that matches the specified selector is not visible.
Here's the snippet code of the app
I tried visible in expected, like below
.expect(Selector('.btn.btn-default').withText('Yes').visible).ok()
.click(Selector('.btn.btn-default').withText('Yes'))
but got error:
AssertionError: expected false to be truthy

try
await t.click(Selector('.jconfirm-buttons).find('button').withText('Yes'))

Related

Cypress tests removing certain attributes from the page

Has anyone faced this with Cypress?
When I run my test using cypress, a particular test, keeps failing because hidden element is not showing up but when I run the same test manually, I can see the element with the hidden element showing up as soon as I enter value.
There is a field in our UI where if I pass invalid characters, then it should immediately show the hidden error element using aria, but this is not happening when running through cypress.
Desired behavior
When I run the same above test manually on the same field the result I am getting is this.
Cypress test Result:
Actual Result:
Code :
I think with <pvd-system-message> you have a shadow-root preventing access to the text inside you element.
Try
cy.get('#address-cityNameError')
.should('have.attr', 'message')
.shadow() // inside shadow-root
.should('contain', 'City contains invalid characters')
In case there are other tests with this problem, add includeShadowDom option to your config.
Ref Configuration options
cypress.config.js
const { defineConfig } = require('cypress')
module.exports = defineConfig({
e2e: {
baseUrl: 'http://localhost:1234',
includeShadowDom: true
}
})

How to show custom notifications or error message at admin panel for prestashop 1.7.7.7?

​
Hi, 
I've been trying a lot of options to manage an exception and show an error at admin panel but nothing seems to work.
I'm at the postProcess method of a custom module. After the user sends a csv file through a form and the data is checked (everything works fine here), if an exception occurs I need to show a message, stop and redirect to the same page. 
I've tried this: 
this->get('session')->getFlashBag()->add('error',$msg);
Tools::redirectAdmin('index.php?controller='.$controller.'&token='.$token);
this: 
header("HTTP/1.0 400 Bad Request");
die(json_encode(array( 'error' => array($this->l(' Error') ))));
(that one works but shows a blank page with the message, not the message inside the admin panel) 
also this: 
$this->context->smarty->assign(array(
'token' => Tools::getAdminTokenLite('AdminModules'),
'errors' => $this->errors
));
$this->setTemplate('ExcelProcess.tpl');
and {$errors|var_dump} at the tpl displays null...
... and many other options. 
I can't find anything either about backoffice custom notifications at the PS docs, only about front custom notifications.
Any clue? 
 
Thanks a lot! 
Miguel
PostProces code: https://drive.google.com/file/d/175nhUPDlzi6T8rZjjE8Desnzq-mtYzNQ/view?usp=sharing
​Tpl code: https://drive.google.com/file/d/17EONOCJ60L4Gp_GidzvwCQwMyTrRXapF/view?usp=sharing
Adding an error in postProcess() can be achieved by setting
$this->errors[] = $this->l('My error');
or
$this->context->controller->errors[] = $this->l('My error');
during your form submission checks.
Form will be rendered with your error messages into a red box.
If you want to show an alert without reloading the page instead, you'll have to perform an AJAX call to your AdminController, get back a JSON response and render your error message as a result of the execution of the call.
See offical docs

DisplayReplyAllForm is showing popup blocker alert in IE and Edge

I am trying to open reply email using DisplayReplyAllForm, it is showing popup blocker alert in IE and Edge.
Office.context.mailbox.item.displayReplyAllForm(
{
'htmlBody' : emailBodyHtml,
'callback' : function(asyncResult)
{
console.log('reply mail with asyncResult.value ==> ' + asyncResult);
}
});
I am trying to execute this code in a function which will be called by button onclick handler.
Error View :
This is stopping us from app store submission. What is the fix for this?

Handling popups inside casperjs test

I'm trying to make a test for a login webpage where there is the possibility of using Thirdparties social login. When you click on facebook icon, for example, a new popup appears asking for user/password. I'm using waitForPopup and withPopup as specified by the documentation to handle that, but is not working. Is never finding the element (via xpath) inside the xpath, so I can never log in using facebook in our test.
This is an example code that check if the facebook button is there, click on it and wait for the popup:
casper.then(function() {
test.comment("When we click facebook button");
casper.waitForSelector(x(facebookButton), function() {
test.assertExists(x(facebookButton), "Facebook icon is showing");
casper.click(x(facebookButton));
}, function timeout() { // step to execute if check has failed
casper.test.fail("Timeout loading login page");
});
});
casper.then(function() {
casper.waitForPopup(/facebook\.com\/login/, function() {
test.comment("And we fill facebook login info");
casper.withPopup(/facebook\.com\/login/, function() {
this.viewport(1600, 900);
casper.sendKeys(x(facebookEmail), facebookLogin[0]);
casper.sendKeys(x(facebookPassword), facebookLogin[1]);
casper.click(x(facebookLogin));
});
}, function timeout() { // step to execute if check has failed
casper.test.fail("Timeout loading faceebook login");
});
});
The output of the test is:
# When we click facebook button
PASS Facebook icon is showing
# And we fill facebook login info
FAIL Cannot get informations from xpath selector: //input[#id='email']: element not found.
# type: uncaughtError
# file: casper/import-login-testing.js:1058
# error: Cannot get informations from xpath selector: //input[#id='email']: element not found.
# CasperError: Cannot get informations from xpath selector: //input[#id='email']: element not found.
# at getElementInfo (/Users/ginogalotti/testing-presentation/node_modules/casperjs/modules/casper.js:1058)
# at /Users/ginogalotti/testing-presentation/node_modules/casperjs/modules/casper.js:1589
# at casper/import-login-testing.js:84
# at runStep (/Users/ginogalotti/testing-presentation/node_modules/casperjs/modules/casper.js:1553)
# at checkStep (/Users/ginogalotti/testing-presentation/node_modules/casperjs/modules/casper.js:399)
# stack: not provided
For me, that means that is finding the popup, the waitForPopup is triggering and is just not using the popup to look for the facebookEmail element. I'm still learning about casperjs, so probably this is not even the best way to approach the problem; but I would really thank some guidance.
Thanks in advance,
Example website that I'm testing: https://import.io/login

XMLHttpRequest not working properly in Safari (but works with Chrome)

I have the following code to load a file after creating a web page which displays a WebGL canvas:
// Load ccconnect.js file
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
if(xmlhttp.readyState == 4){
eval.call( Window, xmlhttp.response );
}
};
xmlhttp.open("GET","../ccconnect.js",true);
xmlhttp.send(null);
It works fine in Chrome but Safari brings up an error saying:
ReferenceError: Can't find variable: Window
on the line eval.call(...). The ccconnect.js code is displayed when I hover the mouse over 'response' on that same line when debugging so it seems to have retrieved it. Any idea what is wrong? I'm using Safari 5.1.5.
both window and Window is the global object both are understand by other browsers.
but when I checked in safari, it don't understand the variable Window. So my suggestion is replace Window with window.