Reputation: 188
I am needing to find a way to update my URL in my python file used for python testing. Every time a new build is released the URL increments, i.e. build1.test.com, build2.test.com.
Is there a way to automatically update this URL to increment up when the new build is released?
import unittest
from page import *
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
class LoginTest(unittest.TestCase):
def setUp(self):
self.driver = webdriver.chrome()
self.driver.get("https://build10.test.com")
Upvotes: 0
Views: 179
Reputation: 1119
You can do this by having your test methods read the build information from an external file. I have test information in json files which are read and are passed into each test when they are run.
import json
with open('../test data/testdata.json) as data_file
json_contents = json.load(data_file)
and your json file could be something like this:
{
"Latest Build": "build10"
}
You read in this information and use that to construct your URL for the test.
build_number = json_contents["Latest Build"]
build_url = "https://%s.test.com" % build_number
self.driver.get(build_url)
You could possibly write a script to update this file with the latest build info, but that would depend on what you have access to.
Upvotes: 1