量角器打字稿:规格文件中出现突然错误。无法运行文件

时间:2019-03-21 15:05:23

标签: javascript typescript protractor

我正在尝试运行示例typescirpt文件。我已成功将.ts文件转换为js文件。然后我注意到我的原始TS文件中出现了错误,这是正确的。另外,我无法运行这些规格文件。

不确定我做错了什么。

我该如何解决?

watch this

我还将附上ts。和转换的js。文件。

我很困惑

预先感谢

TS。文件1样本测试文件

import{browser} from "protractor";
import{element,by,} from "protractor";


describe('Using chain loctor',function(){


    it('Opening google page',function(){
    // write your code here!!!

        browser.get("http://juliemr.github.io/protractor-demo/");

        element(by.model("first")).sendKeys("3");
        element(by.model("second")).sendKeys("5");

        element(by.id("gobutton")).click();


        //repeater syntax , chaining locators and CSS tags 
        element(by.repeater("result in memory")).element(by.css("td:nth-child(3)")).getText().then(function(text)
                {
            //possible promise syntax here!!!
            console.log(text);


        })

TS。配置文件

import {Config} from "protractor";

// An example configuration file

export let config: Config = {
    // The address of a running selenium server.
    //seleniumAddress: 'http://localhost:4444/wd/hub',
  directConnect:true,


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

    // Spec patterns are relative to the configuration file location passed
    // to protractor (in this example conf.js).
    // They may include glob patterns.
    specs: ['ChaLoctestscript.js'],

    // Options to be passed to Jasmine-node.
    jasmineNodeOpts: {
      showColors: true, // Use colors in the command line report.
    }
  };
  1. 已将ts转换为Javascript测试文件。

这是我将数字1转换为javascript的文件

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const protractor_1 = require("protractor");
const protractor_2 = require("protractor");
describe('Using chain loctor', function () {
    it('Opening google page', function () {
        // write your code here!!!
        protractor_1.browser.get("http://juliemr.github.io/protractor-demo/");
        protractor_2.element(protractor_2.by.model("first")).sendKeys("3");
        protractor_2.element(protractor_2.by.model("second")).sendKeys("5");
        protractor_2.element(protractor_2.by.id("gobutton")).click();
        //repeater syntax , chaining locators and CSS tags 
        protractor_2.element(protractor_2.by.repeater("result in memory")).element(protractor_2.by.css("td:nth-child(3)")).getText().then(function (text) {
            //possible promise syntax here!!!
            console.log(text);
        });
    });
});
  1. ts。到Javascript配置文件

转换后的配置文件。

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
// An example configuration file
exports.config = {
    // The address of a running selenium server.
    //seleniumAddress: 'http://localhost:4444/wd/hub',
    directConnect: true,
    // Capabilities to be passed to the webdriver instance.
    capabilities: {
        browserName: 'chrome'
    },
    // Spec patterns are relative to the configuration file location passed
    // to protractor (in this example conf.js).
    // They may include glob patterns.
    specs: ['ChaLoctestscript.ts'],
    // Options to be passed to Jasmine-node.
    jasmineNodeOpts: {
        showColors: true,
    }
};

最后,来自终端的错误消息。对不起所有代码...只是试图通过

5。终端错误消息

nvm is not compatible with the npm config "prefix" option: currently set to "/usr/local"
Run `npm config delete prefix` or `nvm use --delete-prefix v11.1.0 --silent` to unset it.Jacquelines-MacBook-Air:ProtractorTypeScriptCucumber jacquelinegeorge$ npm install -g typscrtipt
npm ERR! code E404
npm ERR! 404 Not Found: typscrtipt@latest
npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/jacquelinegeorge/.npm/_logs/2019-03-21T11_40_22_316Z-debug.logJacquelines-MacBook-Air:ProtractorTypeScriptCucumber jacquelinegeorge$ npm install -g typescript
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules
npm ERR! path /usr/local/lib/node_modulesnpm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall access
npm ERR! Error: EACCES: permission denied, access '/usr/local/lib/node_modules'
npm ERR!  { [Error: EACCES: permission denied, access '/usr/local/lib/node_modules']
npm ERR!   stack:
Jacquelines-MacBook-Air:ProtractorTypeScriptCucumber jacquelinegeorge$ npm install -g typescript
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules
npm ERR! path /usr/local/lib/node_modules
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall access
npm ERR! Error: EACCES: permission denied, access '/usr/local/lib/node_modules'
npm ERR!  { [Error: EACCES: permission denied, access '/usr/local/lib/node_modules']
npm ERR!   stack:
Jacquelines-MacBook-Air:ProtractorTypeScriptCucumber jacquelinegeorge$ npm install -g typescript
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules
npm ERR! path /usr/local/lib/node_modules
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall access
npm ERR! Error: EACCES: permission denied, access '/usr/local/lib/node_modules'
npm ERR!  { [Error: EACCES: permission denied, access '/usr/local/lib/node_modules']
npm ERR!   stack:
Jacquelines-MacBook-Air:ProtractorTypeScriptCucumber jacquelinegeorge$ npm install -g typescript
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules
npm ERR! path /usr/local/lib/node_modules
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall access
npm ERR! Error: EACCES: permission denied, access '/usr/local/lib/node_modules'
npm ERR!  { [Error: EACCES: permission denied, access '/usr/local/lib/node_modules']
npm ERR!   stack:

0 个答案:

没有答案