File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -443,7 +443,13 @@ class NightwatchClient extends EventEmitter {
443443 }
444444
445445 setLaunchUrl ( ) {
446- const value = this . settings . baseUrl || this . settings . launchUrl || this . settings . launch_url || null ;
446+ let value = this . settings . baseUrl || this . settings . launchUrl || this . settings . launch_url || null ;
447+
448+ // For e2e and component testing on android emulator
449+ if ( ! this . settings . desiredCapabilities . real_mobile && this . settings . desiredCapabilities . avd ) {
450+ value = value . replace ( 'localhost' , '10.0.2.2' ) . replace ( '127.0.0.1' , '10.0.2.2' ) ;
451+ }
452+
447453 this
448454 . setApiProperty ( 'baseUrl' , value )
449455 . setApiProperty ( 'launchUrl' , value )
Original file line number Diff line number Diff line change 1+ const assert = require ( 'assert' ) ;
2+ const common = require ( '../../common.js' ) ;
3+ const NightwatchClient = common . require ( 'index.js' ) ;
4+
5+
6+ describe ( 'Mobile Component Testing in Android Emulator' , function ( ) {
7+ it ( 'test baseUrl - localhost' , function ( ) {
8+ const client = NightwatchClient . client ( {
9+ baseUrl : 'http://localhost:3000' ,
10+ webdriver : {
11+ start_process : true
12+ } ,
13+ desiredCapabilities : {
14+ avd : 'nightwatch-android-11' ,
15+ real_mobile : false
16+ }
17+ } ) ;
18+
19+ assert . strictEqual ( client . api . baseUrl , 'http://10.0.2.2:3000' ) ;
20+ } ) ;
21+
22+ it ( 'test baseUrl - 127.0.0.1' , function ( ) {
23+ const client = NightwatchClient . client ( {
24+ baseUrl : 'http://127.0.0.1:3000' ,
25+ webdriver : {
26+ start_process : true
27+ } ,
28+ desiredCapabilities : {
29+ avd : 'nightwatch-android-11' ,
30+ real_mobile : false
31+ }
32+ } ) ;
33+
34+ assert . strictEqual ( client . api . baseUrl , 'http://10.0.2.2:3000' ) ;
35+ } ) ;
36+ } ) ;
You can’t perform that action at this time.
0 commit comments