V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
woshichuanqilz
V2EX  ›  Python

selenium 如何 attach 在一个已经打开的页面上?

  •  
  •   woshichuanqilz · 2017-11-28 12:54:06 +08:00 · 2378 次点击
    这是一个创建于 2338 天前的主题,其中的信息可能已经有所发展或是发生改变。

    我搜索了一下使用了一下的代码, 但是提示由于目标计算机积 极拒绝,无法连接. 不知道各位有没有类似的经历, 实际上我觉得如果能 attach 在已经打开的浏览器上更加的实用。

    # -*- coding: utf-8 -*-
    from selenium import webdriver
    import time
    import json
    import traceback
    import sys
    import os
    from urllib import request
    from selenium.webdriver.common.by import By
    from selenium.webdriver.support.ui import WebDriverWait
    from selenium.webdriver.chrome.options import Options
    
    driver = webdriver.Chrome()  #python
    url = driver.command_executor._url       #"http://127.0.0.1:60622/hub"
    print(url)
    session_id = driver.session_id            #'4e167f26-dc1d-4f51-a207-f761eaf73c31'
    driver = webdriver.Remote(command_executor=url,desired_capabilities={})
    driver.session_id = session_id
    driver.get("http://www.baidu.com")
    
    目前尚无回复
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   4413 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 39ms · UTC 05:33 · PVG 13:33 · LAX 22:33 · JFK 01:33
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.