Answer the question
In order to leave comments, you need to log in
How to set up an argument for a different URL value when testing on different environments?
There is a specific smoke test script that runs every day.
You need to set different arguments to test this script on different environments
. Also, on some environments, the password will change
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time
from selenium.webdriver.support.ui import Select
driver = webdriver.Chrome("C:\File_Path")
base_url = localUrl
driver.get(base_url)
driver.maximize_window()
username = driver.find_element_by_id("Username")
password = driver.find_element_by_id("Password")
username.send_keys("username")
password.send_keys("pass")
driver.find_element_by_name("Login").click()
Answer the question
In order to leave comments, you need to log in
If you need a settings file, then you can add the following function:
def load_config(path):
config_path = os.path.join(path, 'config.json')
if not os.path.exists(config_path):
print('Not found config.json in {}'.format(path))
return
with open(config_path, 'r') as fp:
config = json.load(fp)
return config
import os
script_path = os.path.dirname(os.path.abspath(__file__))
config = load_config(script_path)
{
"localUrl": "local.com",
"developmentUrl": "development.com"
"productionUrl": "production.com"
}
driver.get(config['localUrl'])
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question