Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

commit dfab927 contains a reference to basestring, which is not in Python 3 #1820

Closed
madeleineth opened this issue Mar 16, 2016 · 5 comments
Closed

Comments

@madeleineth
Copy link

OS: Ubuntu 14.04
Selenium Version: 2.53.0
Browser: Firefox
Browser Version: 45.0+build2-0ubuntu0.14.04.1

It looks like commit dfab927 introduced a reference to basestring, which does not exist in Python 3.4.3.

With Dockerfile:

FROM ubuntu:trusty
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update -qq
RUN apt-get install -qq build-essential python3-pip
RUN apt-get install -qq firefox
RUN pip3 install -U selenium
RUN pip3 list
COPY repro.py /seleniumtest/
CMD /seleniumtest/repro.py

And this repro.py mode 755:

#!/usr/bin/python3
from selenium import webdriver
webdriver.Firefox()

Run:

docker build -t repro .
docker run -t -i  repro

And see:

Traceback (most recent call last):
  File "/seleniumtest/repro.py", line 3, in <module>
    webdriver.Firefox()
  File "/usr/local/lib/python3.4/dist-packages/selenium/webdriver/firefox/webdriver.py", line 62, in __init__
    firefox_options.binary_location = self.binary if isinstance(self.binary, basestring) else self.binary._get_firefox_start_cmd()
NameError: name 'basestring' is not defined

...which wasn't happening yesterday, before the release of 2.53.0.

@dosyoyas
Copy link

Confirmed also in Linux Mint 17, python 3.4.3, selenium 2.53.0

@timgraham
Copy link

Looks like other files that use basestring have this at the top:

try:
    basestring
except NameError:  # Python 3.x
    basestring = str

@leviable
Copy link

I've created a PR to fix this issue, however the CI checks are failing for other reasons.

@madeleineth
Copy link
Author

FYI: If you want to test whether something is one of bytes or unicode in a way that works cleanly in both Python 2 and 3, use isinstance(..., six.string_types).

@madeleineth
Copy link
Author

I confirmed that my tests are passing now with Selenium 2.53.1.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants