Building on the answer from @Shady Programmer.
I tried to send Tab
keys with selenium in order to focus on the popup, but as reported by others it didn't work in Linux. Therefore, instead of using selenium keys, I use xdotool
command from python :
def send_key(winid, key):
xdotool_args = ['xdotool', 'windowactivate', '--sync', winid, 'key', key]
subprocess.check_output(xdotool_args)
which for Firefox, gives the following approximate sequence :
# Focusing on permissions popup icon
for i in range(6):
time.sleep(0.1)
send_key(win_info['winid'], 'Tab')
# Enter permissions popup
time.sleep(0.1)
send_key(win_info['winid'], 'space')
# Focus on "accept" button
for i in range(3):
time.sleep(0.1)
send_key(win_info['winid'], 'Tab')
# Press "accept"
send_key(win_info['winid'], 'a')