推荐学习书目
› 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 · Nov 28, 2017 · 3018 views
    This topic created in 3239 days ago, the information mentioned may be changed or developed.

    我搜索了一下使用了一下的代码, 但是提示由于目标计算机积 极拒绝,无法连接. 不知道各位有没有类似的经历, 实际上我觉得如果能 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")
    
    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   3148 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 22ms · UTC 14:14 · PVG 22:14 · LAX 07:14 · JFK 10:14
    ♥ Do have faith in what you're doing.