0

I have 10+ test cases at the moment and planning on creating several more. That being said is there a way that I can modify the URL variable once and that would change the variable in all my other scripts? I have this in all my of test scripts:

class TestCase1(unittest.TestCase): def setUp(self): self.driver = webdriver.Firefox() self.driver.implicitly_wait(30) self.base_url = "http://URL" self.verificationErrors = [] self.accept_next_alert = True I want to be able to be able to modify self.base_url = http://URL. But I don't want to have to do that 10+ times.

1
  • 1
    In Java, we use a .properties file and read URL from there. Or make all tests inherit from a Super class and define commonly shared data in your Super Class. Commented Nov 12, 2015 at 19:28

2 Answers 2

2

You should consider migrate your test to Page Object model.

http://selenium-python.readthedocs.org/page-objects.html

Sign up to request clarification or add additional context in comments.

Comments

1

There are 2 good approaches to doing this,

1) Using a Configuration Manager, a singleton object that stores all your settings.

2) Using a basetest, a single base test that all your tests inherit from.

My preference is towards a Configuration Manager. And within that configuration manager, you can put your logic for grabbing the base url form configuration files, system environments, command line params, etc...

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.