小编ssh*_*rma的帖子

如何将参数从npm命令传递到量角器配置文件

如何将参数从npm命令传递到量角器配置文件

我有量角器配置文件:

exports.config = {

allScriptsTimeout : 30000,

suites : {        
   login2 : 'e2e/TestSuites/Full/LoginTestSuite/ValidInvalidLogins.js',
},
// configure multiple browsers to run tests
multiCapabilities : [
{
   'browserName' : 'chrome'
    //'browserName': 'firefox'
} ],
baseUrl :'http://localhost:8080',
framework : 'jasmine2',
jasmineNodeOpts : {
    defaultTimeoutInterval : 30000
 },
};
Run Code Online (Sandbox Code Playgroud)

和npm package.json文件:

 "scripts": {   
"e2e-bvt": "protractor tests/protractor-conf-BVT.js --baseUrl $baseUrl",    
 },
Run Code Online (Sandbox Code Playgroud)

我想将--baseUrl = http:// testurl:8080传递给npm命令,以便量角器配置文件可以采用此参数针对不同的baseUrl运行测试。

我该如何实现以下目标:

 npm run e2e-bvt --$baseUrl=http://testurl:8080
Run Code Online (Sandbox Code Playgroud)

npm protractor

4
推荐指数
1
解决办法
3857
查看次数

在firefox中运行Protractor测试时,无法解析新的会话响应

量角器版本:5.1.1,Firefox版本:47,webdriver版本:v0.15.0当我尝试在Firefox中运行Protractor测试时出现以下错误:

