Feb-11-2019, 02:55 PM
(Feb-10-2019, 06:39 PM)metulburr Wrote: I dont believe you can use selenium without using the driver. What popup window are you referring to? A popup can be dismissed via selenium.driver.switch_to
can handle switching windows such as popups or tabs. In which you would switch to it and close it, then return to the parent window. You can also try to dismiss notifications before via something similar to this depending on what popup you are talking about
def chrome_prep(self): '''get rid of asking to save password and notifications popup''' chrome_options = webdriver.ChromeOptions() chrome_options.add_experimental_option( 'prefs', { 'credentials_enable_service': False, "profile.default_content_setting_values.notifications" : 2, 'profile': { 'password_manager_enabled': False } } ) return chrome_options def setup_chrome(self): options = self.chrome_prep() self.browser = webdriver.Chrome(CHROMEPATH, chrome_options=options)You can open a new tab via javascriptdriver.execute_script("window.open('');")
and then switch to it and open a url. Such as:
#driver.get("https://malaysia.yahoo.com/?p=us") driver.execute_script("window.open('');") driver.switch_to.window(driver.window_handles[1]) driver.get('https://python-forum.io') driver.switch_to.window(driver.window_handles[0]) driver.get('https://malaysia.yahoo.com/?p=us')You can build an exe using Pyinstaller
Whenever I launch the chromedriver.exe it will popped 1 new window, and I don't want it be showed.
Regarding the chrome_options, I don't know why I can't execute as I did follow online example.
It said, "use options instead of chrome_options"
Regarding the tab via JavaScript, how can I check? If Chrome Broswer is open then open as new tab, else open new Chrome Browser.
Thanks.