VoiceControlBrowsers: Need help with selenium {adding user profiles} - 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: VoiceControlBrowsers: Need help with selenium {adding user profiles} (/thread-4712.html) |
VoiceControlBrowsers: Need help with selenium {adding user profiles} - hbknjr - Sep-05-2017 Hi all, Here my project. I'm using selenium, gtts and speechrecognition to add voice interface to the browsers. Right now I'm using api.ai machine learning bot to process the speech. Currently, it works with chrome and firefox[default profile]. My problems. 1- Loading User profile in chrome with selenium. I tried: #CHROME Chrome_UserData_Dir = "C:\\Users\\{user name}\\AppData\\Local\\Google\\Chrome\\User Data" chrome_options = Options() chrome_options.add_argument("user-data-dir=" + Chrome_UserData_Dir) self.browser = webdriver.Chrome(chrome_options=chrome_options) Though the browser opens with my profile loaded, the program than crashes giving that error.2- Loading User profile in Firefox with selenium. Firefox_UserData_Dir = 'path to firefox profile' firefox_profile = webdriver.FirefoxProfile(Firefox_UserData_Dir) self.browser = webdriver.Firefox(firefox_profile=firefox_profile)It runs but the behaviour is strange. eg- It opens new window intead of new tab. 3- My third problem is optimisation. I need help optimizing this project and reducing too many if-else statements. PS: feel free to contribute to this open source project RE: VoiceControlBrowsers: Need help with selenium {adding user profiles} - hbknjr - Sep-06-2017 UPDATE: I solved the first issue of Chrome crashing if a user profile is loaded, by killing every chrome.exe or chromedriver.exe process before calling selenium webdriver. def kill_chrome_process(): import psutil for p in psutil.process_iter(): try: if p.name() in ['chrome.exe', 'chromedriver.exe']: p.kill() except psutil.Error: passBut Firefox isn't working properly when user profile is loaded. I wonder if I was right choosing Selenium instead of some GUI automation library like PyWinAuto. |