2016-02-11 50 views
0

在试图运行这个例子约Protractor Automation 当我点击量角器conf.js在cmd中我得到了以下错误意外标记

exports.config = { 
      directConnect: true, 

      // Capabilities to be passed to the webdriver instance. 
      capabilities: { 
      'browserName': 'chrome' 
      }, 

      // Framework to use. Jasmine is recommended. 
      framework: 'jasmine', 

      // Spec patterns are relative to the current working directly when 
      // protractor is called. 
      specs: ['joe_spec.js'], 

      // Options to be passed to Jasmine. 
      jasmineNodeOpts: { 
      defaultTimeoutInterval: 30000 
      } 
     }; 

C:\Users\Emna\Desktop\example>protractor conf.js 
Using ChromeDriver directly... 
[launcher] Running 1 instances of WebDriver 
[launcher] Error: SyntaxError: Unexpected token ILLEGAL 
    at exports.runInThisContext (vm.js:53:16) 
    at Module._compile (module.js:374:25) 
    at Object.Module._extensions..js (module.js:417:10) 
    at Module.load (module.js:344:32) 
    at Function.Module._load (module.js:301:12) 
    at Module.require (module.js:354:17) 
    at require (internal/module.js:12:17) 
    at C:\Users\Emna\AppData\Roaming\npm\node_modules\protractor\node_modules\jasmine\lib\jasmine.js:71:5 
    at Array.forEach (native) 
    at Jasmine.loadSpecs (C:\Users\Emna\AppData\Roaming\npm\node_modules\protractor\node_modules\jasmine\lib\jasmine.js:70:18) 
[launcher] Process exited with error code 100 
+1

可以你用conf.js文件更新你的问题?谢谢 –

+0

好的,它完成了。由于 – Emna

+0

这里是joe_spec.js文件: 描述(“输入量角器示例页面上的元素文本”),功能({ 它(“检查在文本框中显示页面上输入文本”功能( );}};}}。sendKeys(“Joe Colantonio”); element(by .model(“joeAngularText”)){0128} (text); });; }}; });() – Emna

回答

2

在这里你走这将作品的拷贝,粘贴示例代码并运行它:

describe('Enter text in element on Protractor Example page', function() { 

    it ('to check that text entered in text box displays on page',function() { 
     browser.get('http://www.joecolantonio.com/ProtractorExample.html'); 
      element(by.model('joeAngularText')).sendKeys('Joe Colantonio'); 
     element(by.binding('joeAngularText')).getText().then(function(text){ 
      console.log(text); 
     }); 
    }); 
}); 

的问题是您使用的是您的描述文件中的字符: 都“和“狡猾的是其中的字符它不喜欢..如果你再把它们放在'和'它的作品...我只测试了两个,当我使用你的代码作为你得到的同样的错误信息..但如果我改变为'和'然后错误消失

+0

非常感谢。最后它的工作.. – Emna

+1

你很受欢迎,我很高兴成为协助:) – TesterPhi

+0

我是初学者这是我的第一个例子与角JS和量角器:) – Emna