小编Mic*_*hal的帖子

量角器/ Jasmine2 - 在指定的超时内未调用异步回调

我在elen测试中遇到问题,我在selenium网格上运行测试.有时候测试失败了defaultTimeoutInterval

试图解决它以某种方式改变defaultTimeoutInterval到更高的值,defaultTimeoutInterval但结果是等待更长但错误是相同的.

Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.
Run Code Online (Sandbox Code Playgroud)

测试失败的示例规范:

var LoginPage = require('../ pages/login_page.js'); var UsersPage = require('../ pages/users_page.js'); var WelcomePage = require('../ pages/welcome_page.js');

exports.config = {
    chromeOnly: true,
    chromeDriver: '../node_modules/.bin/chromedriver',
    framework: 'jasmine2',
    capabilities: {
        'browserName': 'chrome',
        shardTestFiles: true,
        maxInstances: 3
    },
    specs: ['../e2e/protractor/spec/*.js'],
    jasmineNodeOpts: {
        showColors: true,
        defaultTimeoutInterval: 30000,
        isVerbose: true,
        includeStackTrace: true,
    },
Run Code Online (Sandbox Code Playgroud)

任何人都可以提供任何合理的解决方案如何处理/避免它并解释为什么会发生?

javascript testing error-handling protractor jasmine2.0

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

全球化之前和之后的量角器

在我的每个规范beforeEachafterEach声明中.是否有可能以某种方式在全球范围内添加它以避免规范之间的代码重复?

javascript selenium protractor

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

放心 - 如果失败重试请求

示例测试:

@Test
public void shouldGetRoutesList() {
    Response response =
            given()
                    .headers("RequestId", 10)
                    .headers("Authorization", accessToken)
                    .contentType(ContentType.JSON).
            expect()
                    .statusCode(HttpURLConnection.HTTP_OK).
            when()
                    .get("address");
    String responseBody = response.getBody().asString();
    System.out.println(responseBody);
    logger.info("Log message");
}
Run Code Online (Sandbox Code Playgroud)

事情是有时来自服务的响应等于 500 错误。这是因为应用程序错误并且是应用程序错误,所以我想添加 temp。.get如果服务返回 500 ,则重试的解决方法。我正在考虑ifdo-while但我知道这不是很聪明的方法。任何人都可以建议一些解决方案?

换句话说 - 如果 statusCode=!HTTP_OK,我想重试整个测试(或只是 .get)

java testng rest-assured selenium-webdriver

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

带硒栅的量角器

有人可以建议如何设置量角器来远程运行测试吗?

我的量角器.conf.js:

exports.config = {
    chromeOnly: true,
    chromeDriver: '../node_modules/.bin/chromedriver',
    framework: 'jasmine2',
    capabilities: {
        'browserName': 'chrome',
        shardTestFiles: true,
        maxInstances: 3
    },
    specs: ['../e2e/protractor/spec/*.js'],
    jasmineNodeOpts: {
        showColors: true,
        defaultTimeoutInterval: 30000
    },
    jasmineNodeOpts: {
        isVerbose: true
    },
    onPrepare: function () {
        global.dv = browser.driver;
        browser.ignoreSynchronization = true;
    },
    seleniumServerJar: '../node_modules/selenium-server/lib/runner/selenium-server-standalone-2.47.1.jar',
    baseUrl: 'www.google.com'
};
Run Code Online (Sandbox Code Playgroud)

我的量角器.json:

{
  "options": {
    "configFile": "./config/protractor.conf.js",
    "noColor": false,
    "args": {},
    "webdriverManagerUpdate": true
  },
  "e2e": {
    "options": {
      "keepAlive": false
    }
  },
  "continuous": {
    "options": {
      "keepAlive": true
    }
  }
} …
Run Code Online (Sandbox Code Playgroud)

javascript configuration selenium-grid selenium-webdriver protractor

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

在java中返回两个类的方法

我有两节课:

public class UnoLoginPageUi {
    public final Input username = new Input("id=username");
    public final Input password = new Input("id=password");
    public final Button loginButton = new Button("name=login");
}
Run Code Online (Sandbox Code Playgroud)

public class DuoLoginPageUi {
    public final Input username = new Input("id=usernameField");
    public final Input password = new Input("id=passwordField");
    public final Button loginButton = new Button("id=submitButton");
}
Run Code Online (Sandbox Code Playgroud)

在一个共同的课堂上,我想做出类似的东西:

public void loginUsingUsernameAndPassword(String username, String password, String pageType) {
    getUi(pageType).username.waitForToBeDisplayed();
    getUi(pageType).username.setValue(username);
    getUi(pageType).password.setValue(password);
    getUi(pageType).loginButton.click();
}
Run Code Online (Sandbox Code Playgroud)

其中getUi()是一个gas参数pageType(即UNO或DUO)的方法.

private Class getUi(String pageType) {
    if (pageType.equals("UNO")) {
        return new …
Run Code Online (Sandbox Code Playgroud)

java testing methods selenium

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

如何验证Java中的时间格式是否符合预期

在我的带有@PathVariable("timestamp")的REST API控制器中,我必须验证时间戳格式是否符合ISO 8601标准:例如2016-12-02T18:25:43.511Z.

@RequestMapping("/v3/testMe/{timestamp}")
public class TestController {

    private static final String HARDCODED_TEST_VALUE = "{\n\t\"X\": \"01\",\n\t\"Y\": \"0.2\"\n}";

    @ApiOperation(nickname = "getTestMe", value = "Return TestMe value", httpMethod = "GET",
            authorizations = {@Authorization(value = OAUTH2,
                    scopes = {@AuthorizationScope(scope = DEFAULT_SCOPE, description = SCOPE_DESCRIPTION)})})
    @RequestMapping(method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
    @ResponseBody
    public String getTestMe(@PathVariable("timestamp") String timestamp) {

        if (timestamp != null)        {
            return HARDCODED_TEST_VALUE;
        }

        throw new ResourceNotFoundException("wrong timestamp format");
    }
}
Run Code Online (Sandbox Code Playgroud)

我想要实现它的方式与上面的if-else语句类似,检查时间戳是否为null - 所以类似地我想添加类似的if-else来验证时间戳的格式并返回正文(如果是)或404错误代码,如果不是.

知道我可以用它做什么,请给我准备好的例子吗?我已经尝试使用正则表达式进行简单验证但不方便,但遗憾的是无论如何都没有...

java api validation rest timestamp

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