Hi all.
I have an issue with running tests with webdriver in docker and a general question about chrome logging.
General question:
How can I add and an observer to log Chrome console messages?
I have set of tests written in typescript with puppeteer and there I use the following observer:
page.on('console', msg =>
msg.args().forEach(async arg => {
Generic.logToConsole(`arg: ${await arg.jsonValue()}`);
})
);
page.on('pageerror', error => {
Generic.logToConsole(`PageError: ${error.message}`);
});
page.on('error', error => {
Generic.logToConsole(`Error: ${error.message}`);
});
page.on('requestfailed', request => {
const failure = request.failure();
if (failure) {
Generic.logToConsole(`RequestFailed: ${failure.errorText} | ${request.url()}`);
}
});
Is there any similar way to do this in jmeter webdriver script? I understand that this question is more related to the authors of webdriver plugin, but anyway. I feel that it's pretty useful thing for many users.
My particular issue:
I'm trying to setup some load tests for our local website and have an issue with running tests with headless chrome in Docker. When user opens our website url, user is being redirected to login page. My tests work fine when I run them locally in jmeter in normal or headless mode.
But when tests are run in docker (blazemeter/taurus image with respective chromedriver 81), and browser tries to open our website (with redirects) it get's a blank page. I know that because I've set a timeout and take screenshot after that (please check code below).
In the same time if it tries to open
google.com or other site - it's opened fine. Initially I had an issue with CA certificates absence, but resolved it by installing CA certificates. When I use curl <our url>, it's able to open our website and redirected page.
My configs and code samples can be found below. Any help will be much appreciated.
Dockerfile:
docker-compose file:
version: "3.7"
services:
taurus:
volumes:
- './load_test:/bzt-configs'
- './artifacts:/tmp/artifacts'
- ../.config/cert/ca.local-dev.crt:/usr/local/share/ca-certificates/ca.local-dev.crt
- ../.config/cert/ca.pal-root-dev.crt:/usr/local/share/ca-certificates/ca.pal-root-dev.crt
image: blazemeter-taurus:1.14
entrypoint: ["sh", "-c", "update-ca-certificates && bzt -l /tmp/artifacts/bzt.log \"$$@\"", "ignored"]
command: complex_scenario_proxy.yml
environment:
no_proxy: ${no_proxy}
complex_scenario_proxy.yml:
settings:
proxy:
address: http://<our proxy ip>:8081
execution:
- write-xml-jtl: full
iterations: 1
concurrency: 1
ramp-up: 1
scenario: portalComplexWebdriver
scenarios:
portalComplexWebdriver:
script: Portal_Complex_Scenario.jmx
properties:
log_level.jmeter: DEBUG
variables:
chromeDriverPath: /usr/bin/chromedriver
reporting:
- module: passfail
criteria:
- "avg-rt>13000ms for 10s, continue as failed"
- "fail>50% for 10s, stop as failed"
- module: blazemeter
report-name: Portal load test
test: Portal load test
project: Portal load test
modules:
jmeter:
properties:
log_level.jmeter: DEBUG
log_level.jmeter.threads: DEBUG
sampler:
var url = WDS.args[0];
var pkg = JavaImporter(org.openqa.selenium);
var fileUtils = JavaImporter(org.apache.commons.io)
var io = JavaImporter(java.io);
var support_ui = JavaImporter(org.openqa.selenium.support.ui.WebDriverWait);
var conditions = org.openqa.selenium.support.ui.ExpectedConditions;
var wait = new support_ui.WebDriverWait(WDS.browser, 30000);
WDS.browser.manage().window().setPosition(new pkg.Point(0, 0))
WDS.browser.manage().window().setSize(new pkg.Dimension(1920, 1080))
WDS.sampleResult.sampleStart();
WDS.log.info(url);
WDS.browser.get(url);
// Debug
java.lang.Thread.sleep(5000);
var location = '/tmp/artifacts/';
var screenshot = WDS.browser.getScreenshotAs(pkg.OutputType.FILE);
fileUtils.FileUtils.copyFile(screenshot, new io.File(location+'screenshot.png'));
wait.until(conditions.visibilityOfElementLocated(pkg.By.cssSelector('button[name="button"]')));
WDS.sampleResult.sampleEnd();
I thought that issue may be caused by proxy - but no luck. First - I passed no proxy list to docker container and second - i tried to set "no proxy" to chrome driver configuration item.
I decided to find some way to enable chrome console logs but was not able to find the way.
Can see no error in logs. It just wait for element with css selector for hours.
taurus_1 | 11:00:32 INFO: Taurus CLI Tool v1.14.2
taurus_1 | 11:00:32 INFO: Starting with configs: ['complex_scenario_proxy.yml']
taurus_1 | 11:00:32 INFO: Configuring...
taurus_1 | 11:00:32 INFO: Using proxy 'http://**.**.**.**:8081'
taurus_1 | 11:00:32 INFO: Artifacts dir: /tmp/artifacts
taurus_1 | 11:00:32 INFO: Preparing...
taurus_1 | 11:00:33 INFO: 1 obsolete CookieManagers are found and fixed
taurus_1 | 11:00:34 WARNING: No BlazeMeter API key provided, will upload anonymously
taurus_1 | 11:00:35 INFO: Starting...
taurus_1 | 11:00:35 INFO: Waiting for results...
taurus_1 | 11:00:35 INFO: Initiating data feeding...
taurus_1 | 11:00:36 INFO: Started data feeding: https://a.blazemeter.com/app/?public-token=u4DaNqVd2qw9y0p0rDaFRlIC3t3dRwxLHSYDekvD5kpjcbrZGW#reports/r-ext-5ed0eb522b4fa/summary
taurus_1 | 11:00:36 WARNING: Can't open link in browser: could not locate runnable browser