Sep-05-2017, 12:25 AM
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:
2- Loading User profile in Firefox with selenium.
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
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)
Error: self.browser = webdriver.Chrome(chrome_options=chrome_options)
File "C:\ProgramData\Anaconda3\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 69, in __init__
desired_capabilities=desired_capabilities)
File "C:\ProgramData\Anaconda3\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 140, in __init__
self.start_session(desired_capabilities, browser_profile)
File "C:\ProgramData\Anaconda3\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 229, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "C:\ProgramData\Anaconda3\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 297, in execute
self.error_handler.check_response(response)
File "C:\ProgramData\Anaconda3\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 194, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: crashed
(Driver info: chromedriver=2.32.498550 (9dec58e66c31bcc53a9ce3c7226f0c1c5810906a),platform=Windows NT 10.0.15063 x86_64)
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