What's the correct way to close and open the browser within a Geb test? |
Add in your test, for save sessions cookies.
autoClearCookies = false
link
|
emitting data via socket on browser close /window close |
When user connects - register on server side the time it happened.
Socket.IO has heart beating and pinging functionality. So just subscribe to
disconnect event on server side and once it happens - means client
disconnected - and you have on server time when client had connection. So
that way you have timespan of client session.
Do not trust client to tell you any time or important data, as client can
simply 'lie' - which leads to hacks/cheats/bugs on your server-side.
There is no reliable way to send data just before disconnect from
client-side at all. There is nothing in Socket.IO for that, nor in just one
of transports (WebSockets). As well as there is too many different
scenarios of disconnection (power off, force close, ethernet cable out,
wifi lose, etc).
|
spec test export csv files |
FWIW -- looking at a method afterward and trying to come up with a spec
leads to frustration, guilt, and binges. If you were to create this using
TDD, it would be broken up into small methods that were easy to verify.
Hint: break up your code into small methods. test those methods.
|
How to test inserting a has_many relation with spec? |
You should check Shoulda-matchers gem.
You also can try using the syntax:
it { should have(1).error_on :role }
Basically you have access to the errors from your spec and can check that
there is one on the field you want to have one.
|
Can protractor test a login that is not angular based |
After placing the issue on github I received the answer I was looking for.
This can be found HERE!
Protractor requires that Angular be present on the page and the way around
this is to use the driver directly. Following the link above should stear
anyone stuck on the same issue in the right direction.
Kudos to JulieMR and the others who helped out with this issue.
|
minitest-spec-rails went wrong when I make some functional test |
Rails expects controller names to be plural, like so:
PublishersController
Your test is using a singular controller name, PublisherController, which
doesn't exist. This can be caused by a typo when using generators.
To fix it, change Publisher to Publishers. Remember to change the filename
as well.
|
How can I test the presence of cookies using a Rails integration/feature spec? |
To my understanding cookies shall not be tested in integration
tests.Inspecting the values set during integration test with debugger
revealed that the response object was nil and cookies set were empty. My
solution , was to separately write controller spec to check if cookies are
set, and to test rest of behavior in integration specs.
Plus relish cookies section explicitly states, that controller spec expose
ways to access cookies.
|
How to restart Heroku app from browser |
If you have Android you can use
https://play.google.com/store/apps/details?id=net.cyberstride&hl=en
If you have an Iphone you can use
https://itunes.apple.com/gb/app/nezumi-for-heroku/id346715875?mt=8 or
https://itunes.apple.com/gb/app/iroku-for-heroku/id667837229?mt=8
|
Close DB connection on browser close |
No, there is no way. At least, no reliable way. You could perhaps set the
session timeout to 1 minute, keep it alive with ajax polling and use
HttpSessionListener#sessionDestroyed() to close the connection. But still,
the whole approach is very brittle and prone to failure.
You should always acquire and close the DB resources in the shortest
possible scope within the very same try-finally block as where the SQL
query/queries are fired, no excuses. A Java EE web application is really
not comparable to a plain Java desktop application where the enduser can
just restart the buggy application itself if it crashes due to DB resource
leaking.
See also:
Is it safe to use a static java.sql.Connection instance in a multithreaded
system? — whilst not exactly the same problem/question as yo
|
PHP - Session is set after browser restart, but PHP acts as isn't |
Just because you are setting your session_id in some cookie doesn't mean it
is THE session cookie. Most browsers will purge session cookies on browser
close. This is what you are seeing. Look at the cookies in your browser
that are set when your session is valid and compare this to the cookies
that are still remaining after browser restart. You will notice your true
session cookie has gone missing.
|
expects() of a spec visible outside to other specs when running 'rspec spec' |
Based on the comment thread, this appears to be a rather serious
incompatibility between the ruby, rspec and mocha versions you cited. No
such issue has been submitted to mocha's github site, let alone included in
their "Known Issues" documentation.
Although the mocha gem seems to have been implicitly deprecated for rspec
use by the rspec-rails-mocha gem you subsequently tried, you might want to
submit an issue against mocha. If you want to be a particularly good
citizen, you could try out ruby 2.0 and rspec 2.14 before doing so to see
what impact they have.
|
Remember me in Symfony2 not working after restart browser |
If you are using another property than Username to authenticate the user,
then the cookie might be saving the username while your script expects
another property, like email.
You can override the default remember me service behavior. See this answer:
http://stackoverflow.com/a/20550520/3096524
|
How to keep cookies from expiring even after browser restart in CakePHP application |
update
session.cookie_lifetime specifies the lifetime of the cookie in seconds
which is sent to the browser. The value 0 means "until the browser is
closed." Defaults to 0. See also session_get_cookie_params() and
session_set_cookie_params().
I think setting your session.cookie_lifetime to such a high value will mean
you will have many stale sessions on your server and this might be a issue
if you have large numbers of sessions - typically sessions are stored in
the system's /tmp folder. When this folder, typically on *nix machines,
fills up it could cause problems on the machine - processes start locking
up as they fail to create temporary files for whatever reason. (You can
change the session.save_path to something other than /tmp so you don't have
this issue - especially on shared hos
|
Chrome extension losing requested permissions after browser restart |
For me the following reported issue answered my question:
Issue 158004: chrome.permissions.request support for user-supplied URL.
To make it clear: It is not possible to request a subset of the permissions
defined in optional_permissions. If you define http://*/* then you need to
request exactly this string! A subset like http://example.org/* wont work!
Here is a quote from a comment in the issue description which makes that
clear:
"There's no wildcard handling, just plain string comparison between the
URLPatterns"
The Issue has been fixed in Revision 182287
The only thing left is to cross your fingers that this fix gets included in
a upcomming chrome release soon. We'll have to use the bloody Access your
data on all websites permission in the meanwhile.
|
Error "Unable parse file browser.yml" when running a test with Magento automation test framework |
I've resolved this by upgrading the Symfony Yaml package to the latest
version:
pear channel-discover pear.symfony-project.com
pear install symfony/YAML
Seems that the "---" syntax is supported on v. 1.0.6 (the latest stable at
this moment).
|
How do i restart nginx only after the config test was successful on ubuntu? |
Actually as far as i know, nginx would show an empty message and it won't
actually restart if the config is bad, the only way to screw it up is by
doing an nginx stop then start again, it would succeed to stop but fail to
start.
|
UnitTestIsolation instrumentation failed to initialize. Please restart Visual Studio and rerun this test |
This error is reported when the shims runtime is unable to connect to the
IntelliTrace profiler, which provides runtime instrumentation necessary to
detour CLR methods. The IntelliTrace profiler is automatically started by
the CLR when the COR_PROFILER environment variable is set for the test
runner process (vstest.executionengine*.exe). If the shims runtime reports
this error, it means something went wrong and the COR_PROFILER variable was
not set correctly and the IntelliTrace profiler was not loaded.
There are several potential causes of this problem. It is hard to tell
without a closer look. In Visual Studio 2012, you can find additional
information about it from the application event log. In Visual Studio 2013,
this information is included in the exception error message itself.
|
Installscript : How to close explorer windows without restart of explorer.exe process? |
I'm sure you could call FindWindow and use SendMessage to close the
explorer windows but the explorer.exe process will still be running and
you'll still have a file lock.
Windows Installer can delete locked files on reboot. If you don't want the
reboot, you'll have to kill and restart explorer.
I know of no other patterns here.
FindWindow Example
WM_SYSCOMMAND message
|
Why I don't close browser by webdriver? |
Rather than using @ Before you can try...
@BeforeClass
baseUrl = "http://localhost:8080/";
driver = new FirefoxDriver();
driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
driver.get(baseUrl);
and @AfterClass
driver.quit();
So try using this it works for me.
|
Notify user on browser close only |
I just want to work this code only for browser refreshing and closing. Is
there a way to catch the refresh or browser cosing so that can use it.
No. Instead, you'll have to capture each link and form submission and
either set a flag telling your onbeforeunload handler not to return a
string, or removing your onbeforeunload handler (probably the flag is
cleaner).
For example:
var warnBeforeClose = true;
function unloadPage(){
if (warnBeforeClose) {
return "Your changes will not be saved.";
}
}
window.onbeforeclose = unloadPage;
// ...when the elements exist:
$("a").click(dontWarn);
$("form").submit(dontWarn);
function dontWarn() {
// Don't warn
warnBeforeClose = false;
// ...but if we're still on the page a second later, set the flag again
setTimeout
|
How can I implement a Close Tab Listener of my Browser Tab? |
You can listen for an onbeforeunload event
See Eli Grey's answer below
Intercept page exit event
|
Close the browser window in Vaadin |
Read https://vaadin.com/book/vaadin6/-/page/application.close.html if you
haven't done so far.
If appRef is already your Application, you do not have to call
appRef.getMainWindow().getApplication() to get the Application. Just do
appRef.close();
Do not invalidate the session manually. It messes with the vaadin
lifecycle, so the next lines are not executed anymore, at least not in the
vaadin context. Just do "application.close()" and let vaadin do the rest.
In vaadin 6 "window.close()" works, i use it with IE and chrome. So after
you removed the session invalidation stuff, your code
appRef.getMainWindow().executeJavascript("window.close()"); will work as
expected.
|
what happens on a running php exeutable when i close browser? |
By default the PHP process gets torn down the next time it tries to send
output to the client¹, although you can change this behavior by using
ignore_user_abort. For additional related information, read the manual
section on connection handling.
¹ Note that in the presence of output buffering by PHP or by the web
server, "echoing something" does not necessarily equal "output is sent to
the client"; see flush.
|
Calling JS functions on browser tab close |
JSFiddle uses the following to alert the user they are trying to close
their modified fiddle without saving:
window.onbeforeunload = function(){
if (window.editorsModified){
return "You've modified your fiddle, reloading the page will reset all
changes."
}
};
This works reliably (http://jsfiddle.net/MaxPRafferty/b6uEF/show/ ,Latest
Chrome, FF, IE10 ), but will always prompt the user. You can't force the
page open by returning false;
|
How to clear database entries on browser close in jsf? |
Listening on browser close is not reliable. You can use beforeunload event
for that, but this is not supported on every webbrowser the world is aware
of and even disableable/spoofable/hackable by the enduser. Then we're not
talking about the race condition during firing the ajax request: would the
ajax request arrive in its entirety right before the browser is closed?
More than often this is not the case and the browser close wins over the
ajax request.
Just listen server side on session expiration instead.
@WebListener
public class MyHttpSessionListener implements HttpSessionListener {
@Override
public void sessionCreated(HttpSessionEvent event) {
// NOOP.
}
@Override
public void sessionDestroyed(HttpSessionEvent event) {
HttpSession session = event
|
why is my php session in the smartphone can't be destroyed after i close the web browser? |
"Session" stored not on your phone - whatever its name.
Its stored on the web-server.
Browser send to the server only id of the session - using different
methids. Server identify this id to track this uniq browser "session" and
get data from stored session file or another method of session storage.
When you close your browser - server known nothing about it. Ther is some
processes on the server - common named GC (garbage collectors) who clean up
old expired session files.
Please read Sessions reference
|
as3 close browser window with externalinterface.call |
Unfortunately closing browser windows via flash->java in very hit and miss.
You will find that it will work in some browsers but not others.
From what I understand, this is because of an attempt by Adobe to prevent
certain behaviours being used maliciously.
Sorry I don't have a better answer for you.
|
Close a single tab in browser using windows application c# |
Sorry i don't have the comments previlages but this is same in somwhat
manner it might help you acessing browser tabs
|
IE9 cookies not working once browser is close and open? |
You shouldn't be using javascript with your login cookie.
Use SSL, and useSSL-only cookies.
Create the cookie on the server, with the HTTP-only flag.
Store an authentication ticket in the cookie, not the password.
Don't store the user's password in your database, store a salted hash.
Otherwise, for cookies, you can try
http://docs.sencha.com/extjs/4.2.1/#!/api/Ext.util.Cookies to make it
easier.
|
PHP ob_end_flush() doesn't close browser connection |
This has nothing to do with PHP. Your new server probably supports Keep
Alive connections (which your browser most certainly solicits) causing the
connection to remain open for subsequent requests. Try adding
Header("Connection: close") to your script or turn off Keep Alive support
in your web server.
|
Text to speech still plays even after tab or browser close |
I don't know much about the API you're using but I think you can use the
Pause method. Look at this link. As this is server side code you'll need to
do something like this to detect when the browser closes.
|
PHP - Session expire date is set, but session is still cleared on browser restart |
Well, it doesn't exactly answer my question but @sectus "What about other
browser?" provided (unexpectedly enough) the missing link.
It turns out it was my browser, Google Chrome who reset my session, in
FireFox it worked perfectly...
|
How to show custom pop up when detect browser close event? |
You cannot. Imagine an advertiser adding code to display a popup advert
when the window is closed, or a trickster adding a popup which has "OK" and
"Cancel" reversed or non-functional; it's back to the old days of the
internet when browsers were too trusting and users were left occasionally
needing to force-quit the browser just to escape a page.
To prevent it, these days sites are allowed to display a block of text
within a standard popup. You have no more control than that.
The best proof I can offer is this: go to an online email provider and
close the window while uploading something, or jsfiddle and close the
window after editing something, or any major site where you can edit things
without an autosave. Notice that they use the browser-standard popup. If
there were an alternative,
|
Prevent accidental close of browser window while submitting |
Can you add the JS code when the user submits the form?
<form action="upload.php">
<input type="file" name="myfile" />
<input type="submit" />
</form>
upload.php
<?php
// Validate the data, copy the file, etc.
echo '<script>window.onbeforeunload = function(e) { return "Please
make sure, the video has finished uploading before closing this window";
}</script>';
?>
That should work. However, I think you should give the option to leave:
<?php
echo '<script>window.onbeforeunload = function(e) { return
confirm("Do you want to leave?"); }</script>';
?>
|
Close browser window after opening Custom Protocol |
What about if you try to navigate into a <iframe> instead of a new
window?
Try to add a new <iframe> to the DOM, navigate to your custom url,
then remove the <iframe> from the DOM. Do not bother to load the
close.html page.
(disclaimer: to be honest, it's just an idea, I did no tried)
|
How to trigger a browser window or tab close event with jQuery |
You can use unload() on the window property in jQuery:
$(window).unload(function() {
//do stuff
});
You don't need jQuery to do it though, you can use good ol' fashioned
JavaScript:
window.onbeforeunload = function(e){
var msg = 'Are you sure?';
e = e || window.event;
if(e)
e.returnValue = msg;
return msg;
}
|
How to test if two numbers are close in Clojure |
You'll need to define "close". If you ask for a "difference" of less than
some tolerance, you can roll your own function using <:
(defn close? [tolerance x y]
(< (difference x y) tolerance))
Where difference might be absolute:
(defn absolute-difference ^double [^double x ^double y]
(Math/abs (double (- x y))))
or relative:
(defn relative-difference ^double [^double x ^double y]
(/ (Math/abs (- x y))
(max (Math/abs x) (Math/abs y))))
(pick your preferred definition of relative difference, of course).
Then (partial close? 0.001) will test approximate equality with tolerance
of 0.001.
To discover limits on useful values of the tolerance parameter you can use
Math/ulp, which is a static method which takes a double and returns the
absolute difference between it and t
|
How to close the current window in browser after clicking ok in the alert message? |
Just put the statements one after each other :
alert("ok");
window.close();
EDIT following Ankit's remark to OP : note that if you didn't open the
window with Javascript yourself, you may not be authorized to close it
depending on the browser.
|
How to close EXTJS form panel when clicked in rest of the browser area. |
You can register a listener on the body element. Here's a simple example:
var panel = new Ext.Panel({
cls: 'the-panel',
width: 400,
height: 400,
renderTo: Ext.getBody()
});
Ext.getBody().on('click', function (event) {
var targEl = Ext.get(event.getTarget());
if (targEl === panel.getEl() || targEl.up('.the-panel')) {
//clicked on or within the panel, do nothing
} else {
panel.close();
}
});
You'll likely want to enhance the example above such that the event is
unregistered once the panel is closed.
|
On browser close, JavaScript does not always call a custom server side method (Asp.Net/C#) |
Aha, we had one of those problems a while back, where we absolutely needed
to give our server notification that the window has closed. We noticed that
only Firefox would obey requests made inside onbeforeunload. Finally, the
solution is as follows:
$(window).unload(function () {
$.ajax ({
url: "...",
data: "(what you want to send)",
async: false // THIS
});
});
What's more peculiar is that neither window.onunload nor
window.onbeforeunload worked for us; not back then at least.
|