richardyc / Chrome-GPT

An AutoGPT agent that controls Chrome on your desktop
GNU General Public License v3.0
1.66k stars 208 forks source link

How to login into web pages? #6

Open avion23 opened 1 year ago

avion23 commented 1 year ago

I am seeking to automate the download process from https://sellercentral.amazon.de/payments/allstatements/index.html. Like many other pages, this one requires a login.

However, even when logging in manually, the process continues to crash.

I have noticed that Selenium is used for this purpose, but I have not yet discovered an effective method to incorporate logins. Does anyone have suggestions on how to address this issue?

avion23 commented 1 year ago

So I have no Idea what I am doing. This works:

diff --git a/chromegpt/tools/selenium.py b/chromegpt/tools/selenium.py
index 3a02a5f..c0e74c5 100644
--- a/chromegpt/tools/selenium.py
+++ b/chromegpt/tools/selenium.py
@@ -36,16 +36,21 @@ class SeleniumWrapper:
             selenium = SeleniumWrapper()
     """

+
     def __init__(self, headless: bool = False) -> None:
-        """Initialize Selenium and start interactive session."""
         chrome_options = Options()
+
         if headless:
             chrome_options.add_argument("--headless")
         else:
             chrome_options.add_argument("--start-maximized")
+
+        remote_debugging_port = "9222"
+        chrome_options.add_argument(f"--remote-debugging-port={remote_debugging_port}")
+
         self.driver = webdriver.Chrome(options=chrome_options)
         self.driver.implicitly_wait(5)  # Wait 5 seconds for elements to load
-
+
     def __del__(self) -> None:
         """Close Selenium session."""
         self.driver.close()
wu-s-john commented 1 year ago

I tried to login with my LinkedIn account with this thing. It actually does this automatically for me. It just does this really slowly. You just need to provide your account details and password on the prompt