@@ -569,7 +569,7 @@ class Options extends Capabilities {
569
569
return extension . toString ( 'base64' )
570
570
}
571
571
return io
572
- . read ( /** @type {string } */ ( extension ) )
572
+ . read ( /** @type {string } */ ( extension ) )
573
573
. then ( ( buffer ) => buffer . toString ( 'base64' ) )
574
574
} )
575
575
}
@@ -622,7 +622,7 @@ class Driver extends webdriver.WebDriver {
622
622
* implementation.
623
623
* @override
624
624
*/
625
- setFileDetector ( ) { }
625
+ setFileDetector ( ) { }
626
626
627
627
/**
628
628
* Schedules a command to launch Chrome App with given ID.
@@ -776,34 +776,52 @@ class Driver extends webdriver.WebDriver {
776
776
* @param connection CDP Connection
777
777
*/
778
778
async register ( username , password , connection ) {
779
- await connection . execute ( "Network.setCacheDisabled" , this . getRandomNumber ( 1 , 10 ) , {
780
- cacheDisabled : true ,
781
- } , null ) ;
779
+ await connection . execute (
780
+ 'Network.setCacheDisabled' ,
781
+ this . getRandomNumber ( 1 , 10 ) ,
782
+ {
783
+ cacheDisabled : true ,
784
+ } ,
785
+ null
786
+ )
782
787
783
788
this . _wsConnection . on ( 'message' , ( message ) => {
784
789
const params = JSON . parse ( message )
785
790
786
791
if ( params . method === 'Fetch.authRequired' ) {
787
792
const requestParams = params [ 'params' ]
788
- connection . execute ( 'Fetch.continueWithAuth' , this . getRandomNumber ( 1 , 10 ) , {
789
- requestId : requestParams [ 'requestId' ] ,
790
- authChallengeResponse : {
791
- response : 'ProvideCredentials' ,
792
- username : username ,
793
- password : password ,
793
+ connection . execute (
794
+ 'Fetch.continueWithAuth' ,
795
+ this . getRandomNumber ( 1 , 10 ) ,
796
+ {
797
+ requestId : requestParams [ 'requestId' ] ,
798
+ authChallengeResponse : {
799
+ response : 'ProvideCredentials' ,
800
+ username : username ,
801
+ password : password ,
802
+ } ,
794
803
}
795
- } )
804
+ )
796
805
} else if ( params . method === 'Fetch.requestPaused' ) {
797
806
const requestPausedParams = params [ 'params' ]
798
- connection . execute ( 'Fetch.continueRequest' , this . getRandomNumber ( 1 , 10 ) , {
799
- requestId : requestPausedParams [ 'requestId' ] ,
800
- } )
807
+ connection . execute (
808
+ 'Fetch.continueRequest' ,
809
+ this . getRandomNumber ( 1 , 10 ) ,
810
+ {
811
+ requestId : requestPausedParams [ 'requestId' ] ,
812
+ }
813
+ )
801
814
}
802
815
} )
803
816
804
- await connection . execute ( 'Fetch.enable' , 1 , {
805
- handleAuthRequests : true ,
806
- } , null )
817
+ await connection . execute (
818
+ 'Fetch.enable' ,
819
+ 1 ,
820
+ {
821
+ handleAuthRequests : true ,
822
+ } ,
823
+ null
824
+ )
807
825
}
808
826
809
827
/**
@@ -813,7 +831,12 @@ class Driver extends webdriver.WebDriver {
813
831
* @returns {Promise<void> }
814
832
*/
815
833
async onLogEvent ( connection , callback ) {
816
- await connection . execute ( 'Runtime.enable' , this . getRandomNumber ( 1 , 10 ) , { } , null )
834
+ await connection . execute (
835
+ 'Runtime.enable' ,
836
+ this . getRandomNumber ( 1 , 10 ) ,
837
+ { } ,
838
+ null
839
+ )
817
840
818
841
this . _wsConnection . on ( 'message' , ( message ) => {
819
842
const params = JSON . parse ( message )
@@ -823,7 +846,7 @@ class Driver extends webdriver.WebDriver {
823
846
let event = {
824
847
type : consoleEventParams [ 'type' ] ,
825
848
timestamp : new Date ( consoleEventParams [ 'timestamp' ] ) ,
826
- args : consoleEventParams [ 'args' ]
849
+ args : consoleEventParams [ 'args' ] ,
827
850
}
828
851
829
852
callback ( event )
@@ -856,7 +879,12 @@ class Driver extends webdriver.WebDriver {
856
879
* @returns {Promise<void> }
857
880
*/
858
881
async onLogException ( connection , callback ) {
859
- await connection . execute ( 'Runtime.enable' , this . getRandomNumber ( 1 , 10 ) , { } , null )
882
+ await connection . execute (
883
+ 'Runtime.enable' ,
884
+ this . getRandomNumber ( 1 , 10 ) ,
885
+ { } ,
886
+ null
887
+ )
860
888
861
889
this . _wsConnection . on ( 'message' , ( message ) => {
862
890
const params = JSON . parse ( message )
@@ -879,33 +907,62 @@ class Driver extends webdriver.WebDriver {
879
907
* @returns {Promise<void> }
880
908
*/
881
909
async logMutationEvents ( connection , callback ) {
882
- await connection . execute ( 'Runtime.enable' , this . getRandomNumber ( 1 , 10 ) , { } , null )
883
- await connection . execute ( 'Page.enable' , this . getRandomNumber ( 1 , 10 ) , { } , null )
910
+ await connection . execute (
911
+ 'Runtime.enable' ,
912
+ this . getRandomNumber ( 1 , 10 ) ,
913
+ { } ,
914
+ null
915
+ )
916
+ await connection . execute (
917
+ 'Page.enable' ,
918
+ this . getRandomNumber ( 1 , 10 ) ,
919
+ { } ,
920
+ null
921
+ )
884
922
885
- await connection . execute ( 'Runtime.addBinding' , this . getRandomNumber ( 1 , 10 ) , {
886
- name : '__webdriver_attribute' ,
887
- } , null )
923
+ await connection . execute (
924
+ 'Runtime.addBinding' ,
925
+ this . getRandomNumber ( 1 , 10 ) ,
926
+ {
927
+ name : '__webdriver_attribute' ,
928
+ } ,
929
+ null
930
+ )
888
931
889
- const mutationListener
932
+ let mutationListener = ''
890
933
try {
891
934
// Depending on what is running the code it could appear in 2 different places which is why we try
892
935
// here and then the other location
893
- mutationListener = fs . readFileSync ( './javascript/node/selenium-webdriver/lib/atoms/mutation-listener.js' , 'utf-8' ) . toString ( )
936
+ mutationListener = fs
937
+ . readFileSync (
938
+ './javascript/node/selenium-webdriver/lib/atoms/mutation-listener.js' ,
939
+ 'utf-8'
940
+ )
941
+ . toString ( )
894
942
} catch {
895
- mutationListener = fs . readFileSync ( './lib/atoms/mutation-listener.js' , 'utf-8' ) . toString ( )
943
+ mutationListener = fs
944
+ . readFileSync ( './lib/atoms/mutation-listener.js' , 'utf-8' )
945
+ . toString ( )
896
946
}
897
947
898
948
this . executeScript ( mutationListener )
899
949
900
- await connection . execute ( 'Page.addScriptToEvaluateOnNewDocument' , this . getRandomNumber ( 1 , 10 ) , {
901
- source : mutationListener ,
902
- } , null )
950
+ await connection . execute (
951
+ 'Page.addScriptToEvaluateOnNewDocument' ,
952
+ this . getRandomNumber ( 1 , 10 ) ,
953
+ {
954
+ source : mutationListener ,
955
+ } ,
956
+ null
957
+ )
903
958
904
959
this . _wsConnection . on ( 'message' , async ( message ) => {
905
960
const params = JSON . parse ( message )
906
961
if ( params . method === 'Runtime.bindingCalled' ) {
907
962
let payload = JSON . parse ( params [ 'params' ] [ 'payload' ] )
908
- let elements = await this . findElements ( { css : "*[data-__webdriver_id=" + payload [ 'target' ] } )
963
+ let elements = await this . findElements ( {
964
+ css : '*[data-__webdriver_id=' + payload [ 'target' ] ,
965
+ } )
909
966
910
967
if ( elements . length === 0 ) {
911
968
return
@@ -915,7 +972,7 @@ class Driver extends webdriver.WebDriver {
915
972
element : elements [ 0 ] ,
916
973
attribute_name : payload [ 'name' ] ,
917
974
current_value : payload [ 'value' ] ,
918
- old_value : payload [ 'oldValue' ]
975
+ old_value : payload [ 'oldValue' ] ,
919
976
}
920
977
callback ( event )
921
978
}
0 commit comments