8
8
from selenium .webdriver import Edge , EdgeOptions # noqa: F401, F403
9
9
from selenium .webdriver .edge .service import Service as EdgeService # noqa: F401, F403
10
10
11
+ from ..util import is_admin
12
+
11
13
12
14
def default_options (headless = False , download_folder_path = None , user_data_dir = None ,
13
15
page_load_strategy = "normal" , binary_path : str = None ) -> EdgeOptions :
@@ -48,10 +50,16 @@ def default_options(headless=False, download_folder_path=None, user_data_dir=Non
48
50
edge_options .add_argument ("--disable-features=msSmartScreenProtection" )
49
51
edge_options .add_argument ("--disable-blink-features=AutomationControlled" )
50
52
51
- # Disable banner for Browser being remote-controlled
52
- edge_options .add_experimental_option ("excludeSwitches" , ["enable-automation" ])
53
53
edge_options .add_experimental_option ('useAutomationExtension' , False )
54
54
55
+ # Check if user is root
56
+ if is_admin ():
57
+ if os .name == "posix" :
58
+ edge_options .add_argument ("--no-sandbox" )
59
+ else :
60
+ # Disable banner for Browser being remote-controlled
61
+ edge_options .add_experimental_option ("excludeSwitches" , ["enable-automation" ])
62
+
55
63
if headless :
56
64
edge_options .add_argument ("--headless" )
57
65
edge_options .add_argument ("--headless=new" )
@@ -60,14 +68,6 @@ def default_options(headless=False, download_folder_path=None, user_data_dir=Non
60
68
edge_options .add_argument ("--hide-scrollbars" )
61
69
edge_options .add_argument ("--mute-audio" )
62
70
63
- # Check if user is root
64
- try :
65
- # This is only valid with Unix
66
- if os .geteuid () == 0 :
67
- edge_options .add_argument ("--no-sandbox" )
68
- except AttributeError :
69
- pass
70
-
71
71
edge_options ._botcity_temp_dir = None
72
72
if not user_data_dir :
73
73
temp_dir = tempfile .TemporaryDirectory (prefix = "botcity_" )
0 commit comments