seleniumbase 4.19.1__py3-none-any.whl → 4.20.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. seleniumbase/__version__.py +1 -1
  2. seleniumbase/behave/behave_sb.py +17 -9
  3. seleniumbase/console_scripts/logo_helper.py +8 -1
  4. seleniumbase/console_scripts/run.py +5 -2
  5. seleniumbase/console_scripts/sb_behave_gui.py +7 -1
  6. seleniumbase/console_scripts/sb_caseplans.py +7 -1
  7. seleniumbase/console_scripts/sb_commander.py +7 -1
  8. seleniumbase/console_scripts/sb_install.py +4 -1
  9. seleniumbase/console_scripts/sb_mkchart.py +7 -1
  10. seleniumbase/console_scripts/sb_mkdir.py +7 -1
  11. seleniumbase/console_scripts/sb_mkfile.py +7 -1
  12. seleniumbase/console_scripts/sb_mkpres.py +7 -1
  13. seleniumbase/console_scripts/sb_mkrec.py +7 -1
  14. seleniumbase/console_scripts/sb_print.py +7 -1
  15. seleniumbase/console_scripts/sb_recorder.py +7 -1
  16. seleniumbase/core/browser_launcher.py +102 -14
  17. seleniumbase/core/sb_driver.py +38 -0
  18. seleniumbase/fixtures/base_case.py +23 -23
  19. seleniumbase/fixtures/constants.py +13 -0
  20. seleniumbase/fixtures/js_utils.py +1 -1
  21. seleniumbase/fixtures/page_actions.py +30 -0
  22. seleniumbase/plugins/driver_manager.py +2 -5
  23. seleniumbase/plugins/pytest_plugin.py +14 -14
  24. seleniumbase/plugins/sb_manager.py +16 -8
  25. seleniumbase/plugins/selenium_plugin.py +4 -13
  26. seleniumbase/translate/translator.py +7 -1
  27. seleniumbase/undetected/__init__.py +6 -11
  28. {seleniumbase-4.19.1.dist-info → seleniumbase-4.20.0.dist-info}/METADATA +5 -5
  29. {seleniumbase-4.19.1.dist-info → seleniumbase-4.20.0.dist-info}/RECORD +33 -33
  30. {seleniumbase-4.19.1.dist-info → seleniumbase-4.20.0.dist-info}/LICENSE +0 -0
  31. {seleniumbase-4.19.1.dist-info → seleniumbase-4.20.0.dist-info}/WHEEL +0 -0
  32. {seleniumbase-4.19.1.dist-info → seleniumbase-4.20.0.dist-info}/entry_points.txt +0 -0
  33. {seleniumbase-4.19.1.dist-info → seleniumbase-4.20.0.dist-info}/top_level.txt +0 -0
@@ -1,2 +1,2 @@
1
1
  # seleniumbase package
2
- __version__ = "4.19.1"
2
+ __version__ = "4.20.0"
@@ -111,6 +111,8 @@ from seleniumbase.core import session_helper
111
111
  from seleniumbase.fixtures import constants
112
112
  from seleniumbase.fixtures import shared_utils
113
113
 
114
+ is_linux = shared_utils.is_linux()
115
+ is_windows = shared_utils.is_windows()
114
116
  sb_config.__base_class = None
115
117
 
116
118
 
@@ -829,10 +831,10 @@ def get_configured_sb(context):
829
831
  '\n (Your browser choice was: "%s")\n' % sb.browser
830
832
  )
831
833
  # The Xvfb virtual display server is for Linux OS Only.
832
- if sb.xvfb and not shared_utils.is_linux():
834
+ if sb.xvfb and not is_linux:
833
835
  sb.xvfb = False
