Anthony Kong
Anthony Kong

Reputation: 40624

Selenium: Why the css selector fails in IE10 but not in firefox or chrome?

from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC


wait = WebDriverWait(webdriver, 10)
elem = self.wait.until(EC.visibility_of_element_located(
            (By.CSS_SELECTOR, '.top_layer.active-element')))

The above code works perfectly in FF or Chrome. However when I target IE, I get this error message:

 Unable to find element with css selector == .top_layer.active-element (WARNING: The 
 server did not provide any stacktrace information) Command duration or timeout:  
316 milliseconds For documentation on this error, please visit:  
http://seleniumhq.org/exceptions/no_such_element.html Build info: version:  
'2.43.1', revision: '5163bce', time: '2014-09-10 16:27:33' System info: host: 
 '172-16-4-157', ip: '172.16.4.157', os.name: 'windows', os.arch: 'x86',  
os.version: '6.2', java.version: '1.8.0_40' Driver info:  
org.openqa.selenium.ie.InternetExplorerDriver

How can I make the css selector works on IE10 too?

Upvotes: 2

Views: 692

Answers (1)

Saifur
Saifur

Reputation: 16201

Try by disabling the nativeEvents of ie driver. See the full list of IE capabilities here

self.profile = webdriver.DesiredCapabilities.INTERNETEXPLORER
self.profile['nativeEvents'] = False
self.driver = webdriver.Ie(self.profile)

Upvotes: 2

Related Questions