forked from All-Hands-AI/OpenHands
-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3b468f9
commit 07a6e6e
Showing
13 changed files
with
149 additions
and
4 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
python-Levenshtein | ||
fuzzywuzzy | ||
arxiv | ||
libcst | ||
libcst | ||
undetected_chromedriver |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import undetected_chromedriver as uc | ||
from selenium import webdriver | ||
from selenium.webdriver.common.by import By | ||
import os | ||
os.chdir(os.path.dirname(os.path.abspath(__file__))) | ||
|
||
if __name__ == '__main__': | ||
# Initialize Chrome options | ||
options = webdriver.ChromeOptions() | ||
options.add_argument('--disable-popup-blocking') | ||
options.headless = False # Set to True if headless mode is required | ||
|
||
# Desired capabilities for logging | ||
capabilities = webdriver.DesiredCapabilities().CHROME | ||
capabilities["goog:loggingPrefs"] = {"performance": "ALL"} | ||
|
||
# Launch the browser using undetected_chromedriver | ||
driver = uc.Chrome(headless=False, use_subprocess=False, options=options) | ||
|
||
# Save session details for reuse | ||
command_url = driver.command_executor._url | ||
session_id = driver.session_id | ||
|
||
session_script = f""" | ||
url = '{command_url}' | ||
session_id = "{session_id}" | ||
""" | ||
|
||
# Print session details | ||
print(f"Command URL: {command_url}") | ||
print(f"Session ID: {session_id}") | ||
|
||
# Write session script to a file | ||
session_file = 'selenium_session_details.py' | ||
with open(session_file, 'w') as file: | ||
file.write(session_script) | ||
|
||
print(f"Session details saved to: {session_file}") |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
url = 'http://localhost:57072' | ||
session_id = "4dcc81cc2c4fc962e6a0dc38882092cf" |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
from selenium import webdriver | ||
|
||
from selenium.webdriver.remote import remote_connection | ||
from selenium.webdriver.remote.command import Command | ||
class SessionRemote(webdriver.Remote): | ||
name = 'chrome' | ||
def start_session(self, desired_capabilities, browser_profile=None): | ||
w3c = True | ||
|
||
|
||
def create_driver(url,session_id): | ||
rmt_con = remote_connection.RemoteConnection(url) | ||
rmt_con._commands.update({ | ||
Command.UPLOAD_FILE: ("POST", "/session/$sessionId/file") | ||
}) | ||
options = webdriver.ChromeOptions() | ||
driver = SessionRemote(command_executor=rmt_con, options=options) | ||
driver.session_id = session_id | ||
return driver | ||
|
||
from sel.selenium_session_details import url,session_id | ||
driver = create_driver(url,session_id) | ||
## import selenium keys | ||
if __name__ == '__main__': | ||
print(driver.current_url) | ||
s = '[data-test-id="icon-disclosure"]' | ||
# click on the element | ||
from selenium.webdriver.common.by import By | ||
# driver.find_element(By.CSS_SELECTOR, s).click() | ||
s='[data-test-id="paper-link"]' | ||
link = driver.find_element(By.CSS_SELECTOR, s).get_attribute('href') | ||
print(link) | ||
|
||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
@echo off | ||
python -i sel/selenium_browser.py |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
python3.12 -i sel/selenium_browser.py |