I am trying to access clientId and csv inside method but it is not accessible.
import argparse
import csv
import re
import sys
import unittest
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
ABC_CDN_URL = 'http[s]?://xyz.abc.com/%s/tracker.js$'
class Abc(unittest.TestCase):
def setUp(self):
self.driver = webdriver.Firefox()
self.chuknuURLRegex = re.compile(ABC_CDN_URL % (17420))
def checkForAbc(self, nargs):
driver = self.driver
with open('/home/Downloads/Website_Url.csv', 'rb') as f:
reader = csv.reader(f)
index = 0
for url in reader:
if index == 0:
index += 1
continue
driver.get(url[0])
driver.implicitly_wait(10) # seconds
elems = driver.find_elements_by_tag_name('script')
isPresent = False;
for elem in elems:
elemSrc = elem.get_attribute('src')
if self.chuknuURLRegex.match(elemSrc):
isPresent = True;
print url[0], "pass"
break
if isPresent == False:
print url[0], 'fail'
def tearDown(self):
self.driver.close()
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument('--clientId', default='')
parser.add_argument('--csv', default='')
parser.add_argument('unittest_args', nargs='*')
args = parser.parse_args()
sys.argv[1:] = args.unittest_args
unittest.main()
python Abc.py Abc.checkForAbc --clientId=0 --csv=990
How do I access clientId and csv argument inside my checkForAbc method while executing unit test
Aucun commentaire:
Enregistrer un commentaire