This repository was archived by the owner on Jun 19, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +81
-0
lines changed Expand file tree Collapse file tree 2 files changed +81
-0
lines changed Original file line number Diff line number Diff line change @@ -667,6 +667,54 @@ Think of it as a way to stop javascript execution within the remote DOM environm
667
667
668
668
casper.run();
669
669
670
+ .. _casper_clearcache :
671
+
672
+ .. index :: Memory
673
+
674
+ ``clearCache() ``
675
+ -------------------------------------------------------------------------------
676
+
677
+ **Signature: ** ``clearCache() ``
678
+
679
+ .. versionadded :: 1.1.5
680
+
681
+ Replace current page by a new page object, with newPage() and clear the memory cache, with clearMemoryCache().
682
+ Example::
683
+
684
+ casper.start('http://www.google.fr/', function() {
685
+ this.clearCache(); // cleared the memory cache and replaced page object with newPage().
686
+ });
687
+
688
+ casper.then(function() {
689
+ // ...
690
+ });
691
+
692
+ casper.run();
693
+
694
+ .. _casper_clearmemorycache :
695
+
696
+ .. index :: Memory
697
+
698
+ ``clearMemoryCache() ``
699
+ -------------------------------------------------------------------------------
700
+
701
+ **Signature: ** ``clearMemoryCache() ``
702
+
703
+ .. versionadded :: 1.1.5
704
+
705
+ Use the engine page.clearMemoryCache() to clear the memory cache.
706
+ Example::
707
+
708
+ casper.start('http://www.google.fr/', function() {
709
+ this.clearMemoryCache(); // cleared the memory cache.
710
+ });
711
+
712
+ casper.then(function() {
713
+ // ...
714
+ });
715
+
716
+ casper.run();
717
+
670
718
.. index :: Debugging
671
719
672
720
``debugHTML() ``
Original file line number Diff line number Diff line change @@ -464,6 +464,39 @@ Casper.prototype.clear = function clear() {
464
464
return this ;
465
465
} ;
466
466
467
+ /**
468
+ * Replace currente page by a new page object, with newPage()
469
+ * Clears the memory cache, with clearMemoryCache()
470
+ *
471
+ * @return Casper
472
+ */
473
+ Casper . prototype . clearCache = function clearCache ( ) {
474
+ "use strict" ;
475
+ this . checkStarted ( ) ;
476
+ this . page = this . newPage ( ) ;
477
+ this . clearMemoryCache ( ) ;
478
+ return this ;
479
+ } ;
480
+
481
+ /**
482
+ * Clears the memory cache, using engine method
483
+ * reference: https://github.com/ariya/phantomjs/issues/10357
484
+ *
485
+ * @return Casper
486
+ */
487
+ Casper . prototype . clearMemoryCache = function clearMemoryCache ( ) {
488
+ "use strict" ;
489
+ this . checkStarted ( ) ;
490
+ if ( typeof this . page . clearMemoryCache === 'function' ) {
491
+ this . page . clearMemoryCache ( ) ;
492
+ } else if ( phantom . casperEngine === 'slimerjs' || utils . matchEngine ( { name : 'phantomjs' , version : { min : '2.0.0' } } ) ) {
493
+ this . log ( 'clearMemoryCache() did nothing: page.clearMemoryCache is not avliable in this engine' , "warning" ) ;
494
+ } else {
495
+ throw new CasperError ( "clearMemoryCache(): page.clearMemoryCache should be avaliable in this engine" ) ;
496
+ } ;
497
+ return this ;
498
+ } ;
499
+
467
500
/**
468
501
* Emulates a click on the element from the provided selector using the mouse
469
502
* pointer, if possible.
You can’t perform that action at this time.
0 commit comments