[英]Python webdriver connect to already webpage (selenium)
I need to open multiple links in separate tabs or sessions... I already know how to do it, so what i would like to know is if it's possible to connect to an already open webpage instead of open every links every time i run the script. 我需要在单独的选项卡或会话中打开多个链接...我已经知道该怎么做,所以我想知道的是,是否有可能连接到一个已经打开的网页,而不是每次运行该链接时都打开每个链接。脚本。 What i used now in Python is:
我现在在Python中使用的是:
from selenium import webdriver
driver.get(link)
The purpose would be once i run the first script (to load multiple links), the second should connect to the webpages, refresh them and continue with the code. 目的是一旦我运行第一个脚本(以加载多个链接),第二个脚本应连接到网页,刷新它们并继续执行代码。 Is it possible?
可能吗? Anyone know how to do it?
有人知道怎么做吗?
Thanks a lot for the help!!!! 非常感谢您的帮助!!!!
Connecting to the previously opened window is easy: 连接到先前打开的窗口很容易:
driver = webdriver.Firefox()
url = driver.command_executor._url
session_id = driver.session_id
driver2 = webdriver.Remote(command_executor=url,desired_capabilities={})
driver2.session_id = session_id
#You're all set to do whatever with the previously opened browser
driver2.get("http://www.stackoverflow.com")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.