NihalGazi commited on
Commit
fc9edb8
·
verified ·
1 Parent(s): cce1b6e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -9
app.py CHANGED
@@ -1,25 +1,24 @@
1
  import gradio as gr
2
  from selenium import webdriver
3
- from selenium.common.exceptions import WebDriverException
4
  from selenium.webdriver.common.by import By
5
  from selenium.webdriver.common.keys import Keys
6
- from selenium.webdriver.chrome.service import Service as ChromeService
7
- from webdriver_manager.chrome import ChromeDriverManager
8
  from PIL import Image
9
  from io import BytesIO
10
  import time
11
 
12
  def take_screenshot_and_login(url, email, password):
13
- options = webdriver.ChromeOptions()
14
  options.add_argument('--headless')
15
  options.add_argument('--no-sandbox')
16
  options.add_argument('--disable-dev-shm-usage')
17
 
18
  wd = None
19
  try:
20
- # Use ChromeDriverManager to automatically manage the ChromeDriver executable
21
- service = ChromeService(ChromeDriverManager().install())
22
- wd = webdriver.Chrome(service=service, options=options)
23
 
24
  wd.set_window_size(1080, 720)
25
  wd.get(url)
@@ -37,8 +36,8 @@ def take_screenshot_and_login(url, email, password):
37
 
38
  # Take a screenshot
39
  screenshot = wd.get_screenshot_as_png()
40
- except WebDriverException as e:
41
- print(f"WebDriverException occurred: {e}")
42
  return Image.new('RGB', (1080, 720), color='white')
43
  finally:
44
  if wd:
 
1
  import gradio as gr
2
  from selenium import webdriver
 
3
  from selenium.webdriver.common.by import By
4
  from selenium.webdriver.common.keys import Keys
5
+ from selenium.webdriver.firefox.service import Service as FirefoxService
6
+ from webdriver_manager.firefox import GeckoDriverManager
7
  from PIL import Image
8
  from io import BytesIO
9
  import time
10
 
11
  def take_screenshot_and_login(url, email, password):
12
+ options = webdriver.FirefoxOptions()
13
  options.add_argument('--headless')
14
  options.add_argument('--no-sandbox')
15
  options.add_argument('--disable-dev-shm-usage')
16
 
17
  wd = None
18
  try:
19
+ # Use GeckoDriverManager to automatically manage the Geckodriver executable
20
+ service = FirefoxService(GeckoDriverManager().install())
21
+ wd = webdriver.Firefox(service=service, options=options)
22
 
23
  wd.set_window_size(1080, 720)
24
  wd.get(url)
 
36
 
37
  # Take a screenshot
38
  screenshot = wd.get_screenshot_as_png()
39
+ except Exception as e:
40
+ print(f"Exception occurred: {e}")
41
  return Image.new('RGB', (1080, 720), color='white')
42
  finally:
43
  if wd: