简体   繁体   中英

Selenium with python bindings launches Firefox but not Explorer and Chrome browsers

I want to launch Internet Explorer (8) browser on Windows XP SP3 using selenium. I coded these lines:

from selenium import webdriver
class InternetExplorer8:
    def ie8(self):
        self.browser=webdriver.Ie()
        self.browser.get("http://www.begueradj.com")
if __name__=='__main__':
    IE=InternetExplorer8()
    IE.ie8()

I got this error:

self.iedriver.start() File "C:\\Python34\\lib\\site-packages\\selenium\\webdriver\\ie\\service.py", line 73, in start and read up at http://code.google.com/p/selenium/wiki/InternetExplorerDriver ") selenium.common.exceptions.WebDriverException: Message: 'IEDriver executable needs to be available in the path. Please download from http://selenium-release.storage.googleapis.com/index.html and read up at http://code.google.com/p/selenium/wiki/InternetExplorerDriver

Note that I launch firefox without any problem using the same code, except internet explorer and crhome (that outputs a similar error). How could I resolve this problem ?

You need to download Internet Explorer driver and place the path to it into PATH environment variable.

Or, alternatively, provide an executable_path argument to webdriver.Ie() :

self.browser = webdriver.Ie(executable_path='path\to\iedriver\driver.exe')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM