[WebKit] Page.route() doesn't seem to work as expected on Linux.
See original GitHub issueContext:
- Playwright Version: 1.18.1
- Operating System: Linux(Ubuntu 20.04 LTS)
- Python version: 3.8.10
- Browser: WebKit
- Extra:
Code Snippet
import asyncio
from playwright.async_api import async_playwright, Route, Request
async def func(url):
async with async_playwright() as p:
_browser = await p.webkit.launch(proxy={"server": "socks5://127.0.0.1:10808"})
_context = await _browser.new_context()
page = await _context.new_page()
async def _hook_request(route: Route, request: Request):
new_headers = {
**request.headers,
'TEST': 'test123456789',
'Cookie': 'AAAA=NBBBB; '
}
print(request.url)
print(new_headers)
await route.continue_(headers=new_headers)
pass
await page.route('*',_hook_request)
await page.goto(url, wait_until='networkidle', timeout=5*60*1000)
print(await page.inner_text('*'))
await _context.close()
await _browser.close()
pass
pass
async def main():
await func('http://httpbin.org/get')
pass
if __name__ == '__main__':
asyncio.run(main())
pass
Describe the bug
Execute the above code, the output is as follows:
http://httpbin.org/get
{'accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 'upgrade-insecure-requests': '1', 'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.4 Safari/605.1.15', 'TEST': 'test123456789', 'Cookie': 'AAAA=NBBBB; '}
{
"args": {},
"headers": {
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
"Accept-Encoding": "gzip, deflate",
"Accept-Language": "en-US",
"Host": "httpbin.org",
"Test": "test123456789",
"Upgrade-Insecure-Requests": "1",
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.4 Safari/605.1.15",
"X-Amzn-Trace-Id": "Root=1-6201c3e4-5f3435bf320770fd1c183156"
},
"origin": "104.245.96.65",
"url": "http://httpbin.org/get"
}
Apparently the Hook request and then modifying the cookie fails.If I change my browser to Chromium it works as expected, but there are some other issues. By the way the same code works as expected under Windows.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:13 (8 by maintainers)
Top Results From Across the Web
Handling common HTML and CSS problems - MDN Web Docs
Objective: To be able to diagnose common HTML and CSS cross browser problems, and use appropriate tools and techniques to fix them. The ......
Read more >luakit browser framework (almost with jQuery!) (Page 25 ...
-when I download something (like a pdf) i am unable to open it from luakit, how to make the linux command "mimeopen" open...
Read more >Angular 2 Routing Does Not Work When Deployed to Http ...
But when I deploy the project in http-server, the links do not work as expected. I deployed the app using 'http-server ./dist' command...
Read more >WebView - Android Developers
A WebView is useful when you need increased control over the UI and advanced configuration options that will allow you to embed web...
Read more >QRadar APARs 101 - IBM
The QRadar Support team created this QRadar APARs 101 page to make APARs ... Routing Rule window does not display as expected when...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Thanks Reply. The second object is output on line 23
print(await page.inner_text('*'))
in the above code. The second object is the result returned by accessinghttp://httpbin.org/get
I have a similar issue. I use msw and playwright-msw which under the hood intercepts all requests using
page.route
. In my case, cookies are set in WebKit but in playwright intercepted requests don’t have cookies in headers even though I can see that WebKit browser included them (I can see it from devtools). In other browsers, cookies are properly included in intercepted requests but for WebKit they aren’t.Can you please re-open this issue?
Context: Playwright Version: 1.27.1 Operating System: WSL (Ubuntu 20.04) Browser: WebKit 1724