@@ -138,7 +138,8 @@ def start_session(self, desired_capabilities, browser_profile=None):
138
138
self .session_id = response ['sessionId' ]
139
139
self .capabilities = response ['value' ]
140
140
141
- self .capabilities ["w3c" ] = desired_capabilities .get ("marionette" , False )
141
+ # Quick check to see if we have a W3C Compliant browser
142
+ self .w3c = "takesElementScreenshot" in self .capabilities
142
143
143
144
def _wrap_value (self , value ):
144
145
if isinstance (value , dict ):
@@ -157,7 +158,7 @@ def create_web_element(self, element_id):
157
158
"""
158
159
Creates a web element with the specified element_id.
159
160
"""
160
- return WebElement (self , element_id , w3c = self .capabilities [ ' w3c' ] )
161
+ return WebElement (self , element_id , w3c = self .w3c )
161
162
162
163
def _unwrap_value (self , value ):
163
164
if isinstance (value , dict ) and ('ELEMENT' in value or 'element-6066-11e4-a52e-4f735466cecf' in value ):
@@ -503,7 +504,7 @@ def maximize_window(self):
503
504
Maximizes the current window that webdriver is using
504
505
"""
505
506
command = Command .MAXIMIZE_WINDOW
506
- if self .capabilities [ ' w3c' ] == True :
507
+ if self .w3c :
507
508
command = Command .W3C_MAXIMIZE_WINDOW
508
509
self .execute (command , {"windowHandle" : "current" })
509
510
@@ -641,7 +642,7 @@ def implicitly_wait(self, time_to_wait):
641
642
:Usage:
642
643
driver.implicitly_wait(30)
643
644
"""
644
- if self .capabilities [ " w3c" ] == True :
645
+ if self .w3c :
645
646
self .execute (Command .SET_TIMEOUTS ,
646
647
{'ms' : float (time_to_wait ) * 1000 , 'type' :'implicit' })
647
648
else :
@@ -658,7 +659,7 @@ def set_script_timeout(self, time_to_wait):
658
659
:Usage:
659
660
driver.set_script_timeout(30)
660
661
"""
661
- if self .capabilities [ " w3c" ] == True :
662
+ if self .w3c :
662
663
self .execute (Command .SET_TIMEOUTS ,
663
664
{'ms' : float (time_to_wait ) * 1000 , 'type' :'script' })
664
665
else :
@@ -690,7 +691,7 @@ def find_element(self, by=By.ID, value=None):
690
691
"""
691
692
if not By .is_valid (by ) or not isinstance (value , str ):
692
693
raise InvalidSelectorException ("Invalid locator values passed in" )
693
- if self .capabilities [ ' w3c' ] == True :
694
+ if self .w3c :
694
695
if by == By .ID :
695
696
by = By .CSS_SELECTOR
696
697
value = '[id="%s"]' % value
@@ -716,7 +717,7 @@ def find_elements(self, by=By.ID, value=None):
716
717
"""
717
718
if not By .is_valid (by ) or not isinstance (value , str ):
718
719
raise InvalidSelectorException ("Invalid locator values passed in" )
719
- if self .capabilities [ ' w3c' ] == True :
720
+ if self .w3c :
720
721
if by == By .ID :
721
722
by = By .CSS_SELECTOR
722
723
value = '[id="%s"]' % value
@@ -792,7 +793,7 @@ def set_window_size(self, width, height, windowHandle='current'):
792
793
driver.set_window_size(800,600)
793
794
"""
794
795
command = Command .SET_WINDOW_SIZE
795
- if self .capabilities [ " w3c" ] == True :
796
+ if self .w3c :
796
797
command = Command .W3C_SET_WINDOW_SIZE
797
798
self .execute (command , {'width' : int (width ), 'height' : int (height ),
798
799
'windowHandle' : windowHandle })
@@ -805,7 +806,7 @@ def get_window_size(self, windowHandle='current'):
805
806
driver.get_window_size()
806
807
"""
807
808
command = Command .GET_WINDOW_SIZE
808
- if self .capabilities [ ' w3c' ] == True :
809
+ if self .w3c :
809
810
command = Command .W3C_GET_WINDOW_SIZE
810
811
size = self .execute (command ,
811
812
{'windowHandle' : windowHandle })
0 commit comments