Login to web application - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Web Scraping & Web Development (https://python-forum.io/forum-13.html) +--- Thread: Login to web application (/thread-12784.html) |
Login to web application - malinowy - Sep-12-2018 Hello, I am using many environments of an application in my work. Each environment has a different URL. I am using the webbrowser module to quickly open the app in a particular environment from the windows CMD. See the code below. Now I want to go further and once the application is open in a browser then to log in automatically. I found that I could use selenium to automatically log in. The point is that my application is working in IE 11 only and selenium seems to be not working with IE 11. I had to make some entries to the registry but still getting errors. My question is how to log in to the web app not using selenium? import webbrowser, sys url = 'google.com' if len(sys.argv) > 1: arg = str(sys.argv[1]).upper() else: arg = "" prod='https://produrl' uat='https://uat' sit='http://sit' dev='http://dev' reftest='http://reftest' refqa='http://refqa' refdev='http://dev' if arg == 'PROD': url = prod elif arg == 'UAT': url = uat elif arg == 'SIT': url = sit elif arg == 'DEV': url = dev elif arg == 'REFTEST': url = reftest elif arg == 'REFQA': url = refqa elif arg == 'REFDEV': url = refdev else: if arg: url = 'unknown' else: url = 'none' if url == 'none': print ('W parametrze musisz podać nazwę środowiska...') elif url == 'unknown': print ('Nie znam takiego środowiska...%s' %(arg)) else: webbrowser.get(webbrowser.iexplore).open_new_tab(url) print ('Otwieram...%s' %(arg)) RE: Login to web application - buran - Sep-12-2018 first of all, your code can be shortened to import webbrowser, sys urls = {'prod':'https://produrl', 'uat':'https://uat', 'sit':'http://sit', 'dev':'http://dev', 'reftest'='http://reftest', 'refqa':'http://refqa' 'refdev':'http://dev'} if len(sys.argv) == 1: print ('W parametrze musisz podać nazwę środowiska...') else: arg = sys.argv[1].lower() url = urls.get(arg, None) if url: webbrowser.get(webbrowser.iexplore).open_new_tab(url) print ('Otwieram {}...'.format(arg)) else: print ('Nie znam takiego środowiska {}...'.format(arg))not sure if it will work but you may try to use some of the modules like pywinauto, pyautogui |