22
33const wd = require ( 'macaca-wd' ) ;
44
5- const remoteConfig = {
6- host : 'localhost' ,
7- port : 3456 // Macaca server 默认使用 3456 端口
8- } ;
9-
10- const driver = wd . promiseChainRemote ( remoteConfig ) ;
11-
12- describe ( 'test electron.app' , function ( ) {
5+ describe ( './test/sample.test.js' , function ( ) {
136 this . timeout ( 5 * 60 * 1000 ) ;
147
15- let driver = wd . promiseChainRemote ( {
8+ const driver = wd . promiseChainRemote ( {
169 host : 'localhost' ,
1710 port : process . env . MACACA_SERVER_PORT || 3456
1811 } ) ;
1912
20- before ( function ( ) {
13+ before ( ( ) => {
2114 return driver . init ( {
2215 platformName : 'desktop' ,
2316 browserName : 'chrome' ,
2417 chromeOptions : {
25- " binary" : " /Applications/macaca-electron-builder.app/Contents/MacOS/macaca-electron-builder" // 填写自己的执行文件路劲
18+ binary : ' /Applications/macaca-electron-builder.app/Contents/MacOS/macaca-electron-builder' // 填写自己的执行文件路劲
2619 }
2720 } ) . sleep ( 2 * 1000 )
2821 } ) ;
2922
30- after ( function ( ) {
23+ after ( ( ) => {
3124 return driver
3225 . sleep ( 1000 )
33- . close ( )
26+ . close ( ) ;
3427 } )
3528
36- it ( 'click link' , function ( ) {
29+ it ( 'click link' , ( ) => {
3730 return driver
3831 . waitForElementById ( 'macacaId' , 5000 , 100 )
39- . click ( )
32+ . click ( ) ;
4033 } )
4134
42- it ( 'click button' , function ( ) {
35+ it ( 'click button' , ( ) => {
4336 return driver
4437 . elementByCss ( '#app > div > header > div.sidebar-button' )
45- . click ( )
38+ . click ( ) ;
4639 } )
4740
48- it ( 'click title ' , function ( ) {
41+ it ( 'click title ' , ( ) => {
4942 return driver
5043 . elementByCss ( '#app > div > div.sidebar > nav > div:nth-child(2) > div > a > span.title' )
5144 . sleep ( 2000 )
52- . click ( )
45+ . click ( ) ;
5346 } )
5447
55- it ( 'click title' , function ( ) {
48+ it ( 'click title' , ( ) => {
5649 return driver
5750 . elementByCss ( '#app > div > div.sidebar > nav > div:nth-child(3) > div > a > span.title' )
5851 . sleep ( 2000 )
59- . click ( )
52+ . click ( ) ;
6053 } )
6154
62- it ( 'input text' , function ( ) {
55+ it ( 'input text' , ( ) => {
6356 return driver
6457 . elementByCss ( '#app > div > header > div.links > div > input' )
6558 . sleep ( 2000 )
6659 . click ( )
67- . sendKeys ( '计算机' )
60+ . sendKeys ( '计算机' ) ;
6861 } )
6962} )
0 commit comments