0

I am creating automated tests with Python's unittest, Selenium and PhantomJS. I will have them running by Jenkins. So the list of urls could be added to Jenkins.

I found that pytest can have tests getting urls from command line, as shown on https://www.blazemeter.com/blog/how-automate-testing-using-selenium-webdriver-jenkins-and-allure.

However, I am using unittest framework. The main reason of doing that is that I would be testing on menus, headers and footers on 500 web pages.

So, how can I get the urls from command line and then to put them in self.driver.get('urls_from_command_line')?

2 Answers2

0

It depends of your configuration and code you already done for sure. But for example some ideas how to do it:

  • Store your URLs to some place (text file?) and parse the file from your unittest.
  • Use Jenkins Parameterized job to invoke your python script with URL as parameter.

You can read about Python command line parameters at here
And Jenkins Parameterized build at here

kyxap
  • 516
  • 6
  • 20
0

I use pytest and I have my conftest.py file and a config.py setup so that we can easily set URLs for each test as needed.

However, it looks like your question was answered within How to use a command line argument in unittest?

Basically, you set a base URL and include an argument to include a provided URL.

Wunderbread
  • 898
  • 2
  • 14
  • 34