[15:13:47] I/launcher - Running 1 instances of WebDriver
[15:13:47] I/direct - Using FirefoxDriver directly...
[15:13:53] E/launcher - Unable to parse new session response: {"value": {"sessionId":"e8dc5d2f-a3bd-45db-89c1-a023e31e08e6","value":{"XULappId":"{ec80
30f7-c20a-464f-9b0e-13a3a9e97384}","acceptSslCerts":false,"appBuildId":"20160604131506","browserName":"Firefox","browserVersion":"47.0","command_id":1
,"count":1,"device":"desktop","platform":"WINDOWS_NT","platformName":"Windows_NT","platformVersion":"6.3","proxy":{},"raisesAccessibilityExceptions":f
alse,"rotatable":false,"specificationLevel":0,"takesElementScreenshot":true,"takesScreenshot":true,"version":"47.0"}}}
[15:13:53] E/launcher - WebDriverError: Unable to parse new session response: {"value": {"sessionId":"e8dc5d2f-a3bd-45db-89c1-a023e31e08e6","value":{"
XULappId":"{ec8030f7-c20a-464f-9b0e-13a3a9e97384}","acceptSslCerts":false,"appBuildId":"20160604131506","browserName":"Firefox","browserVersion":"47.0
","command_id":1,"count":1,"device":"desktop","platform":"WINDOWS_NT","platformName":"Windows_NT","platformVersion":"6.3","proxy":{},"raisesAccessibil
ityExceptions":false,"rotatable":false,"specificationLevel":0,"takesElementScreenshot":true,"takesScreenshot":true,"version":"47.0"}}}
    at WebDriverError (C:\DG_Selenium\analytics-qa\TestAutomation\SeleniumFramework\node_modules\selenium-webdriver\lib\error.js:27:5)
    at doSend.then.response (C:\DG_Selenium\analytics-qa\TestAutomation\SeleniumFramework\node_modules\selenium-webdriver\lib\http.js:445:19)
    at process._tickCallback (internal/process/next_tick.js:109:7)
From: Task: WebDriver.createSession()
    at Function.createSession (C:\DG_Selenium\analytics-qa\TestAutomation\SeleniumFramework\node_modules\selenium-webdriver\lib\webdriver.js:777:24)
    at Function.createSession (C:\DG_Selenium\analytics-qa\TestAutomation\SeleniumFramework\node_modules\selenium-webdriver\firefox\index.js:640:55)
    at Direct.getNewDriver (C:\DG_Selenium\analytics-qa\TestAutomation\SeleniumFramework\node_modules\protractor\lib\driverProviders\direct.ts:112:25)

    at Runner.createBrowser (C:\DG_Selenium\analytics-qa\TestAutomation\SeleniumFramework\node_modules\protractor\lib\runner.ts:225:39)
    at q.then.then (C:\DG_Selenium\analytics-qa\TestAutomation\SeleniumFramework\node_modules\protractor\lib\runner.ts:391:27)
    at _fulfilled (C:\DG_Selenium\analytics-qa\TestAutomation\SeleniumFramework\node_modules\q\q.js:834:54)
    at self.promiseDispatch.done (C:\DG_Selenium\analytics-qa\TestAutomation\SeleniumFramework\node_modules\q\q.js:863:30)
    at Promise.promise.promiseDispatch (C:\DG_Selenium\analytics-qa\TestAutomation\SeleniumFramework\node_modules\q\q.js:796:13) …
Run Code Online (Sandbox Code Playgroud)

protractor

3
推荐指数
1
解决办法
5152
查看次数

如何为不同的浏览器和测试套件参数化量角器配置文件

我正在从命令运行我的量角器测试 npm run e2e

我想要一种方法,如果我通过,npm run e2e firefox那么我的测试将在 Firefox 浏览器上执行。

或者,如果我运行,npm run e2e chrome那么它应该在 chrome 上运行

如果我都通过了,npm run e2e firefox chrome那么我的测试应该在两个浏览器上并行运行。

是否可以参数化量角器配置文件?

同样,如果我可以通过命令传递测试套件名称,并且它应该只在该特定测试套件下执行测试。

这是我的配置文件,这就是我想要实现的目标:

`//var HtmlReporter = require('protractor-html-screenshot-reporter');

exports.config = {

allScriptsTimeout: 30000,
//Add parameters for browser names
params:{
  pass: {
      browserName : 'chrome',
      testSuitName : 'e2e/TestSuites/_BVT/*.js',
  }
 },  
suites: {    
//Define here List of Sanity Test Scenarios:
  BVT : testSuitName,   
}, 
// configure multiple browsers to run tests
multiCapabilities: [
 shardTestFiles: true,
 maxInstances: …
Run Code Online (Sandbox Code Playgroud)

protractor

1
推荐指数
1
解决办法
7803
查看次数

如果项目在列表中存在,如何预期

如何将String与List进行比较ng-repeat:

this.TenantList = element.all(by.repeater("tenant in tenantList"));

TenantList.getAttribute('aria-label').then(function(list) {
    //label contains 10 items and I want to see if this list contains 'Test'
    expect(list).toMatch('Test');
});
Run Code Online (Sandbox Code Playgroud)

javascript testing jasmine protractor

1
推荐指数
1
解决办法
51
查看次数

使用browser.takeScreenshot()时,如何在预期失败时拍摄sceenshots

我希望捕获屏幕截图,只要Spec失败,这是我正在使用的屏幕截图辅助函数:

var fs = require('fs');
function screenshot(filename, path) {
 // within a test:
browser.takeScreenshot().then(function (png) {
    writeScreenShot(png, filename, path);
 });
}

function writeScreenShot(data, filename, path) {
var stream = fs.createWriteStream( path+ filename);
stream.write(new Buffer(data, 'base64'));
stream.end();
}   
Run Code Online (Sandbox Code Playgroud)

我的测试:

describe('this is a sample test',function(){
 var testCaseName = this.getFullName();
 it('this is sample spec1',function(){
 // Test Steps
 expect(A).toBe(B);
 });
it('this is sample spec2',function(){
 // Test Steps
 expect(A).toBe(B);
 });
});
Run Code Online (Sandbox Code Playgroud)

当我的测试规格失败时,我想截取屏幕截图,我该怎么做?有什么建议 ?

protractor

0
推荐指数
1
解决办法
1261
查看次数

标签 统计

protractor ×5

jasmine ×1

javascript ×1

npm ×1

testing ×1