Skip to content

Instantly share code, notes, and snippets.

@hjwp
Last active October 5, 2018 22:44
Show Gist options
  • Save hjwp/90141915d0b1bde0d5c472a5fc7fcf16 to your computer and use it in GitHub Desktop.
Save hjwp/90141915d0b1bde0d5c472a5fc7fcf16 to your computer and use it in GitHub Desktop.
<htmL>
<head>
<title>Hello, Greetings</title>
</head>
</html>
from selenium.webdriver.remote.webdriver import WebDriver as RemoteWebDriver
from selenium.webdriver.firefox.remote_connection import FirefoxRemoteConnection
class ReattachingRemoteWebDriver(RemoteWebDriver):
def start_session(self, *args, **kwargs):
pass
def attach_new_driver(url, session_id):
print('attaching to', url, session_id)
executor = FirefoxRemoteConnection(remote_server_addr=url)
d2 = ReattachingRemoteWebDriver(
command_executor=executor, desired_capabilities={}
)
d2.session_id = session_id
return d2
import sys
if __name__ == '__main__':
driver = attach_new_driver(*sys.argv[1:])
driver.get('file:///tmp/index.html')
print(driver.title)
import time
from selenium import webdriver
if __name__ == '__main__':
try:
driver = webdriver.Firefox()
print(driver.command_executor._url, driver.session_id)
time.sleep(1000)
except:
driver.close()
raise
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment