Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add fragment to url #2079

Merged
merged 2 commits into from
Mar 27, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions src/bidiMapper/domains/network/NetworkRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,14 +129,19 @@ export class NetworkRequest {
}

get url(): string {
return (
const fragment =
this.#request.info?.request.urlFragment ??
this.#request.paused?.request.urlFragment ??
'';
const url =
this.#response.info?.url ??
this.#response.paused?.request.url ??
this.#request.auth?.request.url ??
this.#request.info?.request.url ??
this.#request.paused?.request.url ??
NetworkRequest.unknownParameter
);
NetworkRequest.unknownParameter;

return `${url}${fragment}`;
}

get method(): string {
Expand Down
46 changes: 46 additions & 0 deletions tests/network/test_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,52 @@ async def test_network_before_request_sent_event_emitted(
}


@pytest.mark.asyncio
async def test_network_before_request_sent_event_emitted_with_url_fragment(
websocket, context_id, base_url):
await subscribe(websocket, ["network.beforeRequestSent"], [context_id])

url_fragment = "#test"
url = f"{base_url}{url_fragment}"

await send_JSON_command(
websocket, {
"method": "browsingContext.navigate",
"params": {
"url": url,
"wait": "complete",
"context": context_id
}
})

resp = await read_JSON_message(websocket)

assert resp == {
'type': 'event',
"method": "network.beforeRequestSent",
"params": {
"isBlocked": False,
"context": context_id,
"navigation": ANY_STR,
"redirectCount": 0,
"request": {
"request": ANY_STR,
"url": url,
"method": "GET",
"headers": ANY_LIST,
"cookies": [],
"headersSize": ANY_NUMBER,
"bodySize": 0,
"timings": ANY_DICT
},
"initiator": {
"type": "other"
},
"timestamp": ANY_TIMESTAMP
}
}


@pytest.mark.asyncio
async def test_network_global_subscription_enabled_in_new_context(
websocket, create_context, base_url):
Expand Down
Loading