4

Using Selenium 3.0.2 with python 3.5.1 and firefox 52, the following selenium code throws the error:

AttributeError: 'WebDriver' object has no attribute 'getCurrentUrl'

Any thoughts on why this is happening or what to use instead of getCurrentUrl?

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import Select
from selenium.common.exceptions import NoSuchElementException
from selenium.common.exceptions import NoAlertPresentException
from selenium.webdriver.firefox.firefox_binary import FirefoxBinary
import unittest, time, re

class TestURL(unittest.TestCase):
    def setUp(self):
        capabilities = DesiredCapabilities.FIREFOX.copy()
        capabilities.update({'acceptInsecureCerts': True})
        binary = FirefoxBinary('/var/lib/firefox/firefox')
        profile = webdriver.FirefoxProfile()
        profile.accept_untrusted_certs = True
        self.driver = webdriver.Firefox(firefox_binary=binary,firefox_profile=profile, capabilities=capabilities)
        self.driver.implicitly_wait(30)
        self.base_url = "http://www.python.org"
        self.verificationErrors = []

    def test_load(self):
        driver = self.driver
        driver.get(self.base_url)
        url = driver.getCurrentUrl()
        try: self.assertEqual("http://www.python.org", url)
        except AssertionError as e: self.verificationErrors.append(str(e))

def tearDown(self):
        self.driver.quit()
        self.assertEqual([], self.verificationErrors)

if __name__ == "__main__":
    unittest.main()

Error:

E
======================================================================
ERROR: test_load (__main__.TestURL)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "test.py", line 26, in test_load
    url = driver.getCurrentUrl()
AttributeError: 'WebDriver' object has no attribute 'getCurrentUrl'

----------------------------------------------------------------------
Ran 1 test in 10.202s

FAILED (errors=1)
Denise Mauldin
  • 5,397
  • 5
  • 32
  • 51
  • @mrfreester Totally is! Somehow I didn't find that SO in searching. Should I leave this up or delete it? – Denise Mauldin Feb 28 '17 at 22:43
  • That's a good question! If you start getting some down votes you might want to delete it, but otherwise [It serves as a sign post for others](http://meta.stackoverflow.com/a/265737/1183506) so I would just leave it there. – mrfreester Mar 01 '17 at 15:27

0 Answers0