Search code examples
pythonseleniumgoogle-chromeui-automationslack

Selenium Python getting around "Open <...>.app?"


I am trying to write e2e tests for a Slack bot and while logging in via browser it always asks whether I'd like to use the Slack desktop app instead of continuing with the browser (its Chrome by the way). Steps the Selenium webdriver is performing:

  1. Visit https://company-name.slack.com
  2. Fill in the email and password
  3. Click Sign In button
  4. Then this shows up:

Open Slack.app Pop-Up

This is not a normal browser alert but I'd like to get rid of it. I have tried the following:

  1. webdriver.switch_to.alert.dismiss() Does not dismiss this pop-up
  2. Adding the chrome_options.add_argument('--disable-default-apps') switch also doesn't prevent the pop-up from showing
  3. Have tried the headless version as well, test failure suggests that the pop-up interrupted the flow.

This also has to work on CI servers so please if the solution didn't involve modifying developer machine then that would be wonderful.


Solution

  • Well, this is not an answer but a workaround. I managed to get around the default-app pop-up by continuing my operations in a new tab (But not before checking whether there is a pop-up in the first place). Psuedo code:

    try
        find_element_by_whatever(element_you_expect_after_login)
    catch TimeoutException
        webdriver.execute_script('window.open()')
        webdriver.switch_to.window(webdriver.window_handles[1])
        webdriver.get(url_which_required_login_in_the_first_place)