Cronax Cronax - 3 months ago 15x
Python Question

Selenium Python webdriver: driver.get() won't accept a variable?

I'm trying to write an automated test script that will perform a set of actions for multiple URL's. The reason I am trying to do this is because I am testing a web application with multiple front-end interfaces that are functionally exactly the same, so if I can use a single test script to run through all of them and make sure the basics are in order, this saves me a lot of time in regression testing when the codebase changes.

My current code is as follows:

# initialize the unittest framework
import unittest
# initialize the selenium framework and grab the toolbox for keyboard output
from selenium import selenium, webdriver
# prepare for the usage of remote browsers
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities

class Clubmodule(unittest.TestCase):
def setUp(self):
# load up the remote driver and tell it to use Firefox
self.driver = webdriver.Remote(

def test_010_LoginAdmin(self):
driver = self.driver
# prepare the URL by loading the list from a textfile
with open('urllist.txt', 'r') as f:
urllist = [line.strip() for line in f]
# Go to the /admin url
for url in urllist:
# create the testurl
testurl = str(url) + str("/admin")
# go to the testurl
driver.get("%s" %testurl)
# log in using the admin credentials

def tearDown(self):
# close the browser

# make it so!
if __name__ == "__main__":

When I print the variable
I get the correct function, but when I try to run my script with Python it does not seem to convert
driver.get("%s" %testurl)

I'm hoping it's a syntax issue but after trying all the variations I can come up with I'm starting to thing this is a limitation of Webdriver. Can this be done at all ?


How about


I do not think string interpolation is required.