I'm using ruby on rails to develop this webapp that only supports the latest browser.
How do i show a pop-up message when user is using unsupported browser.
The message will show when the page is not loaded in the following browser:
Firefox 4 and above
IE9 and above
Safari 5 and above
Chrome 10 and above
jQuery Browser Rejection Plugin can help you. it supports following browsers disable/enable options:
msie: false,msie5: true,msie6: true,msie7: false,msie8: false, // MSIE Flags (Global, 5-8)
firefox: false,firefox1: false,firefox2: false,firefox3: false, // Firefox Flags (Global, 1-3)
konqueror: false,konqueror1: false,konqueror2: false,konqueror3: false, // Konqueror Flags (Global, 1-3)
chrome: false,chrome1: false,chrome2: false,chrome3: false,chrome4: false, // Chrome Flags (Global, 1-4)
safari: false,safari2: false,safari3: false,safari4: false, // Safari Flags (Global, 1-4)
opera: false,opera7: false,opera8: false,opera9: false,opera10: false, // Opera Flags (Global, 7-10)
gecko: false,webkit: false,trident: false,khtml: false,presto: false, // Rendering Engines (Gecko, Webkit, Trident, KHTML, Presto)
win: false,mac: false,linux : false,solaris : false,iphone: false, // Operating Systems (Win, Mac, Linux, Solaris, iPhone)
unknown: false // Unknown covers everything else
It is very simple using jreject_rails gem
Just need to call function into your javascript file.
$(function() {
$.reject({
reject: {
msie5: true,
msie6: true,
msie7: true
}
});
});
Make those versions true which your site don't support.
Let me know If you any issue to implement. It works for me.
Related
I want to run a basic script that takes a screenshot of the tv schedule each day on a specific url, the url in question has a cookies pop up that requests to be accepted before the rest of the page is displayed, this obviously gets in the way of my intended screenshot, a similar post (Pupeteer - how can I accept cookie consent prompts automatically for any URL?) had a solution that suggested to download the chrome extension 'I don't care about cookies' and then run puppeteer with google chrome with this extension installed, I have installed the extension and ran puppeteer with chrome but the extension does not seem to show up in the chrome window that puppeteer creates, how do I fix this so the extension is there when I run chrome using puppeteer? note: I am intentionally using regular chrome not chromium for this reason, chromium does not allow extensions with puppeteer.
my code:
const puppeteer = require('puppeteer-core')
async function main() {
const browser = await puppeteer.launch({
headless: false,
slowMo:10,
executablePath: '/Applications/Google
Chrome.app/Contents/MacOS/Google Chrome',
args: [
'--disable-extensions-except=/Applications/Google
Chrome.app/Contents/MacOS/Google Chrome',
'--load-extension=/Applications/Google
Chrome.app/Contents/MacOS/Google Chrome',
]
});
const page = await browser.newPage()
await page.setViewport({
width: 980,
height: 480,
deviceScaleFactor: 2,
});
await
page.goto("https://www.tvguide.co.uk/mobile/channellisting.asp?
ch=145#588622936")
await page.waitForTimeout(15000); // wait for 15 seconds
await browser.close()
}
main();
Any reply would be greatly appreciated. Many Thanks.
I’ve been trying without success to change default language of browsers Chromium and Firefox (inside automated tests that run in parallel using CodeceptJS + Playwright as runner) to french language. In Chromium, I’ve tried to use args --lang without success and I’ve also tried to use prefs: intl.accept_languages. In Firefox, I’ve tried to use firefoxUserPrefs. Untill now, nothing has worked.
Does anybody know how to change default language in browser launched using playwright?
CodeceptJS version 3.0.6
Playwright version 1.10.0
Chrome version 90.0.4430.0
Firefox version 87.0b10
codecept.conf.js - full printscreen
codecept.conf.js
Playwright: {
url: process.env.baseUrl || DEFAULT_HOST,
show: true,
browser: 'chromium',
waitForAction: 250,
waitForNavigation: 'networkidle0',
chromium: {
channel: process.env.BROWSER,
args: ['--lang=fr-CA'],
prefs: {
'intl.accept_languages': 'fr-CA',
},
firefoxUserPrefs: {
'intl.accept_languages': 'fr-CA, fr',
},
},
},
browser.NewContext has an option called locale. You can use that option to change the language.
This might not have been available by the time of this question, but now there are emulation options for locale (and timezone) in Playwright (documentation here).
Can be specified both globally in config, per project, like this (in playwright.config.ts):
...
projects: [
{
name: 'chromium',
use: {
...devices['Desktop Chrome'],
locale: 'fr-CA',
},
},
...
or per test, like this:
test.use({
locale: 'sv-SE',
});
test('Lang test 1', async ({ page }) => {
// Test code
});
Does chrome support promise based APIs for WebRTC? I am not able to get the getUserMedia() promised based API working in Chrome.
<!DOCTYPE html>
<html>
<head>
<title> Mitel WebRTC client </title>
<script src="https://webrtc.github.io/adapter/adapter-latest.js"></script>
<script src='dist/webrtc.min.js'></script>
<script type="text/javascript">
function startUp() {
var options = {
audio: true,
video: true
};
if (getUserMedia) {
getUserMedia(options)
.then(function (stream) {
console.log("Acquired audio and video!");
})
.catch(function (err) {
console.log(err.name + ": " + err.message);
});
} else {
alert("WebRTC not supported on this browser");
}
}
</script>
</head>
<body onload="startUp();">
<h1>WebRTC Promise API Client Application</h1>
</body>
</html>
On the console, I see the following error
This appears to be Chrome
adapter-latest.js:32 chrome: {"audio":true,"video":true}
adapter-latest.js:410 Uncaught TypeError: Failed to execute 'webkitGetUserMedia' on 'Navigator': The callback provided as parameter 2 is not a function.
I want to make use of promise based API. Am I missing something?
It is not implemented yet in Chrome, but it works there if you use the official adapter.js WebRTC polyfill: https://jsfiddle.net/srn9db4h/
var constraints = { video: true, audio: true };
navigator.mediaDevices.getUserMedia(constraints)
.then(stream => video.srcObject = stream)
.catch(e => console.error(e));
Firefox and Edge support it natively FWIW.
Update: Chrome (50) appears to support this now. And Chrome 52 even supports srcObject.
To access navigator.mediaDevices you must to connect your site with HTTPS connection. There are no access this feature with HTTP.
https://developers.google.com/web/fundamentals/media/capturing-images/
Warning: Direct access to the camera is a powerful feature. It requires consent from the user, and your site MUST be on a secure origin (HTTPS).
Although this is not recommended but still you can try this to test your project by disabling security for media.
chrome://flags/#unsafely-treat-insecure-origin-as-secure
you can add your IP and chrome will treat it as secure.
You can also get this error if you're running Chrome your app in http. If so, you should run your app as https. Only localhost urls with http are supported by Chrome.
`http://jsfiddle.net/jib1/srn9db4h/ `
// not working
`https://jsfiddle.net/jib1/srn9db4h/`
//working with https
Firefox 23 supports the Web Audio API in theory; however, the following snippet that works in Chrome Canary fails in Firefox Aurora:
var theAudioContext = new AudioContext;
navigator.getUserMedia({"audio": true}, function(stream) {
var input = theAudioContext.createMediaStreamSource(stream);
// theAudioContext.createMediaStreamSource is not a function
},
function(){ /* err */ });
Is support for this API planned as part of Firefox in the future, or is there an alternate way to work with MediaStreams today?
We're working on support for MediaStreamAudioSourceNode, it will land in Nightly and Aurora soon. Please follow this bug if you're interested: https://bugzilla.mozilla.org/show_bug.cgi?id=856361
Straight from the first line of the HTML5 Rocks tutorial on web sockets it is not working.
var connection = new WebSocket('ws://html5rocks.websocket.org/echo', ['soap', 'xmpp']);
connection.onopen = function () { alert("open"); };
connection.onerror = function () { alert("error"); };
It works in chrome, opera, ie. It doesn't work in Safari. Am I doing something wrong?
http://jsfiddle.net/xSNpM/2/
apple stopped updating safari on windows. this works on an up to date version of safari.