0

Chrome version 89 and set up below setting and still not dismissing the permission popup which blocks the rest of test cases. Any idea or workaround? enter image description here

capabilities: [{
    
        // maxInstances can get overwritten per capability. So if you have an in-house Selenium
        // grid with only 5 firefox instances available you can make sure that not more than
        // 5 instances get started at a time.
        maxInstances: 1,
        //
        browserName: 'chrome',
        'goog:chromeOptions': {
            // to run chrome headless the following flags are required
            // (see https://developers.google.com/web/updates/2017/04/headless-chrome)
            // args: ['--headless', '--disable-gpu'],
            prefs: {
                'profile.managed_default_content_settings.popups' : 1,
                'profile.managed_default_content_settings.notifications' : 1,
            },
            args: ['--auto-open-devtools-for-tabs',  'disable-infobars', 'disable-popup-blocking', 'disable-notifications']
        },
        // If outputDir is provided WebdriverIO can capture driver session logs
        // it is possible to configure which logTypes to include/exclude.
        // excludeDriverLogs: ['*'], // pass '*' to exclude all driver session logs
        // excludeDriverLogs: ['bugreport', 'server'],
    }],

newBike
  • 12,989
  • 25
  • 88
  • 158

1 Answers1

1

This is a workaround, but, if you're using Python and the popup appears in a consistent location, you can use pyautogui to click the block or allow button and close the popup. See sample code, below:

import pyautogui 

# ensure the Selenium-managed browser has the focus and will receive the click   
driver.switch_to.window(driver.current_window_handle) 

# moveTo the X and Y coordinate of the block or allow button
pyautogui.moveTo(1350, 700) 

# click the block or allow button
pyautogui.click()

If you need to determine the X and Y coordinate, the code below can help:

import pyautogui, sys
print('Press Ctrl-C to quit.')
try:
    while True:
        x, y = pyautogui.position()
        positionStr = 'X: ' + str(x).rjust(4) + ' Y: ' + str(y).rjust(4)
        print(positionStr, end='')
        print('\b' * len(positionStr), end='', flush=True)
except KeyboardInterrupt:
    print('\n')
Rob
  • 21
  • 3