Chris
Chris

Reputation: 121

Python Selenium Having to Change URL Variable On All of My Test Cases

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.

Upvotes: 0

Views: 1618

Answers (2)

David Lai
David Lai

Reputation: 822

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...

Upvotes: 1

nvldk
nvldk

Reputation: 125

You should consider migrate your test to Page Object model.

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

Upvotes: 2

Related Questions