Python: Using argparse to pass arguments into python script

Programming, Technology

Artikel ini juga tersedia dalam terjemahan Bahasa indonesia dengan judul Memakai argparse untuk memberikan argumen pada skrip python.

While doing some QA tasks, I got a case which I need to add and delete domain names from hundreds of categorized text files time after time.

Since it was repetitive and cost me time to perform it, I decided to create python script for automating that case.

Inspired by simplicity of linux command: ls which has several arguments with distinct functionalities, I also want my python script to be able to run multiple functions.

To accommodate that, I need to separate the input arguments.

After doing internet research, I found argparse solving this issue. With argparse library, user can pass arguments into python script.

Let’s write this argparse script.

Selenium: Resolving chrome error / throwing exception on python selenium

Operating System, Programming, Technology


while running a selenium script, always throwing exception like :

File "C:\Python27\lib\site-packages\selenium\webdriver\chrome\", line 67, in __init__
File "C:\Python27\lib\site-packages\selenium\webdriver\remote\", line 87, in __init__
self.start_session(desired_capabilities, browser_profile)
File "C:\Python27\lib\site-packages\selenium\webdriver\remote\", line 141, in start_session
'desiredCapabilities': desired_capabilities,

even if I already used the correct chromedriver location:

browser = webdriver.Chrome("C:/Python27/chromedriver.exe")

the error still showed up.