Comments (7)
Try replacing
playwright.chromium.connect_over_cdp(("http://localhost:1234"))
with
playwright.chromium.connect_over_cdp(("http://127.0.0.1:1234"))
It sound like localhost resolves to ipv6 on your system.
from playwright.
My guess is that
chrome_path = r'"C:\Program Files\Google\Chrome\Application\chrome.exe"'
debugging_port = "--remote-debugging-port=1234"
command = f"{chrome_path} {debugging_port}"
subprocess.Popen(command, shell=True)
is not working or not waiting long enough to Playwright to connect, so the server is not listening yet. Could you verify that?
from playwright.
Try replacing
playwright.chromium.connect_over_cdp(("http://localhost:1234"))
with
playwright.chromium.connect_over_cdp(("http://127.0.0.1:1234"))
It sound like localhost resolves to ipv6 on your system.
Try replacing
playwright.chromium.connect_over_cdp(("http://localhost:1234"))
with
playwright.chromium.connect_over_cdp(("http://127.0.0.1:1234"))
It sound like localhost resolves to ipv6 on your system.
browser = playwright.chromium.connect_over_cdp("http://127.0.0.1:1234")
when I change to browser = playwright.chromium.connect_over_cdp("ws://127.0.0.1:1234")
from playwright.
My guess is that
chrome_path = r'"C:\Program Files\Google\Chrome\Application\chrome.exe"'
debugging_port = "--remote-debugging-port=1234"command = f"{chrome_path} {debugging_port}"
subprocess.Popen(command, shell=True)is not working or not waiting long enough to Playwright to connect, so the server is not listening yet. Could you verify that?
sure, i'll try wait longer time. I have setting the time=10s, still error.
I guess a possible reason is that I use a vpn, is that cause the error?
from playwright.
I had to modify it a little bit, since I'm on macOS, then it was working for me, note the --user-data-dir
:
chrome_path = r'"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"'
debugging_port = "--remote-debugging-port=1234 --user-data-dir=foo"
command = f"{chrome_path} {debugging_port}"
subprocess.Popen(command, shell=True)
from playwright.
I had to modify it a little bit, since I'm on macOS, then it was working for me, note the
--user-data-dir
:chrome_path = r'"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"' debugging_port = "--remote-debugging-port=1234 --user-data-dir=foo" command = f"{chrome_path} {debugging_port}" subprocess.Popen(command, shell=True)
thx, not working on windows.
Since YouTube has a security check mechanism and detected that the Playwright framework contained risks, I wondered if there was a possibility to let Playwright open the local browser and load local cookies and plug-ins, which would save the login step.
So I tried another method:
def run(playwright):
browser = playwright.chromium.launch_persistent_context(
user_data_dir=r"C:\Users\Louis\AppData\Local\Google\Chrome\User Data\Profile 1", # 设置用户数据目录
executable_path=r'C:\Program Files\Google\Chrome\Application\chrome.exe', # Chrome 可执行文件路径
accept_downloads=True, # 允许下载
headless=False, # 非无头模式,即显示浏览器界面
bypass_csp=True, # 绕过 Content Security Policy
slow_mo=10, # 减速执行,便于调试
args=[
'--disable-blink-features=AutomationControlled', # 禁用 Blink 功能控制
'--remote-debugging-port=1234', # 启用远程调试端口
'--in-process-plugins', # 插件在浏览器进程中运行
'--allow-outdated-plugins', # 允许使用过期插件
]
)
page = browser.new_page()
page.goto("https://www.baidu.com/")
print(page.title())
page.pause()
with sync_playwright() as playwright:
run(playwright)
is it possible to open a broswer with cache and plugin? and how about codegen using my own broswer?
from playwright.
This doesn't look like and end-to-end testing use-case, so I'm going to close it for now. If you want to open an existing profile, see e.g. here or here.
from playwright.
Related Issues (20)
- Some of the script are running fine on local but getting failed on github action pipeline. It is giving timeout exceed error in logs
- The addLocatorHandler method can be triggered in the test environment, but it does not trigger when using the library. why this is happening? HOT 1
- [Feature]: --only-changed - run the global set up/teardown files in addition to changed tests HOT 1
- Hello, if the URL jump occurs by clicking on the event on the page, which method is better recommended? I see two methods in the official documentation, waitForURL and waitForNavigation. According to our usage habits, we prefer to use waitForNavigation, but the document mark says that it has been abandoned, and it also says that this method is inherently dangerous. Could you explain the reason? Because we do not pay attention to the url of the click event, if we use waitForURL, it will increase our workload. Thank you!
- [Bug]: waitForURL and waitForNavigation
- How to automate Save/save as Modal using playwright HOT 1
- [Bug]: Incorrect user agent HOT 1
- [Bug]: Symlinked directories inside testDir are ignored in MacOS
- [Bug]: window.resizeTo/resizeBy and window.moveTo/moveBy do not work in Chromium
- [Bug]: Unable to capture full page snapshot of some sites with Chromium and Firefox HOT 1
- [Bug]: Credential scanning tool flags shipped private key HOT 3
- [Bug]: playwright randomly skipping tests once failure is encountered, it sort of terminating the run HOT 3
- [Bug]: Screenshot not recorded/shown in timeline for Webkit HOT 3
- [Bug]: HOT 3
- [Feature]: Add current page URL to Playwright screenshots and videos (eg. render the mock browser chrome) HOT 3
- [Chore]: Set up React StrictMode for tests
- [Feature]: Allow `--only-changed` to work with `--list`
- How can I open a full-screen browser in playwright codegen mode? HOT 1
- [Bug]: Do not open up TLS sessions when using client certificates on matches which don't match HOT 1
- [Bug]: Playwright Components isn't working (React 18/19) HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from playwright.