-1

im trying to define IE web driver to work with python and i have some errors that i cant undetrstand. maby i have to change some security setting at internet explorer ? i have interent explorer version 11 thank you .

from selenium import webdriver

driver = webdriver.Ie(executable_path=r"C:\Users\cohe\PycharmProjects\Testing\IEDriverServer.exe")

i got some errors:

Traceback (most recent call last):
  File "C:/Users/cohe/PycharmProjects/Testing/Shrepoint.py", line 3, in <module>
    driver = webdriver.Ie(executable_path=r"C:\Users\cohe\PycharmProjects\Testing\IEDriverServer.exe")
  File "C:\Users\cohe\AppData\Roaming\Python\Python38\site-packages\selenium\webdriver\ie\webdriver.py", line 54, in __init__
    warnings.warn('executable_path has been deprecated, please pass in a Service object',
NameError: name 'warnings' is not defined

Note: I'm using selenium 4.0.0a1

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • Does this answer your question? [Python Selenium 4 - Firefox FirefoxBinary() Deprecated](https://stackoverflow.com/questions/58296262/python-selenium-4-firefox-firefoxbinary-deprecated) – Challe Aug 25 '20 at 06:59

2 Answers2

0

It's not that clear which version of Selenium clients you are using. However, the latest stable version of Selenium Python client is v3.141.0.

SeleniumPythonAlpha

So for production environment instead of Selenium 4.0.0a1 you need to use Selenium 3.141.0

Additionally, as you are using the raw switch i.e. r, instead of the double quotes, you need to use the single quotes. Effectively your line of code will be:

driver = webdriver.Ie(executable_path=r'C:\Users\cohe\PycharmProjects\Testing\IEDriverServer.exe')
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
0

What version of selenium are you using?

If you have a look at the python selenium bindings here:

You can see 2 key parts:

 - executable_path - Deprecated: path to the executable. If the default is used it assumes the executable is in the $PATH

and

if executable_path != 'IEDriverServer.exe':
            warnings.warn('executable_path has been deprecated, please pass in a Service object',
                          DeprecationWarning, stacklevel=2)

These were removed in the selenium 4 alpha 1 bindings.

Your First, and best option:

Assuming you have the latest v4 selenium - This is in alpha testing and is subject to further and frequent change. Unless you need a cutting edge feature you might want to roll back your version to the latest stable. That should allow the executable path again.

Next options: The error/warning is only thrown If you try and specify the path. The clue is in your error:

'executable_path has been deprecated, please pass in a Service object'

Therefore, don't specify it :-)

You can try:

  1. Add your IeDriverSerice.exe location to PATH variable.
  2. Place the IeDriverService.exe file in the same location as the script. Then you do not have to specify it and can leave it as default
  3. Create a service object and see if that accepts the binary path.
RichEdwards
  • 3,423
  • 2
  • 6
  • 22
  • im using selenium 4.0.0a1 and i cant understand where can i find IEdriver for this version of selenium . do you know where can i find it ? thank you ! – ניב בדלי Aug 26 '20 at 13:05
  • @ניבבדלי If you're working with python use pip install selenium. And get your ie driver from the selenium website https://www.selenium.dev/downloads/ – RichEdwards Aug 26 '20 at 18:24
  • @RichEdwards Do visit [Selenium Chat Room](https://chat.stackoverflow.com/rooms/223360/selenium) and help other users. – undetected Selenium Oct 20 '20 at 18:44