I have a selenium python automation test where i want to pass url of website as a parameter to function. I will be calling the function via command line.
my_python_code.py
class my_automation_class(unittest.TestCase)
def setUp(self):
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument("--headless")
chrome_options.add_argument("--disable-gpu")
self.driver = webdriver.Chrome(ChromeDriverManager().install())
parser = argparse.ArgumentParser()
parser.add_argument("url_link", help="display url")
self.args = parser.parse_args()
def test_my_automation(self):
driver = self.driver
driver.maximize_window()
driver.get(self.args.url_link)
//performs some operation after this
if __name__ == "__main__":
unittest.main(testRunner=HTMLTestRunner(output='Reports'),exit=False)
When I ran this via command line
python my_python_code.py "https://www.netflix.com/in/ "
I am getting
ERROR [0.000000s]: unittest.loader._FailedTest.https://www
AttributeError: module 'main' has no attribute 'https://www'
I am not sure why it's not working. Is there any other way i can pass arguments to selenium python test case ?
python my_python_code.py --url_link="https://www.netflix.com/in/ "