0

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")

1 Answer 1

1

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.

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

1 Comment

This seems like a great solution, I'll get back to you once I get it set up!

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.