自动针对来自cmd

时间:2019-01-04 14:37:46

标签: typescript protractor cucumber

我面临通过命令行针对测试环境设置具有登录凭据用户名和密码的其他属性文件的问题。所以,我的意思是,如果我正在运行生产环境,那么它应该为生产环境加载属性值(用户名和密码)或文件,如果我在测试环境中运行,则应该设置测试用户名和密码。你能帮我这个忙吗?请在下面找到我使用过的代码: properties.json&HomePageObject.ts

`   {"prod":"https://www.prod.com",
    "prodlogin":
    {"username": "sh.sih@sp.com",
    "password": "asbcde"
    },
    "test":"https://www.test.com",
    "testlogin":
    {
     "username": "sh.sih12@sp.com",
     "password": "asbcdefd" 
     }
     }
`
`   import { browser, protractor, Config, ElementFinder, element, by } 
    from 'protractor';
    const chai = require("chai").use(require("chai-as-promised"));
    import { config } from '../config/config';
    const expect = chai.expect;
    import {Value, Properties} from 'ts-json-properties';
    Properties.initialize();
   export class HomePageObject{
   @Value('prodlogin.username')
   private username:string; 
   @Value('testlogin.username')
   private testusername:string;
   @Value('prod')
   private prodEnv:string; 
   @Value('test')
   private testEnv:string;
   constructor(){

   console.log('Doc =>', this.username);
   console.log('Doc =>', this.testusername);
}`

Please suggest if I can do it in any other ways. It would good if you can share a good example or post on the same it will be really helpful.

0 个答案:

没有答案