@@ -27,17 +27,17 @@ class WebDriver(RemoteWebDriver):
2727 FIREFOX = "FIREFOX"
2828
2929 def __init__ (
30- self ,
31- load_images = True ,
32- user_agent = None ,
33- proxy = None ,
34- headless = False ,
35- driver_type = PHANTOMJS ,
36- timeout = 16 ,
37- window_size = (1024 , 800 ),
38- executable_path = None ,
39- custom_argument = None ,
40- ** kwargs
30+ self ,
31+ load_images = True ,
32+ user_agent = None ,
33+ proxy = None ,
34+ headless = False ,
35+ driver_type = PHANTOMJS ,
36+ timeout = 16 ,
37+ window_size = (1024 , 800 ),
38+ executable_path = None ,
39+ custom_argument = None ,
40+ ** kwargs
4141 ):
4242 """
4343 webdirver 封装,支持chrome、phantomjs 和 firefox
@@ -59,7 +59,7 @@ def __init__(
5959 self ._timeout = timeout
6060 self ._window_size = window_size
6161 self ._executable_path = executable_path
62- self .custom_argument = custom_argument
62+ self ._custom_argument = custom_argument
6363
6464 self .proxies = {}
6565 self .user_agent = None
@@ -126,6 +126,11 @@ def firefox_driver(self):
126126 firefox_options .add_argument ("--headless" )
127127 firefox_options .add_argument ("--disable-gpu" )
128128
129+ # 添加自定义的配置参数
130+ if self ._custom_argument :
131+ for arg in self ._custom_argument :
132+ firefox_options .add_argument (arg )
133+
129134 if self ._executable_path :
130135 driver = webdriver .Firefox (
131136 capabilities = firefox_capabilities ,
@@ -178,9 +183,10 @@ def chrome_driver(self):
178183 chrome_options .add_argument (
179184 "--window-size={},{}" .format (self ._window_size [0 ], self ._window_size [1 ])
180185 )
186+
181187 # 添加自定义的配置参数
182- if self .custom_argument :
183- for arg in self .custom_argument :
188+ if self ._custom_argument :
189+ for arg in self ._custom_argument :
184190 chrome_options .add_argument (arg )
185191
186192 if self ._executable_path :
@@ -221,9 +227,10 @@ def phantomjs_driver(self):
221227 )
222228 if not self ._load_images :
223229 service_args .append ("--load-images=no" )
230+
224231 # 添加自定义的配置参数
225- if self .custom_argument :
226- for arg in self .custom_argument :
232+ if self ._custom_argument :
233+ for arg in self ._custom_argument :
227234 service_args .append (arg )
228235
229236 if self ._executable_path :
0 commit comments