Juna190825 commited on
Commit
28a6cee
·
verified ·
1 Parent(s): 8a69a64

Testing with ChromeDriver

Browse files
Files changed (1) hide show
  1. app.py +5 -2
app.py CHANGED
@@ -122,6 +122,9 @@ def setup_selenium():
122
  # Disable automation flag
123
  options.add_experimental_option("excludeSwitches", ["enable-automation"])
124
  options.add_experimental_option("useAutomationExtension", False)
 
 
 
125
 
126
  # Mimic a real browser's user agent
127
  options.add_argument("user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36")
@@ -200,12 +203,12 @@ def fetch_sentences(input_text):
200
  WebDriverWait(driver, 50).until(EC.presence_of_element_located((By.TAG_NAME, "body")))
201
  time.sleep(10)
202
 
203
- textarea = WebDriverWait(driver, 10).until(
204
  EC.presence_of_element_located((By.ID, "userInput"))
205
  )
206
  textarea.clear()
207
  textarea.send_keys(input_text)
208
- time.sleep(10)
209
 
210
  button = driver.find_element(By.XPATH, "//button[@title='Submit message']")
211
  button.click()
 
122
  # Disable automation flag
123
  options.add_experimental_option("excludeSwitches", ["enable-automation"])
124
  options.add_experimental_option("useAutomationExtension", False)
125
+ options.add_experimental_option("prefs", {
126
+ "profile.default_content_setting_values.notifications": 2 # Disable notifications
127
+ })
128
 
129
  # Mimic a real browser's user agent
130
  options.add_argument("user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36")
 
203
  WebDriverWait(driver, 50).until(EC.presence_of_element_located((By.TAG_NAME, "body")))
204
  time.sleep(10)
205
 
206
+ textarea = WebDriverWait(driver, 20).until(
207
  EC.presence_of_element_located((By.ID, "userInput"))
208
  )
209
  textarea.clear()
210
  textarea.send_keys(input_text)
211
+ time.sleep(20)
212
 
213
  button = driver.find_element(By.XPATH, "//button[@title='Submit message']")
214
  button.click()