834
836
  if (
835
- shared_utils.is_linux()
837
+ is_linux
836
838
  and not sb.headed
837
839
  and not sb.headless
838
840
  and not sb.headless2
@@ -1020,7 +1022,7 @@ def dashboard_pre_processing():
1020
1022
  filename = None
1021
1023
  feature_name = None
1022
1024
  scenario_name = None
1023
- if shared_utils.is_windows():
1025
+ if is_windows:
1024
1026
  output = output.decode("latin1")
1025
1027
  else:
1026
1028
  output = output.decode("utf-8")
@@ -1129,8 +1131,11 @@ def behave_dashboard_prepare():
1129
1131
  stars = "*" * star_len
1130
1132
  c1 = ""
1131
1133
  cr = ""
1132
- if not shared_utils.is_linux():
1133
- colorama.init(autoreset=True)
1134
+ if not is_linux:
1135
+ if is_windows and hasattr(colorama, "just_fix_windows_console"):
1136
+ colorama.just_fix_windows_console()
1137
+ else:
1138
+ colorama.init(autoreset=True)
1134
1139
  c1 = colorama.Fore.BLUE + colorama.Back.LIGHTCYAN_EX
1135
1140
  cr = colorama.Style.RESET_ALL
1136
1141
  print("Dashboard: %s%s%s\n%s" % (c1, dash_path, cr, stars))
@@ -1144,7 +1149,7 @@ def _perform_behave_unconfigure_():
1144
1149
  if sb_config.shared_driver:
1145
1150
  try:
1146
1151
  if (
1147
- not shared_utils.is_windows()
1152
+ not is_windows
1148
1153
  or sb_config.browser == "ie"
1149
1154
  or sb_config.shared_driver.service.process
1150
1155
  ):
@@ -1221,7 +1226,7 @@ def do_final_driver_cleanup_as_needed():
1221
1226
  try:
1222
1227
  if hasattr(sb_config, "last_driver") and sb_config.last_driver:
1223
1228
  if (
1224
- not shared_utils.is_windows()
1229
+ not is_windows
1225
1230
  or sb_config.browser == "ie"
1226
1231
  or sb_config.last_driver.service.process
1227
1232
  ):
@@ -1245,8 +1250,11 @@ def _perform_behave_terminal_summary_():
1245
1250
  equals = "=" * (equals_len + 2)
1246
1251
  c2 = ""
1247
1252
  cr = ""
1248
- if not shared_utils.is_linux():
1249
- colorama.init(autoreset=True)
1253
+ if not is_linux:
1254
+ if is_windows and hasattr(colorama, "just_fix_windows_console"):
1255
+ colorama.just_fix_windows_console()
1256
+ else:
1257
+ colorama.init(autoreset=True)
1250
1258
  c2 = colorama.Fore.MAGENTA + colorama.Back.LIGHTYELLOW_EX
1251
1259
  cr = colorama.Style.RESET_ALL
1252
1260
  if sb_config.dashboard:
@@ -3,6 +3,7 @@
3
3
  http://www.patorjk.com/software/taag/#p=display&f=Slant&t=SeleniumBase """
4
4
 
5
5
  import colorama
6
+ import sys
6
7
 
7
8
  r"""
8
9
  ______ __ _ ____
@@ -14,7 +15,13 @@ r"""
14
15
 
15
16
 
16
17
  def get_seleniumbase_logo():
17
- colorama.init(autoreset=True)
18
+ if (
19
+ "win32" in sys.platform
20
+ and hasattr(colorama, "just_fix_windows_console")
21
+ ):
22
+ colorama.just_fix_windows_console()
23
+ else:
24
+ colorama.init(autoreset=True)
18
25
  c1 = colorama.Fore.BLUE + colorama.Back.LIGHTCYAN_EX
19
26
  c2 = colorama.Fore.BLUE + colorama.Back.LIGHTGREEN_EX
20
27
  c3 = colorama.Back.CYAN
@@ -41,8 +41,12 @@ import sys
41
41
  import time
42
42
  from seleniumbase.config import settings
43
43
  from seleniumbase.fixtures import constants
44
+ from seleniumbase.fixtures import shared_utils
44
45
 
45
- colorama.init(autoreset=True)
46
+ if shared_utils.is_windows() and hasattr(colorama, "just_fix_windows_console"):
47
+ colorama.just_fix_windows_console()
48
+ else:
49
+ colorama.init(autoreset=True)
46
50
 
47
51
 
48
52
  def show_usage():
@@ -1330,7 +1334,6 @@ def main():
1330
1334
  show_detailed_help()
1331
1335
  else:
1332
1336
  show_usage()
1333
- colorama.init(autoreset=True)
1334
1337
  c5 = colorama.Fore.RED + colorama.Back.LIGHTYELLOW_EX
1335
1338
  c7 = colorama.Fore.BLACK + colorama.Back.MAGENTA
1336
1339
  cr = colorama.Style.RESET_ALL
@@ -38,7 +38,13 @@ def set_colors(use_colors):
38
38
  c6 = ""
39
39
  cr = ""
40
40
  if use_colors:
41
- colorama.init(autoreset=True)
41
+ if (
42
+ "win32" in sys.platform
43
+ and hasattr(colorama, "just_fix_windows_console")
44
+ ):
45
+ colorama.just_fix_windows_console()
46
+ else:
47
+ colorama.init(autoreset=True)
42
48
  c0 = colorama.Fore.BLUE + colorama.Back.LIGHTCYAN_EX
43
49
  c1 = colorama.Fore.BLUE + colorama.Back.LIGHTGREEN_EX
44
50
  c2 = colorama.Fore.RED + colorama.Back.LIGHTYELLOW_EX
@@ -42,7 +42,13 @@ def set_colors(use_colors):
42
42
  c5 = ""
43
43
  cr = ""
44
44
  if use_colors:
45
- colorama.init(autoreset=True)
45
+ if (
46
+ "win32" in sys.platform
47
+ and hasattr(colorama, "just_fix_windows_console")
48
+ ):
49
+ colorama.just_fix_windows_console()
50
+ else:
51
+ colorama.init(autoreset=True)
46
52
  c0 = colorama.Fore.BLUE + colorama.Back.LIGHTCYAN_EX
47
53
  c1 = colorama.Fore.BLUE + colorama.Back.LIGHTGREEN_EX
48
54
  c2 = colorama.Fore.RED + colorama.Back.LIGHTYELLOW_EX
@@ -42,7 +42,13 @@ def set_colors(use_colors):
42
42
  c5 = ""
43
43
  cr = ""
44
44
  if use_colors:
45
- colorama.init(autoreset=True)
45
+ if (
46
+ "win32" in sys.platform
47
+ and hasattr(colorama, "just_fix_windows_console")
48
+ ):
49
+ colorama.just_fix_windows_console()
50
+ else:
51
+ colorama.init(autoreset=True)
46
52
  c0 = colorama.Fore.BLUE + colorama.Back.LIGHTCYAN_EX
47
53
  c1 = colorama.Fore.BLUE + colorama.Back.LIGHTGREEN_EX
48
54
  c2 = colorama.Fore.RED + colorama.Back.LIGHTYELLOW_EX
@@ -293,7 +293,10 @@ def main(override=None, intel_for_uc=None, force_uc=None):
293
293
  use_version = ""
294
294
  new_file = ""
295
295
  f_name = ""
296
- colorama.init(autoreset=True)
296
+ if IS_WINDOWS and hasattr(colorama, "just_fix_windows_console"):
297
+ colorama.just_fix_windows_console()
298
+ else:
299
+ colorama.init(autoreset=True)
297
300
  c1 = colorama.Fore.BLUE + colorama.Back.LIGHTCYAN_EX
298
301
  c2 = colorama.Fore.BLUE + colorama.Back.LIGHTGREEN_EX
299
302
  c3 = colorama.Fore.BLUE + colorama.Back.LIGHTYELLOW_EX
@@ -62,7 +62,13 @@ def main():
62
62
  c7 = ""
63
63
  cr = ""
64
64
  if "linux" not in sys.platform:
65
- colorama.init(autoreset=True)
65
+ if (
66
+ "win32" in sys.platform
67
+ and hasattr(colorama, "just_fix_windows_console")
68
+ ):
69
+ colorama.just_fix_windows_console()
70
+ else:
71
+ colorama.init(autoreset=True)
66
72
  c1 = colorama.Fore.BLUE + colorama.Back.LIGHTCYAN_EX
67
73
  c5 = colorama.Fore.RED + colorama.Back.LIGHTYELLOW_EX
68
74
  c7 = colorama.Fore.BLACK + colorama.Back.MAGENTA
@@ -54,7 +54,13 @@ def main():
54
54
  c7 = ""
55
55
  cr = ""
56
56
  if "linux" not in sys.platform:
57
- colorama.init(autoreset=True)
57
+ if (
58
+ "win32" in sys.platform
59
+ and hasattr(colorama, "just_fix_windows_console")
60
+ ):
61
+ colorama.just_fix_windows_console()
62
+ else:
63
+ colorama.init(autoreset=True)
58
64
  c1 = colorama.Fore.BLUE + colorama.Back.LIGHTCYAN_EX
59
65
  c5 = colorama.Fore.RED + colorama.Back.LIGHTYELLOW_EX
60
66
  c7 = colorama.Fore.BLACK + colorama.Back.MAGENTA
@@ -92,7 +92,13 @@ def main():
92
92
  c7 = ""
93
93
  cr = ""
94
94
  if "linux" not in sys.platform:
95
- colorama.init(autoreset=True)
95
+ if (
96
+ "win32" in sys.platform
97
+ and hasattr(colorama, "just_fix_windows_console")
98
+ ):
99
+ colorama.just_fix_windows_console()
100
+ else:
101
+ colorama.init(autoreset=True)
96
102
  c1 = colorama.Fore.BLUE + colorama.Back.LIGHTCYAN_EX
97
103
  c5 = colorama.Fore.RED + colorama.Back.LIGHTYELLOW_EX
98
104
  c7 = colorama.Fore.BLACK + colorama.Back.MAGENTA
@@ -62,7 +62,13 @@ def main():
62
62
  c7 = ""
63
63
  cr = ""
64
64
  if "linux" not in sys.platform:
65
- colorama.init(autoreset=True)
65
+ if (
66
+ "win32" in sys.platform
67
+ and hasattr(colorama, "just_fix_windows_console")
68
+ ):
69
+ colorama.just_fix_windows_console()
70
+ else:
71
+ colorama.init(autoreset=True)
66
72
  c1 = colorama.Fore.BLUE + colorama.Back.LIGHTCYAN_EX
67
73
  c5 = colorama.Fore.RED + colorama.Back.LIGHTYELLOW_EX
68
74
  c7 = colorama.Fore.BLACK + colorama.Back.MAGENTA
@@ -71,7 +71,13 @@ def set_colors(use_colors):
71
71
  c7 = ""
72
72
  cr = ""
73
73
  if use_colors:
74
- colorama.init(autoreset=True)
74
+ if (
75
+ "win32" in sys.platform
76
+ and hasattr(colorama, "just_fix_windows_console")
77
+ ):
78
+ colorama.just_fix_windows_console()
79
+ else:
80
+ colorama.init(autoreset=True)
75
81
  c0 = colorama.Fore.BLUE + colorama.Back.LIGHTCYAN_EX
76
82
  c1 = colorama.Fore.RED + colorama.Back.LIGHTYELLOW_EX
77
83
  c2 = colorama.Fore.LIGHTRED_EX + colorama.Back.LIGHTYELLOW_EX
@@ -61,7 +61,13 @@ def get_width(line):
61
61
 
62
62
 
63
63
  def main():
64
- colorama.init(autoreset=True)
64
+ if (
65
+ "win32" in sys.platform
66
+ and hasattr(colorama, "just_fix_windows_console")
67
+ ):
68
+ colorama.just_fix_windows_console()
69
+ else:
70
+ colorama.init(autoreset=True)
65
71
  c5 = colorama.Fore.RED + colorama.Back.LIGHTYELLOW_EX
66
72
  c7 = colorama.Fore.BLACK + colorama.Back.MAGENTA
67
73
  cr = colorama.Style.RESET_ALL
@@ -42,7 +42,13 @@ def set_colors(use_colors):
42
42
  c4 = ""
43
43
  cr = ""
44
44
  if use_colors:
45
- colorama.init(autoreset=True)
45
+ if (
46
+ "win32" in sys.platform
47
+ and hasattr(colorama, "just_fix_windows_console")
48
+ ):
49
+ colorama.just_fix_windows_console()
50
+ else:
51
+ colorama.init(autoreset=True)
46
52
  c0 = colorama.Fore.BLUE + colorama.Back.LIGHTCYAN_EX
47
53
  c1 = colorama.Fore.BLUE + colorama.Back.LIGHTGREEN_EX
48
54
  c2 = colorama.Fore.RED + colorama.Back.LIGHTYELLOW_EX
@@ -116,6 +116,9 @@ def extend_driver(driver):
116
116
  page = types.SimpleNamespace()
117
117
  page.open = DM.open_url
118
118
  page.click = DM.click
119
+ page.click_link = DM.click_link
120
+ page.click_if_visible = DM.click_if_visible
121
+ page.click_active_element = DM.click_active_element
119
122
  page.send_keys = DM.send_keys
120
123
  page.press_keys = DM.press_keys
121
124
  page.type = DM.update_text
@@ -134,10 +137,13 @@ def extend_driver(driver):
134
137
  page.is_element_visible = DM.is_element_visible
135
138
  page.is_text_visible = DM.is_text_visible
136
139
  page.is_exact_text_visible = DM.is_exact_text_visible
140
+ page.is_attribute_present = DM.is_attribute_present
137
141
  page.get_text = DM.get_text
138
142
  page.find_element = DM.find_element
139
143
  page.find_elements = DM.find_elements
140
144
  page.locator = DM.locator
145
+ page.get_page_source = DM.get_page_source
146
+ page.get_title = DM.get_title
141
147
  driver.page = page
142
148
  js = types.SimpleNamespace()
143
149
  js.js_click = DM.js_click
@@ -150,6 +156,8 @@ def extend_driver(driver):
150
156
  driver.open = DM.open_url
151
157
  driver.click = DM.click
152
158
  driver.click_link = DM.click_link
159
+ driver.click_if_visible = DM.click_if_visible
160
+ driver.click_active_element = DM.click_active_element
153
161
  driver.send_keys = DM.send_keys
154
162
  driver.press_keys = DM.press_keys
155
163
  driver.type = DM.update_text
@@ -168,6 +176,7 @@ def extend_driver(driver):
168
176
  driver.is_element_visible = DM.is_element_visible
169
177
  driver.is_text_visible = DM.is_text_visible
170
178
  driver.is_exact_text_visible = DM.is_exact_text_visible
179
+ driver.is_attribute_present = DM.is_attribute_present
171
180
  driver.get_text = DM.get_text
172
181
  driver.js_click = DM.js_click
173
182
  driver.get_active_element_css = DM.get_active_element_css
@@ -176,6 +185,10 @@ def extend_driver(driver):
176
185
  driver.get_user_agent = DM.get_user_agent
177
186
  driver.highlight = DM.highlight
178
187
  driver.sleep = time.sleep
188
+ driver.get_page_source = DM.get_page_source
189
+ driver.get_title = DM.get_title
190
+ if hasattr(driver, "proxy"):
191
+ driver.set_wire_proxy = DM.set_wire_proxy
179
192
  return driver
180
193
 
181
194
 
@@ -306,7 +319,15 @@ def has_cf(text):
306
319
  return False
307
320
 
308
321
 
309
- def uc_special_open_if_cf(driver, url, proxy_string=None):
322
+ def uc_special_open_if_cf(
323
+ driver,
324
+ url,
325
+ proxy_string=None,
326
+ mobile_emulator=None,
327
+ device_width=None,
328
+ device_height=None,
329
+ device_pixel_ratio=None,
330
+ ):
310
331
  if (
311
332
  url.startswith("http:") or url.startswith("https:")
312
333
  ):
@@ -332,6 +353,36 @@ def uc_special_open_if_cf(driver, url, proxy_string=None):
332
353
  driver.close()
333
354
  driver.switch_to.window(driver.window_handles[-1])
334
355
  time.sleep(0.02)
356
+ if mobile_emulator:
357
+ uc_metrics = {}
358
+ if (
359
+ type(device_width) is int
360
+ and type(device_height) is int
361
+ and type(device_pixel_ratio) is int
362
+ ):
363
+ uc_metrics["width"] = device_width
364
+ uc_metrics["height"] = device_height
365
+ uc_metrics["pixelRatio"] = device_pixel_ratio
366
+ else:
367
+ uc_metrics["width"] = constants.Mobile.WIDTH
368
+ uc_metrics["height"] = constants.Mobile.HEIGHT
369
+ uc_metrics["pixelRatio"] = constants.Mobile.RATIO
370
+ set_device_metrics_override = dict(
371
+ {
372
+ "width": uc_metrics["width"],
373
+ "height": uc_metrics["height"],
374
+ "deviceScaleFactor": uc_metrics["pixelRatio"],
375
+ "mobile": True
376
+ }
377
+ )
378
+ try:
379
+ driver.execute_cdp_cmd(
380
+ 'Emulation.setDeviceMetricsOverride',
381
+ set_device_metrics_override
382
+ )
383
+ except Exception:
384
+ pass
385
+ time.sleep(0.03)
335
386
  else:
336
387
  driver.default_get(url) # The original one
337
388
  else:
@@ -726,7 +777,7 @@ def _set_chrome_options(
726
777
  "excludeSwitches",
727
778
  ["enable-automation", "enable-logging", "enable-blink-features"],
728
779
  )
729
- if mobile_emulator:
780
+ if mobile_emulator and not is_using_uc(undetectable, browser_name):
730
781
  emulator_settings = {}
731
782
  device_metrics = {}
732
783
  if (
@@ -738,9 +789,9 @@ def _set_chrome_options(
738
789
  device_metrics["height"] = device_height
739
790
  device_metrics["pixelRatio"] = device_pixel_ratio
740
791
  else:
741
- device_metrics["width"] = 360
742
- device_metrics["height"] = 640
743
- device_metrics["pixelRatio"] = 2
792
+ device_metrics["width"] = constants.Mobile.WIDTH
793
+ device_metrics["height"] = constants.Mobile.HEIGHT
794
+ device_metrics["pixelRatio"] = constants.Mobile.RATIO
744
795
  emulator_settings["deviceMetrics"] = device_metrics
745
796
  if user_agent:
746
797
  emulator_settings["userAgent"] = user_agent
@@ -911,7 +962,8 @@ def _set_chrome_options(
911
962
  debug_port = service_utils.free_port()
912
963
  chrome_options.add_argument("--remote-debugging-port=%s" % debug_port)
913
964
  if swiftshader:
914
- chrome_options.add_argument("--use-gl=swiftshader")
965
+ chrome_options.add_argument("--use-gl=angle")
966
+ chrome_options.add_argument("--use-angle=swiftshader-webgl")
915
967
  elif not is_using_uc(undetectable, browser_name):
916
968
  chrome_options.add_argument("--disable-gpu")
917
969
  if not IS_LINUX and is_using_uc(undetectable, browser_name):
@@ -1265,8 +1317,8 @@ def get_driver(
1265
1317
  if (uc_cdp_events or uc_subprocess) and not undetectable:
1266
1318
  undetectable = True
1267
1319
  if is_using_uc(undetectable, browser_name) and mobile_emulator:
1268
- mobile_emulator = False
1269
- user_agent = None
1320
+ if not user_agent:
1321
+ user_agent = constants.Mobile.AGENT
1270
1322
  if page_load_strategy and page_load_strategy.lower() == "none":
1271
1323
  settings.PAGE_LOAD_STRATEGY = "none"
1272
1324
  proxy_auth = False
@@ -2345,7 +2397,7 @@ def get_local_driver(
2345
2397
  elif headless:
2346
2398
  if "--headless" not in edge_options.arguments:
2347
2399
  edge_options.add_argument("--headless")
2348
- if mobile_emulator:
2400
+ if mobile_emulator and not is_using_uc(undetectable, browser_name):
2349
2401
  emulator_settings = {}
2350
2402
  device_metrics = {}
2351
2403
  if (
@@ -2357,9 +2409,9 @@ def get_local_driver(
2357
2409
  device_metrics["height"] = device_height
2358
2410
  device_metrics["pixelRatio"] = device_pixel_ratio
2359
2411
  else:
2360
- device_metrics["width"] = 360
2361
- device_metrics["height"] = 640
2362
- device_metrics["pixelRatio"] = 2
2412
+ device_metrics["width"] = constants.Mobile.WIDTH
2413
+ device_metrics["height"] = constants.Mobile.HEIGHT
2414
+ device_metrics["pixelRatio"] = constants.Mobile.RATIO
2363
2415
  emulator_settings["deviceMetrics"] = device_metrics
2364
2416
  if user_agent:
2365
2417
  emulator_settings["userAgent"] = user_agent
@@ -2493,7 +2545,8 @@ def get_local_driver(
2493
2545
  free_port = service_utils.free_port()
2494
2546
  edge_options.add_argument("--remote-debugging-port=%s" % free_port)
2495
2547
  if swiftshader:
2496
- edge_options.add_argument("--use-gl=swiftshader")
2548
+ edge_options.add_argument("--use-gl=angle")
2549
+ edge_options.add_argument("--use-angle=swiftshader-webgl")
2497
2550
  else:
2498
2551
  edge_options.add_argument("--disable-gpu")
2499
2552
  if IS_LINUX:
@@ -3401,7 +3454,13 @@ def get_local_driver(
3401
3454
  driver.default_get = driver.get # Save copy of original
3402
3455
  if uc_activated:
3403
3456
  driver.get = lambda url: uc_special_open_if_cf(
3404
- driver, url, proxy_string
3457
+ driver,
3458
+ url,
3459
+ proxy_string,
3460
+ mobile_emulator,
3461
+ device_width,
3462
+ device_height,
3463
+ device_pixel_ratio,
3405
3464
  )
3406
3465
  driver.uc_open = lambda url: uc_open(driver, url)
3407
3466
  driver.uc_open_with_tab = (
@@ -3410,6 +3469,35 @@ def get_local_driver(
3410
3469
  driver.uc_open_with_reconnect = (
3411
3470
  lambda url: uc_open_with_reconnect(driver, url)
3412
3471
  )
3472
+ if mobile_emulator:
3473
+ uc_metrics = {}
3474
+ if (
3475
+ type(device_width) is int
3476
+ and type(device_height) is int
3477
+ and type(device_pixel_ratio) is int
3478
+ ):
3479
+ uc_metrics["width"] = device_width
3480
+ uc_metrics["height"] = device_height
3481
+ uc_metrics["pixelRatio"] = device_pixel_ratio
3482
+ else:
3483
+ uc_metrics["width"] = constants.Mobile.WIDTH
3484
+ uc_metrics["height"] = constants.Mobile.HEIGHT
3485
+ uc_metrics["pixelRatio"] = constants.Mobile.RATIO
3486
+ set_device_metrics_override = dict(
3487
+ {
3488
+ "width": uc_metrics["width"],
3489
+ "height": uc_metrics["height"],
3490
+ "deviceScaleFactor": uc_metrics["pixelRatio"],
3491
+ "mobile": True
3492
+ }
3493
+ )
3494
+ try:
3495
+ driver.execute_cdp_cmd(
3496
+ 'Emulation.setDeviceMetricsOverride',
3497
+ set_device_metrics_override
3498
+ )
3499
+ except Exception:
3500
+ pass
3413
3501
  return extend_driver(driver)
3414
3502
  else: # Running headless on Linux (and not using --uc)
3415
3503
  try:
@@ -41,6 +41,12 @@ class DriverMethods():
41
41
  pass
42
42
  raise Exception('No such Element: {%s} (by="%s")!' % (selector, by))
43
43
 
44
+ def get_page_source(self):
45
+ return self.driver.page_source
46
+
47
+ def get_title(self):
48
+ return self.driver.title
49
+
44
50
  def open_url(self, *args, **kwargs):
45
51
  page_actions.open_url(self.driver, *args, **kwargs)
46
52
 
@@ -50,6 +56,12 @@ class DriverMethods():
50
56
  def click_link(self, *args, **kwargs):
51
57
  page_actions.click_link(self.driver, *args, **kwargs)
52
58
 
59
+ def click_if_visible(self, *args, **kwargs):
60
+ page_actions.click_if_visible(self.driver, *args, **kwargs)
61
+
62
+ def click_active_element(self, *args, **kwargs):
63
+ page_actions.click_active_element(self.driver, *args, **kwargs)
64
+
53
65
  def send_keys(self, *args, **kwargs):
54
66
  page_actions.send_keys(self.driver, *args, **kwargs)
55
67
 
@@ -114,6 +126,9 @@ class DriverMethods():
114
126
  def js_click(self, *args, **kwargs):
115
127
  return page_actions.js_click(self.driver, *args, **kwargs)
116
128
 
129
+ def is_attribute_present(self, *args, **kwargs):
130
+ return page_actions.has_attribute(self.driver, *args, **kwargs)
131
+
117
132
  def get_active_element_css(self, *args, **kwargs):
118
133
  return js_utils.get_active_element_css(self.driver, *args, **kwargs)
119
134
 
@@ -128,3 +143,26 @@ class DriverMethods():
128
143
 
129
144
  def highlight(self, *args, **kwargs):
130
145
  js_utils.highlight(self.driver, *args, **kwargs)
146
+
147
+ def set_wire_proxy(self, string):
148
+ """Set a proxy server for selenium-wire mode ("--wire")
149
+ Examples: (ONLY avilable if using selenium-wire mode!)
150
+ driver.set_wire_proxy("SERVER:PORT")
151
+ driver.set_wire_proxy("socks5://SERVER:PORT")
152
+ driver.set_wire_proxy("USERNAME:PASSWORD@SERVER:PORT")
153
+ """
154
+ the_http = "http"
155
+ the_https = "https"
156
+ if string.startswith("socks4://"):
157
+ the_http = "socks4"
158
+ the_https = "socks4"
159
+ elif string.startswith("socks5://"):
160
+ the_http = "socks5"
161
+ the_https = "socks5"
162
+ string = string.split("//")[-1]
163
+ if hasattr(self.driver, "proxy"):
164
+ self.driver.proxy = {
165
+ "http": "%s://%s" % (the_http, string),
166
+ "https": "%s://%s" % (the_https, string),
167
+ "no_proxy": "localhost,127.0.0.1",
168
+ }