Selenium py3.8+ DepreciationWarnings - where to find doc to update code?

dn PythonList at DancesWithMice.info
Sat Oct 16 16:21:34 EDT 2021


The issues illustrated likely have less to do with Python than with
Selenium (or even Firefox - depending how far back we need to go).

That and our fate with the many web-search engines prioritising
'authoritative sources' in their results. Such definition includes
'clicks' over time. It fails to distinguish (in our case) that software
is improved/changes over time, and 'the old stuff' amongst the plethora
of web-pages becomes 'wrong'.

Plea: every web page should be dated, and all software-related
publications include version numbers (just as your posts do here. Well
done!)


On 17/10/2021 05.02, Akkana Peck wrote:
> jkk writes:
>> Selenium 3.141+
>> python 3.8+
>> ubuntu 20.04 or windows 10
>> I'm trying to upgrade code from py3.6+ to py3.8+ and I'm getting several DepreciationWarnings.
>> Can someone point me to where I can find the documentation that explains how to to remedy these warnings. What are the new preferred coding practices?
> I've also been looking for that (Selenium 4.0.0a1, Python 3.9.5,
> Ubuntu 21.04). For instance:
> 
>>>> from selenium import webdriver
>>>> profiledir = "/path/to/profile/dir"
>>>> driver = webdriver.Firefox(firefox_profile=profiledir)
> <stdin>:1: DeprecationWarning: firefox_profile has been deprecated, please pass in a Service object
> 
> What is a Service object and how do you use it to pass in profiles?
> I've found API references like
> https://www.selenium.dev/selenium/docs/api/rb/Selenium/WebDriver/Service.html
> https://selenium-python.readthedocs.io/api.html#module-selenium.webdriver.common.service
> but how do you create one, or use it to reference a specific profile?
> I haven't been able to find any examples. 

Some of the confusion may have been caused by the fact that there are
several 'moving parts', and all have had version upgrades but must still
'play nicely together'.

Secondly, when we use 'alpha' or other pre-release versions of software,
it is referred-to as "the bleeding edge" for good reason! In this case,
a scan of the repo's history will elicit a groan
(https://github.com/SeleniumHQ/selenium/blob/trunk/py/CHANGES)

Way forward/check list:
- upgrade to the *released* (4.0.0) version of Selenium
- upgrade Python (likely already done)
- upgrade Python-binding (https://pypi.org/project/selenium/4.0.0/)
- ensure Firefox/Gecko-engine is compatible (?v48+ which happened long,
long, ago!)

Some of the question(s) may be answered under "Firefox Legacy"
(https://www.selenium.dev/documentation/getting_started/how_to_upgrade_to_selenium_4/).
However, going backwards is an awkward way to make progress!

The 'new' method of setting a Custom Profile can be found in the docs
(https://www.selenium.dev/documentation/webdriver/capabilities/driver_specific_capabilities/#setting-a-custom-profile)
NB don't know when they were actually released but see "Last modified"
date, and don't feel too bad!

If you're interested in getting down-and-dirty with the API, there are
new classes/methods.
(https://www.selenium.dev/selenium/docs/api/py/api.html#webdriver-firefox)

Finally, (Warning: un-read, so un-tested) I recalled that my 'reading
pile' includes "How to Create Firefox Profile in Selenium WebDriver"
(https://www.guru99.com/firefox-profile-selenium-webdriver.html) which
*may* offer hints about the 'new' handling of FF profiles. Again, YMMV!
-- 
Regards,
=dn


More information about the Python-list mailing list