2016-02-11 91 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