Last active
October 5, 2018 22:44
-
-
Save hjwp/90141915d0b1bde0d5c472a5fc7fcf16 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<htmL> | |
<head> | |
<title>Hello, Greetings</title> | |
</head> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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