Script is getting hang in ie browser only - automated-tests

I want to execute this code in IE11 but it goes in hang mode not clicking in yes button could not understand the reason meanwhile its working fine in chrome and FF
Tried with option -e --skip-js error
import { Selector } from 'testcafe';
fixture(' testcafe ie issue')
.page('https://www1.shoppersdrugmart.ca/en/home');
test('testcafe ie issue', async (t) => {
const medicalCannabisImage=Selector('.wg-hdr-nav-img').nth(0);
const ageGatePopUp = Selector('.age-gate');
const pageContainser=Selector('div#app')
const yesAgePopUp = Selector('[data-auid="age-gate-primary"]');
await t.click(medicalCannabisImage);
if (await ageGatePopUp.exists) {
await t.click(yesAgePopUp);
}
});
I want to execute this code in IE11 but it goes in hang mode not clicking in yes button could not understand the reason meanwhile its working fine in chrome and FF.

We've reproduced this problem and found that its cause is related to this GitHub issue:
Not finding an element in IE11 
The fix is on its way according to the team's comments.
UPDATE:
The fix is ready and is available in version testcafe#v1.0.0-alpha.2.

Related

Can not click on the PayPal button inside the iframe - Cypress

I am writing e2e Testcases on Cypress for webshop, we have integrated PayPal and I am unable to click on the PayPal button with in the iframe.
I always get an error in finding the element in iframe.
someone have an idea how can I do that?
code
cy.get('iframe')
.getframe3D()
.find('paypal-button-number-0')
Command
Cypress.Commands.add('getframe3D', { prevSubject: 'element' }, $iframe => {
return new Cypress.Promise(resolve => {
$iframe.ready(function() {
resolve($iframe.contents().find('body'));
});
});
});
Interacting with iframe is quite tricky in Cypress however it's possible. Your custom command looks correct and it worked for me as well. However, you can also try below way and check if it is working for you.
Here provide CSS selector for the iframe as an argument getIframeBody() function.
cy.getIframeBody('iframe').find('paypal-button-number-0').click()
Custom Commands
Cypress.Commands.add('getIframeBody', (iframe) => {
return cy.get(iframe).then($iframe => {
const $body = $iframe.contents().find('body')
cy.wrap($body)
})
})
For more info you can follow the cypress blog to interact with iFrame
Your custom command to get the iframe body is fine, you just have the wrong selector for the button.
Since it's a class, you need a . prefix
cy.get('iframe')
.getframe3D()
.find('.paypal-button-number-0')

Electron's shell.openExternal opens a new window in internet explorer

I am using shell.openExternal(url) method in my push notifications electron app. Onclick of the received push notifications,a new window opens in internet explorer but I want the same to be opened in Chrome.Is it possible?
You can use Child process :
const { exec } = require('child_process');
exec('/usr/bin/chromium-browser https://example.com', (error, stdout, stderr) => {
if (error) {
console.error(`exec error: ${error}`);
return;
}
console.log(`stdout: ${stdout}`);
console.log(`stderr: ${stderr}`);
});
But you must know on which OS you are to give the correct browser executable path.
The previous code works on Linux.
shell.openExternal(url) will open the link in the System Default Browser. Hence, if you want to open it in Chrome, then make it as the default Browser.

MessengerExtensions.requestCloseBrowser() won't close in desktop

When i try to close the webview with this code:
MessengerExtensions.requestCloseBrowser(function success() {}, function failure(err) {
alert('error closing the window: ' + err); // error closing the window:
console.log(err); // doesn't print
window.close();
});
it closes the webview in iOS, but pops an alert when i try from desktop.
My domain is white-listed, messenger_extensions = true and i enter the page from the desktop messenger and it still doesn't work.
I had before the same problem, but opposite (window closed on desktop, but not on iOS) while trying to use fetch(), and this problem started when started using $.ajax()
before MessengerExtensions.requestCloseBrowser() was invoked from a fetch's promise, and now it's invoked from ajax's success function.
I had to switch fetch with ajax because it didn't work on iOS
Any suggestions?
A day later an error code of 2071011 started to show up, again, only in desktop browsers.
I managed to find a workaround the problem by using window.top.close(); when MessengerExtensions.requestCloseBrowser() fails
It does the same trick on Chrome and asks the user before close on Edge
window.extAsyncInit = function() {
MessengerExtensions.requestCloseBrowser(function success() {
window.close(); // webview closed
}, function error(err) {print ('an error occured');}
);
};
From the documentation on https://developers.facebook.com/docs/messenger-platform/webview/extensions,
window.extAsyncInit() will be called when the Messenger Extensions JS
SDK is done loading. You can use this as a trigger to call other
functions available in the SDK.

jQuery .load() CSS not applying in Safari 6 for Mac, works in Chrome and Firefox

I have a strange problem. I have a PHP controller that dynamically generates HTML that jQuery.load() calls on to update the main content area of a website without updating the headers or footers.
Everything is working fine in Firefox and Chrome for Mac OS but when I totally clear the cache and load the page in Safari 6 for Mac OS X the styles are only partially applied (they are the same for all of the items in this CSS class):
If I reload the page and navigate so jQuery fires another .load() this time it works fine, like this:
Other posts said to reload the CSS as a .load() callback but that doesn’t seem to be the problem here, is it?
Is this a bug? It’s working in 2 other browsers.
UPDATE:
Here is the jQuery powering the .load()
$("#main-content").on("click", "#residential a, #commercial a, #industrial a", function() {
var link = $(this).attr("href");
link = link.slice(1);
if (link == window.name) {
}
else {
window.name = link;
$("#main-content").fadeOut(500, function() {
$(this).load('index.php?jQueryLoad=true&url=' + link, function() {
$("#carousel").show();
flexsliderload();
});
$(this).fadeIn(500);
});
}
return false;
});

How to ignore "Content-Disposition: attachment" in Firefox

How can I cause Firefox to ignore the Content-Disposition: attachment header?
I find it absolutely annoying that I can't view an image in the browser, because it asks me to download it.
I don't want to download the file, I just want to view it in the browser. If the browser doesn't have a plugin to handle it, then it should ask to download.
E.g. I have Adobe Acrobat Reader installed as a plugin for Firefox. I click a link to a PDF, and it asks me to save it, when it should open in the browser using the plugin. This is the behaviour if the server does not send the Content-Disposition: attachment header in the response.
Firefox 3.6.6
Windows XP SP3
Legacy InlineDisposition 1.0.2.4 by Kai Liu can fix this problem.
In the Classic Add-ons Archive at:
caa:addon/inlinedisposition
The "Open in browser" extension is useful for formats supported natively by the browser, not sure about PDF.
Legacy version 1.18 (for users of browsers such as Waterfox Classic) is in the Classic Add-ons Archive at:
caa:addon/open-in-browser
I also found this tonight that totally prevents Firefox from littering your desktop with downloads. It's actually a redirect fix to the hidden /private/temp folder in MAC. Genius.
You can mimic the Windows behaviour simply by changing [Firefox's]
download directory to /tmp.
To do this, open Firefox's General preferences pane, under Save
Downloaded Files To select [choose].... In the dialog that appears,
hit Shift-Command-G to bring up the Go to Folder dialog.
In this dialog, simply type /tmp, hit OK, then hit Select in the
main window.
Well, that's the purpose of disposition type "attachment".
The default behavior (when the header is absent) should be to display in-line.
Maybe there's a configuration problem in your browser, or the Reader plugin?
For PDFs there is an addon called PDF-Download which overrides any attempt to download a PDF and lets the user decide how they want it downloaded (inline, save, external, etc). You could probably modify it to work for other filetypes too.
You could write a firefox extension that removes the disposition header for PDF files. This would be a fairly simple extension.
Since I was looking for a solution and no available add-on was actually working with my Firefox 31.0 (Ubuntu) I decided to try creating my own add-on.
The code if you want to archive a similar goal or just want to know how it works.
console.log("starting addon to disable content-disposition...");
//getting necessary objects
var {Cc, Ci} = require("chrome");
//creating the observer object which alters the Content-Disposition header to inline
var httpResponseObserver = {
//gets fired whenever a response is getting processed
observe: function(subject, topic, data) {
if (topic == "http-on-examine-response") {
var httpChannel = subject.QueryInterface(Ci.nsIHttpChannel);
httpChannel.setResponseHeader("Content-Disposition", "inline", false);
}
},
//needed for this.observerServer.addObserver --> without addObserver will fail
get observerService() {
return Cc["#mozilla.org/observer-service;1"].getService(Ci.nsIObserverService);
},
//used to register with an observer
register: function() {
console.log("register with an observer to get response-events");
this.observerService.addObserver(this, "http-on-examine-response", false);
},
//used to unregister from the observer
unregister: function() {
console.log("unregister from observer");
this.observerService.removeObserver(this, "http-on-examine-response");
}
};
//gets called at enable or install of the add-on
exports.main = function(options, callbacks) {
console.log("content-dispostion main method got invoked");
//call register to make httpResponseObserver.observe get fired whenever a response gets processed
httpResponseObserver.register();
};
//gets called on disable or uninstall
exports.onUnload = function(reason) {
console.log("content-dispostion unloaded");
//unregister from observer
httpResponseObserver.unregister();
};
/*
//not needed!!! just test code for altering http-request header
var httpRequestObserver =
{
observe: function(subject, topic, data)
{
console.log("in observe...");
console.log("topic is: " + topic);
if (topic == "http-on-modify-request") {
var httpChannel = subject.QueryInterface(Ci.nsIHttpChannel);
httpChannel.setRequestHeader("X-Hello", "World", false);
}
},
get observerService() {
return Cc["#mozilla.org/observer-service;1"].getService(Ci.nsIObserverService);
},
register: function()
{
this.observerService.addObserver(this, "http-on-modify-request", false);
},
unregister: function()
{
this.observerService.removeObserver(this, "http-on-modify-request");
}
};
httpRequestObserver.register();
*/
As an alternative you can get my xpi-File to directly install the add-on in Firefox. If you want to disable the "Content-Disposition" altering just deactivate the add-on ;-).
http://www.file-upload.net/download-9374691/content-disposition_remover.xpi.html

Resources