Hi Team,
I have the below code which is working fine in headless mode till clicking on the CONFIGURATION link. But once I click on the CONFIGURATION link I would like to.
Select ‘Server Template’
Enter ‘Discovery Document URL’
Click on ‘Save’
Could you please help on the same.
import { chromium } from 'k6/x/browser';
import { options, openidconnect_url, discovery_document_url, userName, password } from "./common_openid.js";
export {options};
export default function () {
const browser = chromium.launch({
headless: true,
slowMo: '1s',
});
const context = browser.newContext();
const page = context.newPage();
// 01. Go to the openidconnect landing page and click on CONFIGURATION
page.goto('https://openidconnect.net/', { waitUntil: 'networkidle' }).then(() => {
page.screenshot({ path: 'screenshots/01_screenshot.png' });
page.waitForSelector('button[class="playground-header-config btn btn-link"]');
return page.click('button[class="playground-header-config btn btn-link"]');
}).then(() => {
page.screenshot({ path: 'screenshots/02_screenshot.png' });
page.selectOption("select[name='server']", "Custom");
page.type("input[placeholder='https://my-oidc.com/.well-known/openid-configuration']", "some test url");
page.click('button[class="code-box-btn is-alt"]');
page.screenshot({ path: 'screenshots/03_screenshot.png' });
}).finally(() => {
page.close();
browser.close();
});
}
Hi @vishvambruth.javagal ,
Since the click
action returns a promise
, we should wait for it to return (like below):
page.goto('https://openidconnect.net/', { waitUntil: 'networkidle' }).then(() => {
...
}).then(() => {
...
page.type("input[placeholder='https://my-oidc.com/.well-known/openid-configuration']", "some test url");
return page.click('button[class="code-box-btn is-alt"]'); // <-- this
}).then(() => { // <-- this
page.screenshot({ path: 'screenshots/03_screenshot.png' });
}).finally(() => {
page.close();
browser.close();
});
I tried this, and it took three screenshots.
But its not selecting the value from dropdown and typing the required text in the text box.
Any thing wrong with the below code:
page.selectOption("select[name='server']", "Custom");
page.type("input[placeholder='https://my-oidc.com/.well-known/openid-configuration']", "some test url");
page.click('button[class="code-box-btn is-alt"]');
page.screenshot({ path: 'screenshots/03_screenshot.png' });
The click
action returns a promise (as I explained above), the last code you shared doesn’t handle that, but the last one I shared does.
Besides that, the value in the dropdown is "custom"
(with a lowercase c
, not Custom
). Please change the selectOption
as below:
page.selectOption("select[name='server']", "custom");
And please don’t forget handling the promise as I explained in my previous comments.
Hi @inanc ,
Thanks, I have written the below script and now its selecting the dropdown value. But after selecting the dropdown value Im trying to set the ‘Discovery Document URL’ with some URL and its failing to type in. Could you please take a look.
Note: The issue persists when we try to type long URL. Typing short URLs is working fine.
Unable to type: https://my-oidc.com/.well-known/openid-configuration
Able to type: https://my-oidc.com/
import { chromium } from 'k6/x/browser';
export default function () {
const browser = chromium.launch({
headless: true,
slowMo: '1s',
});
const context = browser.newContext();
const page = context.newPage();
// 01. Go to the openidconnect landing page and click on CONFIGURATION
page.goto('https://openidconnect.net/', { waitUntil: 'networkidle' }).then(() => {
page.screenshot({ path: 'screenshots/01_screenshot.png' });
page.waitForSelector('button[class="playground-header-config btn btn-link"]');
return page.click('button[class="playground-header-config btn btn-link"]');
}).then(() => {
page.screenshot({ path: 'screenshots/02_screenshot.png' });
page.waitForSelector("select[name='server']");
return page.selectOption("select[name='server']", "custom");
}).then(() => {
page.screenshot({ path: 'screenshots/03_screenshot.png' });
page.waitForSelector("input[placeholder='https://my-oidc.com/.well-known/openid-configuration']");
return page.click("input[placeholder='https://my-oidc.com/.well-known/openid-configuration']");
}).then(() => {
page.screenshot({ path: 'screenshots/04_screenshot.png' });
page.type("input[placeholder='https://my-oidc.com/.well-known/openid-configuration']", 'https://my-oidc.com/.well-known/openid-configuration');
page.screenshot({ path: 'screenshots/05_screenshot.png' });
}).finally(() => {
page.close();
browser.close();
});
}
PS C:\K6\xk6-browser> ./xk6-browser run openid_test.js
/\ |‾‾| /‾‾/ /‾‾/
/\ / \ | |/ / / /
/ \/ \ | ( / ‾‾\
/ \ | |\ \ | (‾) |
/ __________ \ |__| \__\ \_____/ .io
execution: local
script: openid_test.js
output: -
scenarios: (100.00%) 1 scenario, 1 max VUs, 10m30s max duration (incl. graceful stop):
* default: 1 iterations for each of 1 VUs (maxDuration: 10m0s, gracefulStop: 30s)
ERRO[0004] Failed to load resource: the server responded with a status of 403 () browser_source=network line_number=0 source=browser stacktrace="<nil>" url="https://alb.reddit.com/rp.gif?ts=1666712168171&id=t2_16vcix&event=PageVisit&m.itemCount=&m.value=&m.valueDecimal=&m.currency=&m.transactionId=&m.customEventName=&m.products=&uuid=009f7f87-f960-4cb5-a242-a855b9ac9fca&aaid=&em=&external_id=&idfa=&integration=reddit&opt_out=0&sh=1280&sw=720&v=rdt_02c59ad6"
ERRO[0030] communicating with browser: read tcp 127.0.0.1:51237->127.0.0.1:51236: wsarecv: An existing connection was forcibly
closed by the remote host. category=cdp elapsed="0 ms" goroutine=61
ERRO[0030] Uncaught (in promise) GoError: typing "https://my-oidc.com/.well-known/openid-configuration" in "input[placeholder='https://my-oidc.com/.well-known/openid-configuration']": pressing key: dispatching key event up: read tcp 127.0.0.1:51237->127.0.0.1:51236: wsarecv: An existing connection was forcibly closed by the remote host.: GoError
at reflect.methodValueCall (native)
at file:///C:/K6/xk6-browser/openid_test.js:26:4(11)
at native
executor=per-vu-iterations scenario=default
ERRO[0030] process with PID 141024 unexpectedly ended: exit status 1 category=browser elapsed="33 ms" goroutine=41
running (00m30.1s), 0/1 VUs, 1 complete and 0 interrupted iterations
default ✓ [======================================] 1 VUs 00m30.1s/10m0s 1/1 iters, 1 per VU
browser_dom_content_loaded.......: avg=227.41ms min=37µs med=1.94ms max=5.61s p(90)=6.68ms p(95)=20.65ms
browser_first_contentful_paint...: avg=5.61s min=5.61s med=5.61s max=5.61s p(90)=5.61s p(95)=5.61s
browser_first_meaningful_paint...: avg=5.61s min=5.61s med=5.61s max=5.61s p(90)=5.61s p(95)=5.61s
browser_first_paint..............: avg=5.61s min=5.61s med=5.61s max=5.61s p(90)=5.61s p(95)=5.61s
browser_loaded...................: avg=569.07ms min=221µs med=3.31ms max=6.64s p(90)=510.02ms p(95)=2.35s
data_received....................: 3.1 MB 103 kB/s
data_sent........................: 48 kB 1.6 kB/s
http_req_connecting..............: avg=63.05ms min=0s med=20ms max=902ms p(90)=97.9ms p(95)=323.34ms
http_req_duration................: avg=297.39ms min=13.92ms med=220.28ms max=1.52s p(90)=521.95ms p(95)=1.03s
http_req_receiving...............: avg=130.78ms min=12ms med=54.5ms max=1.03s p(90)=248ms p(95)=286.44ms
http_req_sending.................: avg=0s min=0s med=0s max=0s p(90)=0s p(95)=0s
http_req_tls_handshaking.........: avg=40.95ms min=0s med=16.5ms max=602ms p(90)=69.9ms p(95)=186.59ms
http_reqs........................: 112 3.726465/s
iteration_duration...............: avg=30.05s min=30.05s med=30.05s max=30.05s p(90)=30.05s p(95)=30.05s
iterations.......................: 1 0.033272/s
vus..............................: 1 min=1 max=1
vus_max..........................: 1 min=1 max=1
Hi @vishvambruth.javagal ,
I tried a slightly modified script on my Mac, and it took 5 screenshots. The selectOption
action does not return a promise. The modified script looks as the following:
import { chromium } from 'k6/x/browser';
export default function () {
const browser = chromium.launch({
headless: true,
slowMo: '1s',
});
const context = browser.newContext();
const page = context.newPage();
// 01. Go to the openidconnect landing page and click on CONFIGURATION
page.goto('https://openidconnect.net/', { waitUntil: 'networkidle' }).then(() => {
page.screenshot({ path: 'screenshots/01_screenshot.png' });
page.waitForSelector('button[class="playground-header-config btn btn-link"]');
return page.click('button[class="playground-header-config btn btn-link"]');
}).then(() => {
page.screenshot({ path: 'screenshots/02_screenshot.png' });
page.waitForSelector("select[name='server']");
page.selectOption("select[name='server']", "custom"); // <-------------------
page.screenshot({ path: 'screenshots/03_screenshot.png' });
page.waitForSelector("input[placeholder='https://my-oidc.com/.well-known/openid-configuration']");
return page.click("input[placeholder='https://my-oidc.com/.well-known/openid-configuration']");
}).then(() => {
page.screenshot({ path: 'screenshots/04_screenshot.png' });
page.type("input[placeholder='https://my-oidc.com/.well-known/openid-configuration']", 'https://my-oidc.com/.well-known/openid-configuration');
page.screenshot({ path: 'screenshots/05_screenshot.png' });
}).finally(() => {
page.close();
browser.close();
});
}
@inanc , I tried your below script on my windows machine and its failing. Please find the terminal logs below.
import { chromium } from 'k6/x/browser';
export default function () {
const browser = chromium.launch({
headless: true,
slowMo: '1s',
});
const context = browser.newContext();
const page = context.newPage();
// 01. Go to the openidconnect landing page and click on CONFIGURATION
page.goto('https://openidconnect.net/', { waitUntil: 'networkidle' }).then(() => {
page.screenshot({ path: 'screenshots/01_screenshot.png' });
page.waitForSelector('button[class="playground-header-config btn btn-link"]');
return page.click('button[class="playground-header-config btn btn-link"]');
}).then(() => {
page.screenshot({ path: 'screenshots/02_screenshot.png' });
page.waitForSelector("select[name='server']");
page.selectOption("select[name='server']", "custom"); // <-------------------
page.screenshot({ path: 'screenshots/03_screenshot.png' });
page.waitForSelector("input[placeholder='https://my-oidc.com/.well-known/openid-configuration']");
return page.click("input[placeholder='https://my-oidc.com/.well-known/openid-configuration']");
}).then(() => {
page.screenshot({ path: 'screenshots/04_screenshot.png' });
page.type("input[placeholder='https://my-oidc.com/.well-known/openid-configuration']", 'https://my-oidc.com/.well-known/openid-configuration');
page.screenshot({ path: 'screenshots/05_screenshot.png' });
}).finally(() => {
page.close();
browser.close();
});
PS C:\K6\xk6-browser> ./xk6-browser run .\openid_test.js
/\ |‾‾| /‾‾/ /‾‾/
/\ / \ | |/ / / /
/ \/ \ | ( / ‾‾\
/ \ | |\ \ | (‾) |
/ __________ \ |__| \__\ \_____/ .io
execution: local
script: .\openid_test.js
output: -
scenarios: (100.00%) 1 scenario, 1 max VUs, 10m30s max duration (incl. graceful stop):
* default: 1 iterations for each of 1 VUs (maxDuration: 10m0s, gracefulStop: 30s)
ERRO[0005] Failed to load resource: the server responded with a status of 403 () browser_source=network line_number=0 source=browser stacktrace="<nil>" url="https://alb.reddit.com/rp.gif?ts=1666863081346&id=t2_16vcix&event=PageVisit&m.itemCount=&m.value=&m.valueDecimal=&m.currency=&m.transactionId=&m.customEventName=&m.products=&uuid=36505dcd-eb5b-4918-8f8e-6567c2a00c0d&aaid=&em=&external_id=&idfa=&integration=reddit&opt_out=0&sh=1280&sw=720&v=rdt_02c59ad6"
ERRO[0030] communicating with browser: read tcp 127.0.0.1:49743->127.0.0.1:49742: wsarecv: An existing connection was forcibly
closed by the remote host. category=cdp elapsed="0 ms" goroutine=46
ERRO[0030] process with PID 79600 unexpectedly ended: exit status 1 category=browser elapsed="34 ms" goroutine=67
ERRO[0030] Uncaught (in promise) GoError: typing "https://my-oidc.com/.well-known/openid-configuration" in "input[placeholder='https://my-oidc.com/.well-known/openid-configuration']": pressing key: dispatching key event up: read tcp 127.0.0.1:49743->127.0.0.1:49742: wsarecv: An existing connection was forcibly closed by the remote host.: GoError
at reflect.methodValueCall (native)
at file:///C:/K6/xk6-browser/openid_test.js:25:4(11)
at native
executor=per-vu-iterations scenario=default
running (00m30.1s), 0/1 VUs, 1 complete and 0 interrupted iterations
default ✓ [======================================] 1 VUs 00m30.1s/10m0s 1/1 iters, 1 per VU
browser_dom_content_loaded.......: avg=212.07ms min=34µs med=2.14ms max=6.01s p(90)=15.77ms p(95)=33.81ms
browser_first_contentful_paint...: avg=6s min=6s med=6s max=6s p(90)=6s p(95)=6s
browser_first_meaningful_paint...: avg=6s min=6s med=6s max=6s p(90)=6s p(95)=6s
browser_first_paint..............: avg=6s min=6s med=6s max=6s p(90)=6s p(95)=6s
browser_loaded...................: avg=558.46ms min=235µs med=5.85ms max=7.11s p(90)=645.84ms p(95)=1.97s
data_received....................: 3.1 MB 104 kB/s
data_sent........................: 51 kB 1.7 kB/s
http_req_connecting..............: avg=74.64ms min=0s med=34ms max=891ms p(90)=142.8ms p(95)=446.59ms
http_req_duration................: avg=331.95ms min=11.75ms med=209.36ms max=2.74s p(90)=615.42ms p(95)=1.03s
http_req_receiving...............: avg=159.15ms min=8ms med=84ms max=2.14s p(90)=276.8ms p(95)=326.19ms
http_req_sending.................: avg=8.54µs min=0s med=0s max=1ms p(90)=0s p(95)=0s
http_req_tls_handshaking.........: avg=50.15ms min=0s med=21ms max=597ms p(90)=104.4ms p(95)=226.39ms
http_reqs........................: 117 3.889821/s
iteration_duration...............: avg=30.07s min=30.07s med=30.07s max=30.07s p(90)=30.07s p(95)=30.07s
iterations.......................: 1 0.033246/s
vus..............................: 1 min=1 max=1
vus_max..........................: 1 min=1 max=1
That’s interesting. By the way, you don’t have to click on the input box (The type
action already does that). So run with the following script:
import { chromium } from 'k6/x/browser';
export default function () {
const browser = chromium.launch({
headless: true,
slowMo: '1s',
});
const context = browser.newContext();
const page = context.newPage();
// 01. Go to the openidconnect landing page and click on CONFIGURATION
page.goto('https://openidconnect.net/', { waitUntil: 'networkidle' }).then(() => {
page.screenshot({ path: 'screenshots/01_screenshot.png' });
page.waitForSelector('button[class="playground-header-config btn btn-link"]');
return page.click('button[class="playground-header-config btn btn-link"]');
}).then(() => {
page.screenshot({ path: 'screenshots/02_screenshot.png' });
page.waitForSelector("select[name='server']");
page.selectOption("select[name='server']", "custom");
page.screenshot({ path: 'screenshots/03_screenshot.png' });
page.type("input[placeholder='https://my-oidc.com/.well-known/openid-configuration']", 'https://my-oidc.com/.well-known/openid-configuration');
page.screenshot({ path: 'screenshots/04_screenshot.png' });
}).finally(() => {
page.close();
browser.close();
});
}
Could you run the script above with the following command and send us the debug log?
XK6_BROWSER_LOG=trace ./xk6-browser run -q .\openid_test.js
Hi @inanc , The above script again failing. Please find the debug log below:
DEBU[0046] sid:EEEA4F6FD40EBCF56D3DB3E2C6F3CD74 tid:D816EA9BC420C4BCBB67E3D208279537 category="FrameSession:initEvents:go:session.done" elapsed="0 ms" goroutine=89
WARN[0046] url:https://snap.licdn.com/li.lms-analytics/insight.min.js method:GET err:fetching response body: closing communication with browser: websocket: close 1001 (going away) category="Response:bodySize:fetchBody" elapsed="0 ms" goroutine=170
DEBU[0046] sid:EEEA4F6FD40EBCF56D3DB3E2C6F3CD74 tid:D816EA9BC420C4BCBB67E3D208279537 category="Session:readLoop:<-s.done" elapsed="1 ms" goroutine=98
DEBU[0046] sid:BB4F2ABF4115DBD650F6A1A7285D9571 tid:D794F84E01C8389A7D9DC6D8A9E5F244 fid:D794F84E01C8389A7D9DC6D8A9E5F244 event:InteractiveTime eventTime:"2022-10-27 16:28:31.015153 +0530 IST m=+11.246753801" category="FrameSession:onPageLifecycle" elapsed="1 ms" goroutine=111
DEBU[0046] sid:BB4F2ABF4115DBD650F6A1A7285D9571 tid:D794F84E01C8389A7D9DC6D8A9E5F244 category="Session:readLoop:<-s.done" elapsed="0 ms" goroutine=102
DEBU[0046] category="Browser:initEvents:EventConnectionClose" elapsed="1 ms" goroutine=82
DEBU[0046] sid:BB4F2ABF4115DBD650F6A1A7285D9571 tid:D794F84E01C8389A7D9DC6D8A9E5F244 method:"Network.getResponseBody" category="Session:Execute:<-evCancelCtx.Done():return" elapsed="0 ms" goroutine=1587
DEBU[0046] sid:EEEA4F6FD40EBCF56D3DB3E2C6F3CD74 tid:D816EA9BC420C4BCBB67E3D208279537 category="NewFrameSession:initEvents:go:return" elapsed="0 ms" goroutine=89
DEBU[0046] fmid:2 rurl:https://snap.licdn.com/li.lms-analytics/insight.min.js category="FrameManager:requestFinished" elapsed="1 ms" goroutine=170
DEBU[0046] sid:BB4F2ABF4115DBD650F6A1A7285D9571 tid:D794F84E01C8389A7D9DC6D8A9E5F244 category="FrameSession:initEvents:go:session.done" elapsed="0 ms" goroutine=111
DEBU[0046] ctx err: <nil> category="Browser:initEvents:defer" elapsed="1 ms" goroutine=82
DEBU[0046] fid:D794F84E01C8389A7D9DC6D8A9E5F244 furl:"https://openidconnect.net/" rid:91616.19 category="Frame:deleteRequest" elapsed="0 ms" goroutine=170
DEBU[0046] sid:BB4F2ABF4115DBD650F6A1A7285D9571 tid:D794F84E01C8389A7D9DC6D8A9E5F244 category="NewFrameSession:initEvents:go:return" elapsed="0 ms" goroutine=111
DEBU[0046] sid:BB4F2ABF4115DBD650F6A1A7285D9571 category="Page:Close" elapsed="1 ms" goroutine=28
DEBU[0046] bctxid:9156F77804C05979AF5457F8A51A6E70 category="BrowserContext:Close" elapsed="0 ms" goroutine=28
DEBU[0046] bctxid:9156F77804C05979AF5457F8A51A6E70 category="Browser:disposeContext" elapsed="0 ms" goroutine=28
DEBU[0046] wsURL:"ws://127.0.0.1:56028/devtools/browser/2e492d12-e6a6-4798-9918-e8b989674927" method:"Target.disposeBrowserContext" category="connection:Execute" elapsed="2 ms" goroutine=28
DEBU[0046] wsURL:"ws://127.0.0.1:56028/devtools/browser/2e492d12-e6a6-4798-9918-e8b989674927" sid: category="Connection:send:<-c.done" elapsed="0 ms" goroutine=28
DEBU[0046] wsURL:"ws://127.0.0.1:56028/devtools/browser/2e492d12-e6a6-4798-9918-e8b989674927" err:context canceled category="connection:Execute:<-evCancelCtx.Done()" elapsed="1 ms" goroutine=1562
DEBU[0046] category="Browser:Close" elapsed="0 ms" goroutine=28
DEBU[0046] category="Browser:GracefulClose" elapsed="1 ms" goroutine=28
DEBU[0046] wsURL:"ws://127.0.0.1:56028/devtools/browser/2e492d12-e6a6-4798-9918-e8b989674927" method:"Browser.close" category="connection:Execute" elapsed="0 ms" goroutine=28
DEBU[0046] wsURL:"ws://127.0.0.1:56028/devtools/browser/2e492d12-e6a6-4798-9918-e8b989674927" sid: err:context
canceled category="Connection:send:<-ctx.Done" elapsed="0 ms" goroutine=28
DEBU[0046] wsURL:"ws://127.0.0.1:56028/devtools/browser/2e492d12-e6a6-4798-9918-e8b989674927" code:1001 category="connection:Close" elapsed="1 ms" goroutine=28
DEBU[0046] wsURL:"ws://127.0.0.1:56028/devtools/browser/2e492d12-e6a6-4798-9918-e8b989674927" err:context canceled category="connection:Execute:<-evCancelCtx.Done()" elapsed="0 ms" goroutine=1590
DEBU[0046] code:1001 category="Connection:close" elapsed="1 ms" goroutine=28
ERRO[0046] Uncaught (in promise) navigating to "https://openidconnect.net/": timed out after 30s executor=per-vu-iterations scenario=default
DEBU[0046] Regular duration is done, waiting for iterations to gracefully finish executor=per-vu-iterations gracefulStop=30s scenario=default
DEBU[0046] Executor finished successfully executor=default startTime=0s type=per-vu-iterations
DEBU[0046] Running teardown() phase=local-execution-scheduler-run
DEBU[0046] Metrics emission of VUs and VUsMax metrics stopped
DEBU[0046] Execution scheduler terminated component=engine error="<nil>"
DEBU[0046] Processing metrics and thresholds after the test run has ended... component=engine
DEBU[0046] Stopping... component=metrics-engine-ingester
DEBU[0046] run: execution scheduler terminated component=engine
DEBU[0046] Stopped! component=metrics-engine-ingester
DEBU[0046] Engine run terminated cleanly
DEBU[0046] Engine: Thresholds terminated component=engine
browser_dom_content_loaded.......: avg=74.97ms min=52µs med=4.2ms max=1.74s p(90)=11.11ms p(95)=37.63ms
browser_first_contentful_paint...: avg=1.75s min=1.75s med=1.75s max=1.75s p(90)=1.75s p(95)=1.75s
browser_first_meaningful_paint...: avg=1.75s min=1.75s med=1.75s max=1.75s p(90)=1.75s p(95)=1.75s
browser_first_paint..............: avg=1.75s min=1.75s med=1.75s max=1.75s p(90)=1.75s p(95)=1.75s
browser_loaded...................: avg=396.64ms min=713µs med=7.27ms max=3.92s p(90)=554.59ms p(95)=1.57s
data_received....................: 1.2 MB 26 kB/s
data_sent........................: 8.7 kB 189 B/s
http_req_connecting..............: avg=139.62ms min=0s med=42ms max=542ms p(90)=409.7ms p(95)=475.84ms
http_req_duration................: avg=689.18ms min=78.62ms med=516.49ms max=1.55s p(90)=1.43s p(95)=1.49s
http_req_receiving...............: avg=321.25ms min=8ms med=137ms max=1.01s p(90)=1s p(95)=1s
http_req_sending.................: avg=0s min=0s med=0s max=0s p(90)=0s p(95)=0s
http_req_tls_handshaking.........: avg=86ms min=0s med=36ms max=294ms p(90)=242.89ms p(95)=268.44ms
http_reqs........................: 8 0.17385/s
iteration_duration...............: avg=46.01s min=46.01s med=46.01s max=46.01s p(90)=46.01s p(95)=46.01s
iterations.......................: 1 0.021731/s
vus..............................: 1 min=1 max=1
vus_max..........................: 1 min=1 max=1
Is this the full debug log?
@inanc . No its not allowing to paste the full log here there is a limit. Is there any way I can extract the logs to a file and send?
https://pastebin.mozilla.org/cY5mhypF
Here also I’m not able to paste the entire log the size too big. You can run this in any windows machine and see you will be able to reproduce this issue.
Unfortunately, I don’t have a Windows machine. I’ll see what I can do. We can tackle this problem if you don’t mind opening an issue on our Github. Please don’t forget to link to this post. Thanks!
@inanc , Raised the below bug and provided this link to this discussion.
opened 07:50PM - 27 Oct 22 UTC
closed 10:18AM - 27 Jan 23 UTC
bug
awaiting user
### Brief summary
Getting the below issue while running the below script on w… indows 10 machine.
"Existing connection was forcibly closed by the remote host"
**Chrome Browser Version:** Version 106.0.5249.119 (Official Build) (64-bit)
**xk6-browser version:** V0.5.0
You can find more details on this issue in the below forum post:
https://community.k6.io/t/existing-connection-was-forcibly-closed-by-the-remote-host/4990/1
```js
import { chromium } from 'k6/x/browser';
export default function () {
const browser = chromium.launch({
headless: true,
slowMo: '1s',
});
const context = browser.newContext();
const page = context.newPage();
// 01. Go to the openidconnect landing page and click on CONFIGURATION
page.goto('https://openidconnect.net/', { waitUntil: 'networkidle' }).then(() => {
page.screenshot({ path: 'screenshots/01_screenshot.png' });
page.waitForSelector('button[class="playground-header-config btn btn-link"]');
return page.click('button[class="playground-header-config btn btn-link"]');
}).then(() => {
page.screenshot({ path: 'screenshots/02_screenshot.png' });
page.waitForSelector("select[name='server']");
page.selectOption("select[name='server']", "custom");
page.screenshot({ path: 'screenshots/03_screenshot.png' });
page.type("input[placeholder='https://my-oidc.com/.well-known/openid-configuration']", 'https://my-oidc.com/.well-known/openid-configuration');
page.screenshot({ path: 'screenshots/04_screenshot.png' });
}).finally(() => {
page.close();
browser.close();
});
}
```
### xk6-browser version
v0.5.0
### OS
Windows 10
### Chrome version
Version 106.0.5249.119 (Official Build) (64-bit)
### Docker version and image (if applicable)
_No response_
### Steps to reproduce the problem
Run the script given in headless mode using chrome browser on windows 10 machine.
### Expected behaviour
The script should click on CONFIGIRATION and type the URL.
### Actual behaviour
The URL given is not typed to the textbox.
1 Like
Thank you! We’ll consider it in the next planning session (next week or so).
Arjun
November 2, 2022, 1:57pm
18
@inanc : I am Facing same issue, we can consider this one Blocker for windows machines. Seems this issue happening due to wait mechanism. While pages are taking longer time for loading, K6 is not waiting for page load, Sometimes DOM got loaded but not actual UI. in that kind of scenarios it forcibly closing the session.
I did tried using below wait Options.
page.waitForLoadState(‘networkidle’);
sleep(15);
sleep(Math.random() * 15);
page.waitForNavigation({ timeout: 100000 });
None of the above methods wait specified until the page get loaded.
Ex : My application will take >=60< seconds to load dashboard page. i tried all the above wait methods for interacting next element after Navigating to dashboard. Obsrved K6 trying to interact element very fast. but all the cases it will not work. then in windows machines we are getting “ERRO[0042] communicating with browser: read tcp 127.0.1.0.1:25484->127.0.1.0.1:25484: wsarecv: An existing connection was forcibly closed by the remote host. category=cdp elapsed=“0 ms” goroutine=88”
ankur
November 4, 2022, 10:49am
19
Hi @Arjun ,
I’ll take another look at this issue soon. Can you please give us the following details to help you further:
The OS and version your computer is running. (10 or 11, WSL/WSL2 or powershell).
Which version of xk6-browser
(was it from the release page, or did you build it yourself?).
The full script (pointing to a public website).
The log output.
Cheers,
Ankur
@inanc @ankur You have any update on this issue?
Hi @vishvambruth.javagal ,
You can track our progress from the issue you opened.
Thanks.